From 9298246bcb4c2810be322f5d4612f8c70d4d624c Mon Sep 17 00:00:00 2001 From: Krishna Date: Fri, 29 Mar 2024 09:46:03 +0530 Subject: [PATCH 01/16] initial setup Signed-off-by: Krishna --- src/authentication.ts | 30 ++- src/cliAgent.ts | 17 +- .../additional-endpoint/context.controller.ts | 211 ++++++++++++++++++ .../multitenant.controller.ts | 46 ++++ src/controllers/agent/AgentController.ts | 6 + .../multi-tenancy/MultiTenancyController.ts | 1 + src/controllers/types.ts | 7 + src/enums/enum.ts | 6 + src/routes/routes.ts | 1 + src/routes/swagger.json | 6 +- src/securityMiddleware.ts | 8 +- src/server.ts | 3 + 12 files changed, 337 insertions(+), 5 deletions(-) create mode 100644 src/controllers/additional-endpoint/context.controller.ts create mode 100644 src/controllers/additional-endpoint/multitenant.controller.ts diff --git a/src/authentication.ts b/src/authentication.ts index 30cf4bf6..56a69c7e 100644 --- a/src/authentication.ts +++ b/src/authentication.ts @@ -1,6 +1,9 @@ import type * as express from 'express' +import { AgentType } from './enums/enum' + +import { Agent, LogLevel } from '@aries-framework/core' +import jwt from 'jsonwebtoken' -import { LogLevel } from '@aries-framework/core' import { TsLogger } from './utils/logger' @@ -19,6 +22,12 @@ export async function expressAuthentication( const apiKeyHeader = request.headers['authorization'] + if (!apiKeyHeader) { + return false + } + + // add additional logic to get the token from wallet for validating the passed + if (securityName === 'apiKey') { if (apiKeyHeader) { const providedApiKey = apiKeyHeader as string @@ -28,6 +37,25 @@ export async function expressAuthentication( } } } + + if (securityName === 'RootAuthorization') { + const tenancy = true + const token = apiKeyHeader + const decodedToken: jwt.JwtPayload = jwt.decode(token) as jwt.JwtPayload + const role: AgentType = decodedToken.role + // Krish: figure out how can we get token from agent's generic records + // const secretKey = this.agent + + if (role === AgentType.AgentWithoutTenant && tenancy === true) { + return false + } + + if (role === AgentType.AgentWithTenant && tenancy === false) { + return false + } + + // const verified = jwt.verify(token, ) + } } export function setDynamicApiKey(newApiKey: string) { diff --git a/src/cliAgent.ts b/src/cliAgent.ts index 0281332c..434b9b2c 100644 --- a/src/cliAgent.ts +++ b/src/cliAgent.ts @@ -53,6 +53,8 @@ import { randomBytes } from 'crypto' import { readFile } from 'fs/promises' import jwt from 'jsonwebtoken' +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import { AgentType } from './enums/enum' import { setupServer } from './server' import { TsLogger } from './utils/logger' import { BCOVRIN_TEST_GENESIS } from './utils/util' @@ -347,7 +349,19 @@ export async function runRestAgent(restConfig: AriesRestConfig) { // instead use the existin JWT token // if JWT token is not found, create/generate a new token and save in genericRecords // next time, the same token should be used - instead of creating a new token on every restart event of the agent - token = jwt.sign({ agentInfo: 'agentInfo' }, secretKeyInfo) + + // Krish: Should add agent role and tenant id in case of tenants + // token = jwt.sign({ agentInfo: 'agentInfo' }, secretKeyInfo) + + // agent role set for dedicated agent and base-wallet respectively + if (!('tenants' in agent.modules)) { + token = jwt.sign({ role: AgentType.AgentWithoutTenant }, secretKeyInfo) + } else { + token = jwt.sign({ role: AgentType.AgentWithTenant }, secretKeyInfo) + } + + // Krish: there should be no need to store the token if it is a refresh token. It's okay to save it for now and return it in the additional endpoint + console.log('--------------if---------------', token) await agent.genericRecords.save({ content: { secretKey: secretKeyInfo, @@ -357,6 +371,7 @@ export async function runRestAgent(restConfig: AriesRestConfig) { } else { const recordWithToken = genericRecord.find((record) => record?.content?.token !== undefined) token = recordWithToken?.content.token as string + console.log('--------------else---------------', token) } const app = await setupServer( diff --git a/src/controllers/additional-endpoint/context.controller.ts b/src/controllers/additional-endpoint/context.controller.ts new file mode 100644 index 00000000..1b87b6ef --- /dev/null +++ b/src/controllers/additional-endpoint/context.controller.ts @@ -0,0 +1,211 @@ +// import type { OutOfBandInvitationProps, OutOfBandRecordWithInvitationProps } from '../examples' +import type { OutOfBandInvitationProps, OutOfBandRecordWithInvitationProps } from '../examples' +// eslint-disable-next-line import/order +import type { RecipientKeyOption } from '../types' // AgentMessageType, +// import type { ConnectionRecordProps, CreateLegacyInvitationConfig, Routing } from '@aries-framework/core' + +import type { CreateLegacyInvitationConfig, CreateOutOfBandInvitationConfig, Routing } from '@aries-framework/core' +import type { GenericRecord } from '@aries-framework/core/build/modules/generic-records/repository/GenericRecord' + +import { + // AgentMessage, + // JsonTransformer, + // OutOfBandInvitation, + Agent, + Key, + KeyType, + // RecordNotFoundError, + // Key, + // KeyType, +} from '@aries-framework/core' +import { injectable } from 'tsyringe' + +// import { ConnectionRecordExample, outOfBandInvitationExample, outOfBandRecordExample, RecordId } from '../examples' +// import { +// AcceptInvitationConfig, +// ReceiveInvitationByUrlProps, +// ReceiveInvitationProps, +// CreateInvitationOptions, +// } from '../types' + +import { outOfBandInvitationExample, outOfBandRecordExample } from '../examples' + +import { + Body, + Controller, + // Delete, + Example, + Get, + Path, + Post, + // Query, + Res, + Route, + Tags, + TsoaResponse, + Security, +} from 'tsoa' + +@Tags('Out Of Band') +@Security('authorization') +@Route('/testEndpoint') +@injectable() +export class ContextController extends Controller { + // private agent: Agent + + // public constructor(agent: Agent) { + // super() + // this.agent = agent + // } + + // @Get('/get-token') + // public async getAgentToken(): Promise { + // const agentDetails = await this.agent.genericRecords.getAll() + // return agentDetails + // } + + // This is multi-tenant invitation endpoint + // @Security('apiKey') + // @Post('/create-legacy-invitation/:tenantId') + // public async createLegacyInvitation( + // @Res() internalServerError: TsoaResponse<500, { message: string }>, + // @Path('tenantId') tenantId: string, + // @Body() + // config?: Omit & RecipientKeyOption // props removed because of issues with serialization + // ) { + // let getInvitation + // try { + // let routing: Routing + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // if (config?.recipientKey) { + // routing = { + // endpoints: tenantAgent.config.endpoints, + // routingKeys: [], + // recipientKey: Key.fromPublicKeyBase58(config.recipientKey, KeyType.Ed25519), + // mediatorId: undefined, + // } + // } else { + // routing = await tenantAgent.mediationRecipient.getRouting({}) + // } + // const { outOfBandRecord, invitation } = await tenantAgent.oob.createLegacyInvitation({ ...config, routing }) + // getInvitation = { + // invitationUrl: invitation.toUrl({ + // domain: this.agent.config.endpoints[0], + // useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, + // }), + // invitation: invitation.toJSON({ + // useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, + // }), + // outOfBandRecord: outOfBandRecord.toJSON(), + // ...(config?.recipientKey ? {} : { recipientKey: routing.recipientKey.publicKeyBase58 }), + // } + // }) + + // return getInvitation + // } catch (error) { + // return internalServerError(500, { message: `something went wrong: ${error}` }) + // } + // } + + // This is dedicated agent invitation endpoint + /** + * Creates an outbound out-of-band record in the same way how `createInvitation` method does it, + * but it also converts out-of-band invitation message to an "legacy" invitation message defined + * in RFC 0160: Connection Protocol and returns it together with out-of-band record. + * + * @param config configuration of how a invitation should be created + * @returns out-of-band record and invitation + */ + // @Example<{ invitation: OutOfBandInvitationProps; outOfBandRecord: OutOfBandRecordWithInvitationProps }>({ + // invitation: outOfBandInvitationExample, + // outOfBandRecord: outOfBandRecordExample, + // }) + // @Post('/create-legacy-invitation') + // public async createLegacyInvitation( + // @Res() internalServerError: TsoaResponse<500, { message: string }>, + // @Body() config?: Omit & RecipientKeyOption + // ) { + // try { + // let routing: Routing + // if (config?.recipientKey) { + // routing = { + // endpoints: this.agent.config.endpoints, + // routingKeys: [], + // recipientKey: Key.fromPublicKeyBase58(config.recipientKey, KeyType.Ed25519), + // mediatorId: undefined, + // } + // } else { + // routing = await this.agent.mediationRecipient.getRouting({}) + // } + // const { outOfBandRecord, invitation } = await this.agent.oob.createLegacyInvitation({ + // ...config, + // routing, + // }) + // return { + // invitationUrl: invitation.toUrl({ + // domain: this.agent.config.endpoints[0], + // useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, + // }), + // invitation: invitation.toJSON({ + // useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, + // }), + // outOfBandRecord: outOfBandRecord.toJSON(), + // ...(config?.recipientKey ? {} : { recipientKey: routing.recipientKey.publicKeyBase58 }), + // } + // } catch (error) { + // return internalServerError(500, { message: `something went wrong: ${error}` }) + // } + // } + + // Create a common function that calls createLegacyInvitation + /** + * Creates an outbound out-of-band record in the same way how `createInvitation` method does it, + * but it also converts out-of-band invitation message to an "legacy" invitation message defined + * in RFC 0160: Connection Protocol and returns it together with out-of-band record. + * + * @param config configuration of how a invitation should be created + * @returns out-of-band record and invitation + */ + @Example<{ invitation: OutOfBandInvitationProps; outOfBandRecord: OutOfBandRecordWithInvitationProps }>({ + invitation: outOfBandInvitationExample, + outOfBandRecord: outOfBandRecordExample, + }) + @Post('/create-legacy-invitation') + public async createLegacyInvitation( + @Res() internalServerError: TsoaResponse<500, { message: string }>, + @Body() config?: Omit & RecipientKeyOption + ) { + try { + let routing: Routing + if (config?.recipientKey) { + routing = { + endpoints: this.agent.config.endpoints, + routingKeys: [], + recipientKey: Key.fromPublicKeyBase58(config.recipientKey, KeyType.Ed25519), + mediatorId: undefined, + } + } else { + routing = await this.agent.mediationRecipient.getRouting({}) + } + const { outOfBandRecord, invitation } = await this.agent.oob.createLegacyInvitation({ + ...config, + routing, + }) + return { + invitationUrl: invitation.toUrl({ + domain: this.agent.config.endpoints[0], + useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, + }), + invitation: invitation.toJSON({ + useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, + }), + outOfBandRecord: outOfBandRecord.toJSON(), + ...(config?.recipientKey ? {} : { recipientKey: routing.recipientKey.publicKeyBase58 }), + } + } catch (error) { + return internalServerError(500, { message: `something went wrong: ${error}` }) + } + } + + +} diff --git a/src/controllers/additional-endpoint/multitenant.controller.ts b/src/controllers/additional-endpoint/multitenant.controller.ts new file mode 100644 index 00000000..1417cf98 --- /dev/null +++ b/src/controllers/additional-endpoint/multitenant.controller.ts @@ -0,0 +1,46 @@ +import type { TenantRecord } from '@aries-framework/tenants' + +import { Agent, RecordNotFoundError, injectable } from '@aries-framework/core' + +import { CreateTenantOptions } from '../types' + +import { Body, Controller, Post, Res, Route, Tags, TsoaResponse, Security } from 'tsoa' +import { RestMultiTenantAgentModules } from 'src/cliAgent' + +@Tags('MultiTenancy') +@Route('/multi-tenant') +@Security('NewAuth') +@injectable() +export class MultiTenancyController extends Controller { + //create wallet + public constructor(private readonly agent: Agent) { + super() + } + + @Security('apiKey') + @Post('/create-tenant') + public async createTenant( + @Body() createTenantOptions: CreateTenantOptions, + @Res() notFoundError: TsoaResponse<404, { reason: string }>, + @Res() internalServerError: TsoaResponse<500, { message: string }> + ) { + const { config } = createTenantOptions + try { + const tenantRecord: TenantRecord = await this.agent.modules.tenants.createTenant({ config }) + const token = this.getToken(tenantRecord.id) + const withToken = { token, ...tenantRecord} + return tenantRecord + } catch (error) { + if (error instanceof RecordNotFoundError) { + return notFoundError(404, { + reason: `Tenant not created`, + }) + } + + return internalServerError(500, { message: `Something went wrong: ${error}` }) + } + } + + private getTenant(tenantId: string){ + } +} diff --git a/src/controllers/agent/AgentController.ts b/src/controllers/agent/AgentController.ts index e7ccc708..0ce8c96a 100644 --- a/src/controllers/agent/AgentController.ts +++ b/src/controllers/agent/AgentController.ts @@ -21,11 +21,17 @@ export class AgentController extends Controller { */ @Get('/') public async getAgentInfo(): Promise { + // const details = await this.agent.genericRecords.getAll() + const genericRecord = await this.agent.genericRecords.getAll() + const recordWithToken = genericRecord.find((record) => record?.content?.token !== undefined) + const token = recordWithToken?.content.token as string return { label: this.agent.config.label, endpoints: this.agent.config.endpoints, isInitialized: this.agent.isInitialized, publicDid: undefined, + // token: details[0].content.token, + token: token, } } diff --git a/src/controllers/multi-tenancy/MultiTenancyController.ts b/src/controllers/multi-tenancy/MultiTenancyController.ts index 1bf05991..152bf6b0 100644 --- a/src/controllers/multi-tenancy/MultiTenancyController.ts +++ b/src/controllers/multi-tenancy/MultiTenancyController.ts @@ -87,6 +87,7 @@ import { export class MultiTenancyController extends Controller { private readonly agent: Agent + // Krish: can simply add 'private readonly' in constructor public constructor(agent: Agent) { super() this.agent = agent diff --git a/src/controllers/types.ts b/src/controllers/types.ts index 1c45ea6c..929f0740 100644 --- a/src/controllers/types.ts +++ b/src/controllers/types.ts @@ -1,5 +1,6 @@ import type { Version } from './examples' import type { AnonCredsCredentialFormat, LegacyIndyCredentialFormat } from '@aries-framework/anoncreds' +// eslint-disable-next-line import/order import type { AutoAcceptCredential, AutoAcceptProof, @@ -27,8 +28,13 @@ import type { KeyType, JsonLdCredentialFormat, } from '@aries-framework/core' + +// import type { GenericRecordsApi } from '@aries-framework/core/build/modules/generic-records' +// import type { GenericRecord } from '@aries-framework/core/build/modules/generic-records/repository/GenericRecord' import type { DIDDocument } from 'did-resolver' +// import type { GenericRecord } from '@aries-framework/core/build/modules/generic-records/repository/GenericRecord' + export type TenantConfig = Pick & { walletConfig: Pick } @@ -38,6 +44,7 @@ export interface AgentInfo { endpoints: string[] isInitialized: boolean publicDid: void + token: any // publicDid?: { // did: string // verkey: string diff --git a/src/enums/enum.ts b/src/enums/enum.ts index 3b355229..9e0bbcd9 100644 --- a/src/enums/enum.ts +++ b/src/enums/enum.ts @@ -21,3 +21,9 @@ export enum Network { Indicio_Demonet = 'indicio:demonet', Indicio_Mainnet = 'indicio:mainnet', } + +export enum AgentType { + AgentWithTenant = 'AgentWithTenant', + AgentWithoutTenant = 'AgentWithoutTenant', + TenantAgent = 'TenantAgent', +} diff --git a/src/routes/routes.ts b/src/routes/routes.ts index 4d348d79..1678c631 100644 --- a/src/routes/routes.ts +++ b/src/routes/routes.ts @@ -44,6 +44,7 @@ const models: TsoaRoute.Models = { "endpoints": {"dataType":"array","array":{"dataType":"string"},"required":true}, "isInitialized": {"dataType":"boolean","required":true}, "publicDid": {"dataType":"void","required":true}, + "token": {"dataType":"any","required":true}, }, "additionalProperties": false, }, diff --git a/src/routes/swagger.json b/src/routes/swagger.json index d36439fd..10d8b51d 100644 --- a/src/routes/swagger.json +++ b/src/routes/swagger.json @@ -21,13 +21,15 @@ "isInitialized": { "type": "boolean" }, - "publicDid": {} + "publicDid": {}, + "token": {} }, "required": [ "label", "endpoints", "isInitialized", - "publicDid" + "publicDid", + "token" ], "type": "object", "additionalProperties": false diff --git a/src/securityMiddleware.ts b/src/securityMiddleware.ts index ea8a5199..24693389 100644 --- a/src/securityMiddleware.ts +++ b/src/securityMiddleware.ts @@ -3,13 +3,14 @@ import type { NextFunction } from 'express' import { Middlewares } from '@tsoa/runtime' +// eslint-disable-next-line import/namespace import { expressAuthentication } from './authentication' // Import your authentication function @Middlewares() export class SecurityMiddleware { public async use(request: express.Request, response: express.Response, next: NextFunction) { try { - const securityName = 'apiKey' + let securityName = 'apiKey' // Extract route path or controller name from the request const routePath = request.path @@ -20,6 +21,11 @@ export class SecurityMiddleware { // Check if authentication should be skipped for this route or controller const skipAuthentication = pathsToSkipAuthentication.some((path) => routePath.includes(path)) + if (routePath.includes('/multi-tenant/')) { + securityName = 'RootAuthorization' + // const result = await expressAuthentication(request, securityName); + } + if (skipAuthentication) { // Skip authentication for this route or controller next() diff --git a/src/server.ts b/src/server.ts index c0a95010..46999859 100644 --- a/src/server.ts +++ b/src/server.ts @@ -10,6 +10,7 @@ import { rateLimit } from 'express-rate-limit' import { serve, generateHTML } from 'swagger-ui-express' import { container } from 'tsyringe' +// eslint-disable-next-line import/namespace import { setDynamicApiKey } from './authentication' import { basicMessageEvents } from './events/BasicMessageEvents' import { connectionEvents } from './events/ConnectionEvents' @@ -43,6 +44,8 @@ export const setupServer = async (agent: Agent, config: ServerConfig, apiKey?: s }) ) + // Krish: there's no need to currently store apiKey + // This will be verified based on the secretKey stored in wallet setDynamicApiKey(apiKey ? apiKey : '') app.use(bodyParser.json()) From 6858f2f75673fd32d1962ff5db40ac045a3e6d97 Mon Sep 17 00:00:00 2001 From: Krishna Date: Mon, 1 Apr 2024 17:36:56 +0530 Subject: [PATCH 02/16] working fine --- samples/cliConfig.json | 2 +- src/authentication.ts | 210 +++++++++++++++--- src/cliAgent.ts | 49 ++-- .../additional-endpoint/context.controller.ts | 94 ++++---- .../multitenant.Controller.ts | 82 +++++++ .../multitenant.controller.ts | 46 ---- src/routes/routes.ts | 36 +++ src/routes/swagger.json | 75 +++++++ src/securityMiddleware.ts | 13 +- src/server.ts | 19 +- src/utils/common.service.ts | 19 ++ src/utils/util.ts | 5 + tsoa.json | 5 + 13 files changed, 504 insertions(+), 151 deletions(-) create mode 100644 src/controllers/additional-endpoint/multitenant.Controller.ts delete mode 100644 src/controllers/additional-endpoint/multitenant.controller.ts create mode 100644 src/utils/common.service.ts diff --git a/samples/cliConfig.json b/samples/cliConfig.json index 2e5ef5f6..7e87ff4a 100644 --- a/samples/cliConfig.json +++ b/samples/cliConfig.json @@ -1,6 +1,6 @@ { "label": "AFJ Rest Agent 1", - "walletId": "sample", + "walletId": "sample1", "walletKey": "sample", "walletType": "postgres", "walletUrl": "localhost:5432", diff --git a/src/authentication.ts b/src/authentication.ts index 56a69c7e..da206a37 100644 --- a/src/authentication.ts +++ b/src/authentication.ts @@ -1,12 +1,38 @@ +import type { RestAgentModules, RestMultiTenantAgentModules } from './cliAgent' import type * as express from 'express' -import { AgentType } from './enums/enum' + +// import { Agent } from '@aries-framework/core' +// eslint-disable-next-line import/namespace +import type { Request } from 'express' import { Agent, LogLevel } from '@aries-framework/core' +import { TenantAgent } from '@aries-framework/tenants/build/TenantAgent' import jwt from 'jsonwebtoken' +import { container } from 'tsyringe' - +import { AgentType } from './enums/enum' import { TsLogger } from './utils/logger' +export type RequestWithAgent = RequestWithRootAgent | RequestWithTenantAgent | RequestWithRootTenantAgent + +export type RequestWithTenantAgent = Request & { + user: { + agent: TenantAgent + } +} + +export type RequestWithRootAgent = Request & { + user: { + agent: Agent + } +} + +export type RequestWithRootTenantAgent = Request & { + user: { + agent: Agent + } +} + let dynamicApiKey: string = 'api_key' // Initialize with a default value export async function expressAuthentication( @@ -15,49 +41,173 @@ export async function expressAuthentication( secMethod?: { [key: string]: any }, scopes?: string ) { - const logger = new TsLogger(LogLevel.info) + try { + const logger = new TsLogger(LogLevel.info) - logger.info(`secMethod::: ${JSON.stringify(secMethod)}`) - logger.info(`scopes::: ${JSON.stringify(scopes)}`) + logger.info(`secMethod::: ${JSON.stringify(secMethod)}`) + logger.info(`scopes::: ${JSON.stringify(scopes)}`) - const apiKeyHeader = request.headers['authorization'] + const apiKeyHeader = request.headers['authorization'] - if (!apiKeyHeader) { - return false - } + if (!apiKeyHeader) { + return false + } - // add additional logic to get the token from wallet for validating the passed + // add additional logic to get the token from wallet for validating the passed - if (securityName === 'apiKey') { - if (apiKeyHeader) { - const providedApiKey = apiKeyHeader as string + if (securityName === 'apiKey') { + if (apiKeyHeader) { + const providedApiKey = apiKeyHeader as string - if (providedApiKey === dynamicApiKey) { - return 'success' + if (providedApiKey === dynamicApiKey) { + return 'success' + } } } - } - if (securityName === 'RootAuthorization') { - const tenancy = true - const token = apiKeyHeader - const decodedToken: jwt.JwtPayload = jwt.decode(token) as jwt.JwtPayload - const role: AgentType = decodedToken.role - // Krish: figure out how can we get token from agent's generic records - // const secretKey = this.agent + if (securityName === 'NewAuth') { + const tenancy = true + const token = apiKeyHeader + const decodedToken: jwt.JwtPayload = jwt.decode(token) as jwt.JwtPayload + const role: AgentType = decodedToken.role + const reqPath = request.path + // Shound not contain any + // const rootAgent = container.resolve(Agent) + // Krish: figure out how can we get token from agent's generic records + // const secretKey = this.agent + + if (tenancy) { + const rootAgent = container.resolve(Agent) + // it should be a shared agent + if (role !== AgentType.AgentWithTenant && role !== AgentType.TenantAgent) { + return 'The agent is a multi-tenant agent' + } + + if (role === AgentType.TenantAgent && decodedToken.tenantId) { + // Logic if the token is of tenant agent + console.log('Middleware: Authentication: TenantAgent. The token is::', token) + if (reqPath.includes('/multi-tenant/')) { + return `Tenants can't manage tenants` + } else { + // verify tenant agent + const tenantId: string = decodedToken.tenantId + const tenantAgent = await rootAgent.modules.tenants.getTenantAgent({ + tenantId, + }) + const tenantAgent1: TenantAgent = await getTenantAgent(rootAgent, tenantId) + console.log('Log from console, tenantAgent1::::', tenantAgent1) + console.log('Log from console, tenantAgent::::', tenantAgent) + if (!tenantAgent) return + + const secretKey = await getSecretKey(tenantAgent) + const verified = jwt.verify(token, secretKey) + + // Failed to verify token + if (!verified) return + + // Only need to registerInstance for TenantAgent. + // As Instance of RootAgent with and without tenant will already be registered while starting the server + container.registerInstance(TenantAgent, tenantAgent) + } + } else if (role === AgentType.AgentWithTenant) { + // Logic for base wallet verification + const verified = await verifyToken(rootAgent, token) + + console.log('Middleware: Authentication: Basewallet. The token is::', token) + console.log('The verified is::', verified) + if (!verified) return + + return 'success' + } else { + return 'Invalid Token' + } + } else { + const rootAgent = container.resolve(Agent) + // it should be a dedicated agent + if (role !== AgentType.AgentWithoutTenant) { + return 'This is a dedicated agent' + } else { + // It has a role of dedicated agent + // Verify dedicated agent + const verified = await verifyToken(rootAgent, token) + + console.log('Reached here. The token is::', token) + console.log('The verified is::', verified) + if (!verified) return + + // Can have an enum instead of 'success' string + // return RESULT.SUCCESS + return 'success' + } + } - if (role === AgentType.AgentWithoutTenant && tenancy === true) { - return false + // if (role === AgentType.AgentWithoutTenant) { + // if (tenancy === true) { + // return false + // } + // } + + // if (role === AgentType.AgentWithTenant) { + // if (tenancy === false) { + // return false + // } + // else { + // // eslint-disable-next-line @typescript-eslint/no-unused-vars + // const agent: Agent + // const genericRecord = await agent.genericRecords.getAll() + // const recordWithToken = genericRecord.find((record) => record?.content?.token !== undefined) + // token = recordWithToken?.content.token as string + // return 'success' + // } + // } + + // const verified = jwt.verify(token, ) } - - if (role === AgentType.AgentWithTenant && tenancy === false) { - return false + } catch (error) { + const logger = new TsLogger(LogLevel.error) + if (error instanceof Error) { + logger.error('Error in Authentication', error) } - - // const verified = jwt.verify(token, ) } } +async function verifyToken(agent: Agent, token: string): Promise { + // try { + const secretKey = await getSecretKey(agent) + const verified = jwt.verify(token, secretKey) + + return verified ? true : false + // } catch (error) { + // if (error instanceof Error) { + // logger.error('Token Invalid') + // } + // } +} + +// Common function to pass agent object and get secretKey +async function getSecretKey( + agent: Agent | TenantAgent +): Promise { + const genericRecord = await agent.genericRecords.getAll() + const recordWithToken = genericRecord.find((record) => record?.content?.secretKey !== undefined) + const secretKey = recordWithToken?.content.secretKey as string + + return secretKey +} + +async function getTenantAgent( + agent: Agent, + tenantId: string +): Promise> { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + return new Promise((resolve) => { + agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // Some logic + resolve(tenantAgent) + }) + }) +} + export function setDynamicApiKey(newApiKey: string) { dynamicApiKey = newApiKey } diff --git a/src/cliAgent.ts b/src/cliAgent.ts index 434b9b2c..8d501af5 100644 --- a/src/cliAgent.ts +++ b/src/cliAgent.ts @@ -49,13 +49,16 @@ import { anoncreds } from '@hyperledger/anoncreds-nodejs' import { ariesAskar } from '@hyperledger/aries-askar-nodejs' import { indyVdr } from '@hyperledger/indy-vdr-nodejs' import axios from 'axios' -import { randomBytes } from 'crypto' import { readFile } from 'fs/promises' +// eslint-disable-next-line import/order import jwt from 'jsonwebtoken' // eslint-disable-next-line @typescript-eslint/no-unused-vars +import { container } from 'tsyringe' + import { AgentType } from './enums/enum' import { setupServer } from './server' +import { generateSecretKey } from './utils/common.service' import { TsLogger } from './utils/logger' import { BCOVRIN_TEST_GENESIS } from './utils/util' @@ -115,6 +118,12 @@ export type RestMultiTenantAgentModules = Awaited> +// export type RestMultiTenantAgentModules = Awaited> +// type AgentWithTenantModules = Awaited> +// type AgentWithoutTenantModules = Awaited> +// export type RestMultiTenantAgentModules = Agent +// export type RestAgentModules = Agent + const getModules = (networkConfig: [IndyVdrPoolConfig, ...IndyVdrPoolConfig[]]) => { const legacyIndyCredentialFormat = new LegacyIndyCredentialFormatService() const legacyIndyProofFormat = new LegacyIndyProofFormatService() @@ -204,23 +213,24 @@ const getWithTenantModules = (networkConfig: [IndyVdrPoolConfig, ...IndyVdrPoolC } } -async function generateSecretKey(length: number = 32): Promise { - // Asynchronously generate a buffer containing random values - const buffer: Buffer = await new Promise((resolve, reject) => { - randomBytes(length, (error, buf) => { - if (error) { - reject(error) - } else { - resolve(buf) - } - }) - }) - - // Convert the buffer to a hexadecimal string - const secretKey: string = buffer.toString('hex') - - return secretKey -} +// Add this function in common service +// async function generateSecretKey(length: number = 32): Promise { +// // Asynchronously generate a buffer containing random values +// const buffer: Buffer = await new Promise((resolve, reject) => { +// randomBytes(length, (error, buf) => { +// if (error) { +// reject(error) +// } else { +// resolve(buf) +// } +// }) +// }) + +// // Convert the buffer to a hexadecimal string +// const secretKey: string = buffer.toString('hex') + +// return secretKey +// } export async function runRestAgent(restConfig: AriesRestConfig) { const { @@ -329,6 +339,9 @@ export async function runRestAgent(restConfig: AriesRestConfig) { await agent.initialize() + // Add the agent context to container in tsyringe + // container.registerInstance(Agent, agent as Agent) + let token: string = '' const genericRecord = await agent.genericRecords.getAll() diff --git a/src/controllers/additional-endpoint/context.controller.ts b/src/controllers/additional-endpoint/context.controller.ts index 1b87b6ef..e633a2c9 100644 --- a/src/controllers/additional-endpoint/context.controller.ts +++ b/src/controllers/additional-endpoint/context.controller.ts @@ -1,10 +1,12 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ // import type { OutOfBandInvitationProps, OutOfBandRecordWithInvitationProps } from '../examples' import type { OutOfBandInvitationProps, OutOfBandRecordWithInvitationProps } from '../examples' // eslint-disable-next-line import/order import type { RecipientKeyOption } from '../types' // AgentMessageType, // import type { ConnectionRecordProps, CreateLegacyInvitationConfig, Routing } from '@aries-framework/core' -import type { CreateLegacyInvitationConfig, CreateOutOfBandInvitationConfig, Routing } from '@aries-framework/core' +import type { CreateLegacyInvitationConfig, Routing } from '@aries-framework/core' +// eslint-disable-next-line @typescript-eslint/no-unused-vars import type { GenericRecord } from '@aries-framework/core/build/modules/generic-records/repository/GenericRecord' import { @@ -47,23 +49,20 @@ import { } from 'tsoa' @Tags('Out Of Band') -@Security('authorization') +// @Security('authorization') @Route('/testEndpoint') @injectable() export class ContextController extends Controller { // private agent: Agent - // public constructor(agent: Agent) { // super() // this.agent = agent // } - // @Get('/get-token') // public async getAgentToken(): Promise { // const agentDetails = await this.agent.genericRecords.getAll() // return agentDetails // } - // This is multi-tenant invitation endpoint // @Security('apiKey') // @Post('/create-legacy-invitation/:tenantId') @@ -100,13 +99,11 @@ export class ContextController extends Controller { // ...(config?.recipientKey ? {} : { recipientKey: routing.recipientKey.publicKeyBase58 }), // } // }) - // return getInvitation // } catch (error) { // return internalServerError(500, { message: `something went wrong: ${error}` }) // } // } - // This is dedicated agent invitation endpoint /** * Creates an outbound out-of-band record in the same way how `createInvitation` method does it, @@ -156,7 +153,6 @@ export class ContextController extends Controller { // return internalServerError(500, { message: `something went wrong: ${error}` }) // } // } - // Create a common function that calls createLegacyInvitation /** * Creates an outbound out-of-band record in the same way how `createInvitation` method does it, @@ -166,46 +162,44 @@ export class ContextController extends Controller { * @param config configuration of how a invitation should be created * @returns out-of-band record and invitation */ - @Example<{ invitation: OutOfBandInvitationProps; outOfBandRecord: OutOfBandRecordWithInvitationProps }>({ - invitation: outOfBandInvitationExample, - outOfBandRecord: outOfBandRecordExample, - }) - @Post('/create-legacy-invitation') - public async createLegacyInvitation( - @Res() internalServerError: TsoaResponse<500, { message: string }>, - @Body() config?: Omit & RecipientKeyOption - ) { - try { - let routing: Routing - if (config?.recipientKey) { - routing = { - endpoints: this.agent.config.endpoints, - routingKeys: [], - recipientKey: Key.fromPublicKeyBase58(config.recipientKey, KeyType.Ed25519), - mediatorId: undefined, - } - } else { - routing = await this.agent.mediationRecipient.getRouting({}) - } - const { outOfBandRecord, invitation } = await this.agent.oob.createLegacyInvitation({ - ...config, - routing, - }) - return { - invitationUrl: invitation.toUrl({ - domain: this.agent.config.endpoints[0], - useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, - }), - invitation: invitation.toJSON({ - useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, - }), - outOfBandRecord: outOfBandRecord.toJSON(), - ...(config?.recipientKey ? {} : { recipientKey: routing.recipientKey.publicKeyBase58 }), - } - } catch (error) { - return internalServerError(500, { message: `something went wrong: ${error}` }) - } - } - - + // @Example<{ invitation: OutOfBandInvitationProps; outOfBandRecord: OutOfBandRecordWithInvitationProps }>({ + // invitation: outOfBandInvitationExample, + // outOfBandRecord: outOfBandRecordExample, + // }) + // @Post('/create-legacy-invitation') + // public async createLegacyInvitation( + // @Res() internalServerError: TsoaResponse<500, { message: string }>, + // @Body() config?: Omit & RecipientKeyOption + // ) { + // try { + // let routing: Routing + // if (config?.recipientKey) { + // routing = { + // endpoints: this.agent.config.endpoints, + // routingKeys: [], + // recipientKey: Key.fromPublicKeyBase58(config.recipientKey, KeyType.Ed25519), + // mediatorId: undefined, + // } + // } else { + // routing = await this.agent.mediationRecipient.getRouting({}) + // } + // const { outOfBandRecord, invitation } = await this.agent.oob.createLegacyInvitation({ + // ...config, + // routing, + // }) + // return { + // invitationUrl: invitation.toUrl({ + // domain: this.agent.config.endpoints[0], + // useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, + // }), + // invitation: invitation.toJSON({ + // useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, + // }), + // outOfBandRecord: outOfBandRecord.toJSON(), + // ...(config?.recipientKey ? {} : { recipientKey: routing.recipientKey.publicKeyBase58 }), + // } + // } catch (error) { + // return internalServerError(500, { message: `something went wrong: ${error}` }) + // } + // } } diff --git a/src/controllers/additional-endpoint/multitenant.Controller.ts b/src/controllers/additional-endpoint/multitenant.Controller.ts new file mode 100644 index 00000000..77f61ae6 --- /dev/null +++ b/src/controllers/additional-endpoint/multitenant.Controller.ts @@ -0,0 +1,82 @@ +import type { RestMultiTenantAgentModules } from '../../cliAgent' +import type { TenantRecord } from '@aries-framework/tenants' + +// eslint-disable-next-line import/order +import { Agent, RecordNotFoundError, injectable } from '@aries-framework/core' + +import jwt from 'jsonwebtoken' + +import { RequestWithRootTenantAgent } from '../../authentication' +import { AgentType } from '../../enums/enum' +import { generateSecretKey } from '../../utils/common.service' +import { CreateTenantOptions } from '../types' + +// import { AgentType } from 'src/enums/enum' +import { Body, Controller, Post, Request, Res, Route, Security, Tags, TsoaResponse } from 'tsoa' + +@Tags('Multi Tenant') +@Route('/test-endpoint/multi-tenant') +// @Security('NewAuth') +@injectable() +export class MultiTenantController extends Controller { + // private readonly agent: Agent + + // Krish: can simply add 'private readonly' in constructor + public constructor(private readonly agent: Agent) { + super() + this.agent = agent + } + + // @Security('RootAuthorization') + @Security('NewAuth') + @Post('/create-tenant') + public async createTenant( + @Request() request: RequestWithRootTenantAgent, + @Body() createTenantOptions: CreateTenantOptions, + @Res() notFoundError: TsoaResponse<404, { reason: string }>, + @Res() internalServerError: TsoaResponse<500, { message: string }> + ) { + const { config } = createTenantOptions + try { + const tenantRecord: TenantRecord = await this.agent.modules.tenants.createTenant({ config }) + const token = await this.getToken(tenantRecord.id) + const withToken = { token, ...tenantRecord } + return withToken + return 'success' + } catch (error) { + if (error instanceof RecordNotFoundError) { + return notFoundError(404, { + reason: `Tenant not created`, + }) + } + + return internalServerError(500, { message: `Something went wrong: ${error}` }) + } + } + + private async createToken(tenantId: string) { + const secretKey = await generateSecretKey() + // const genericRecord = await this.agent.genericRecords.getAll() + // const records = genericRecord.find((record) => record?.content?.secretKey !== undefined) + // const secretKey = records?.content.secretKey as string + const token = jwt.sign({ role: AgentType.TenantAgent, tenantId }, secretKey) + // Save token to individual tenants generic records + await this.saveTokenAndSecretKey(token, secretKey, tenantId) + return token + } + + private async saveTokenAndSecretKey(token: string, secretKey: string, tenantId: string) { + await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + tenantAgent.genericRecords.save({ + content: { + secretKey: secretKey, + }, + }) + }) + } + + private async getToken(tenantId: string) { + const token: string = await this.createToken(tenantId) + return token + } +} diff --git a/src/controllers/additional-endpoint/multitenant.controller.ts b/src/controllers/additional-endpoint/multitenant.controller.ts deleted file mode 100644 index 1417cf98..00000000 --- a/src/controllers/additional-endpoint/multitenant.controller.ts +++ /dev/null @@ -1,46 +0,0 @@ -import type { TenantRecord } from '@aries-framework/tenants' - -import { Agent, RecordNotFoundError, injectable } from '@aries-framework/core' - -import { CreateTenantOptions } from '../types' - -import { Body, Controller, Post, Res, Route, Tags, TsoaResponse, Security } from 'tsoa' -import { RestMultiTenantAgentModules } from 'src/cliAgent' - -@Tags('MultiTenancy') -@Route('/multi-tenant') -@Security('NewAuth') -@injectable() -export class MultiTenancyController extends Controller { - //create wallet - public constructor(private readonly agent: Agent) { - super() - } - - @Security('apiKey') - @Post('/create-tenant') - public async createTenant( - @Body() createTenantOptions: CreateTenantOptions, - @Res() notFoundError: TsoaResponse<404, { reason: string }>, - @Res() internalServerError: TsoaResponse<500, { message: string }> - ) { - const { config } = createTenantOptions - try { - const tenantRecord: TenantRecord = await this.agent.modules.tenants.createTenant({ config }) - const token = this.getToken(tenantRecord.id) - const withToken = { token, ...tenantRecord} - return tenantRecord - } catch (error) { - if (error instanceof RecordNotFoundError) { - return notFoundError(404, { - reason: `Tenant not created`, - }) - } - - return internalServerError(500, { message: `Something went wrong: ${error}` }) - } - } - - private getTenant(tenantId: string){ - } -} diff --git a/src/routes/routes.ts b/src/routes/routes.ts index 1678c631..738559d6 100644 --- a/src/routes/routes.ts +++ b/src/routes/routes.ts @@ -27,6 +27,8 @@ import { CredentialController } from './../controllers/credentials/CredentialCon // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa import { Polygon } from './../controllers/polygon/PolygonController'; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa +import { MultiTenantController } from './../controllers/additional-endpoint/multitenant.Controller'; +// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa import { QuestionAnswerController } from './../controllers/question-answer/QuestionAnswerController'; import { expressAuthentication } from './../authentication'; // @ts-ignore - no great way to install types from subpackage @@ -3803,6 +3805,40 @@ export function RegisterRoutes(app: Router) { } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + app.post('/test-endpoint/multi-tenant/create-tenant', + authenticateMiddleware([{"NewAuth":[]}]), + ...(fetchMiddlewares(MultiTenantController)), + ...(fetchMiddlewares(MultiTenantController.prototype.createTenant)), + + async function MultiTenantController_createTenant(request: any, response: any, next: any) { + const args = { + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + createTenantOptions: {"in":"body","name":"createTenantOptions","required":true,"ref":"CreateTenantOptions"}, + notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, + internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, + }; + + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + + let validatedArgs: any[] = []; + try { + validatedArgs = getValidatedArgs(args, request, response); + + const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; + + const controller: any = await container.get(MultiTenantController); + if (typeof controller['setStatus'] === 'function') { + controller.setStatus(undefined); + } + + + const promise = controller.createTenant.apply(controller, validatedArgs as any); + promiseHandler(controller, promise, response, undefined, next); + } catch (err) { + return next(err); + } + }); + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.get('/question-answer', authenticateMiddleware([{"apiKey":[]}]), ...(fetchMiddlewares(QuestionAnswerController)), diff --git a/src/routes/swagger.json b/src/routes/swagger.json index 10d8b51d..d8e8b404 100644 --- a/src/routes/swagger.json +++ b/src/routes/swagger.json @@ -1741,6 +1741,11 @@ "type": "apiKey", "name": "Authorization", "in": "header" + }, + "NewAuth": { + "type": "NewAuth", + "name": "Authorization", + "in": "header" } } }, @@ -9112,6 +9117,76 @@ ] } }, + "/test-endpoint/multi-tenant/create-tenant": { + "post": { + "operationId": "CreateTenant", + "responses": { + "200": { + "description": "Ok", + "content": { + "application/json": { + "schema": {} + } + } + }, + "404": { + "description": "", + "content": { + "application/json": { + "schema": { + "properties": { + "reason": { + "type": "string" + } + }, + "required": [ + "reason" + ], + "type": "object" + } + } + } + }, + "500": { + "description": "", + "content": { + "application/json": { + "schema": { + "properties": { + "message": { + "type": "string" + } + }, + "required": [ + "message" + ], + "type": "object" + } + } + } + } + }, + "tags": [ + "Multi Tenant" + ], + "security": [ + { + "NewAuth": [] + } + ], + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateTenantOptions" + } + } + } + } + } + }, "/question-answer": { "get": { "operationId": "GetQuestionAnswerRecords", diff --git a/src/securityMiddleware.ts b/src/securityMiddleware.ts index 24693389..555b90d4 100644 --- a/src/securityMiddleware.ts +++ b/src/securityMiddleware.ts @@ -1,9 +1,9 @@ import type * as express from 'express' import type { NextFunction } from 'express' +// eslint-disable-next-line import/order import { Middlewares } from '@tsoa/runtime' -// eslint-disable-next-line import/namespace import { expressAuthentication } from './authentication' // Import your authentication function @Middlewares() @@ -21,19 +21,26 @@ export class SecurityMiddleware { // Check if authentication should be skipped for this route or controller const skipAuthentication = pathsToSkipAuthentication.some((path) => routePath.includes(path)) - if (routePath.includes('/multi-tenant/')) { - securityName = 'RootAuthorization' + // Krish: here test endpoints will be replaced by all enpoints except 'pathsToSkipAuthentication' + if (routePath.includes('/test-endpoint/')) { + securityName = 'NewAuth' + console.log('Reached in securityMiddleware::::: /test-endpoint/') // const result = await expressAuthentication(request, securityName); } if (skipAuthentication) { // Skip authentication for this route or controller + console.log('Skipped authentication') next() } else if (securityName) { const result = await expressAuthentication(request, securityName) + console.log('This is result in securityMiddleware:::::', result) if (result === 'success') { + console.log('Successfully resulted') next() + } else if (result) { + response.status(401).json({ message: `Unauthorized ${result}` }) } else { response.status(401).json({ message: 'Unauthorized' }) } diff --git a/src/server.ts b/src/server.ts index 46999859..a32bec57 100644 --- a/src/server.ts +++ b/src/server.ts @@ -1,5 +1,7 @@ import 'reflect-metadata' +import type { RestAgentModules, RestMultiTenantAgentModules } from './cliAgent' import type { ServerConfig } from './utils/ServerConfig' +import type { AgentModulesInput } from '@aries-framework/core/build/agent/AgentModules' import type { Response as ExResponse, Request as ExRequest, NextFunction } from 'express' import { Agent } from '@aries-framework/core' @@ -22,9 +24,20 @@ import { SecurityMiddleware } from './securityMiddleware' import { maxRateLimit, windowMs } from './utils/util' import { ValidateError, type Exception } from 'tsoa' - -export const setupServer = async (agent: Agent, config: ServerConfig, apiKey?: string) => { - container.registerInstance(Agent, agent) +// Define conditional type for Agent +// type AgentWithModules = Agent & (RestMultiTenantAgentModules | RestAgentModules) + +// setupServer function +export const setupServer = async ( + agent: Agent, + config: ServerConfig, + apiKey?: string +) => { + // export const setupServer = async (agent: Agent, config: ServerConfig, apiKey?: string) => { + // let NewAgent: RestMultiTenantAgentModules | RestAgentModules + // container.register(NewAgent, newAgent) + container.registerInstance(Agent, agent as Agent) + console.log('Reached here. This is Agent::::', agent) const app = config.app ?? express() if (config.cors) app.use(cors()) diff --git a/src/utils/common.service.ts b/src/utils/common.service.ts new file mode 100644 index 00000000..51a096dd --- /dev/null +++ b/src/utils/common.service.ts @@ -0,0 +1,19 @@ +import { randomBytes } from 'crypto' + +export async function generateSecretKey(length: number = 32): Promise { + // Asynchronously generate a buffer containing random values + const buffer: Buffer = await new Promise((resolve, reject) => { + randomBytes(length, (error, buf) => { + if (error) { + reject(error) + } else { + resolve(buf) + } + }) + }) + + // Convert the buffer to a hexadecimal string + const secretKey: string = buffer.toString('hex') + + return secretKey +} diff --git a/src/utils/util.ts b/src/utils/util.ts index 43b71461..450a58fc 100644 --- a/src/utils/util.ts +++ b/src/utils/util.ts @@ -161,3 +161,8 @@ export const maxRateLimit = 800 export const DID_CONTRACT_ADDRESS = '0x12513116875BB3E4F098Ce74624739Ee51bAf023' export const SCHEMA_MANAGER_CONTRACT_ADDRESS = '0x552992e9f14b15bBd76488cD4c38c89B80259f37' export const RPC_URL = 'https://rpc-mumbai.maticvigil.com' + +export enum RESULT { + SUCCESS = 'SUCCESS', + FAILED = 'FAILED', +} diff --git a/tsoa.json b/tsoa.json index 5a39d549..8ebbac4d 100644 --- a/tsoa.json +++ b/tsoa.json @@ -10,6 +10,11 @@ "type": "apiKey", "name": "Authorization", "in": "header" + }, + "NewAuth": { + "type": "NewAuth", + "name": "Authorization", + "in": "header" } } }, From 545233b9c93e101c9cba87d6b253b8b68a956747 Mon Sep 17 00:00:00 2001 From: Krishna Date: Mon, 1 Apr 2024 20:12:13 +0530 Subject: [PATCH 03/16] add: done test-endpoint Signed-off-by: Krishna --- src/authentication.ts | 31 ++-- ...xt.controller.ts => context.Controller.ts} | 93 ++++++------ .../multitenant.Controller.ts | 2 +- src/routes/routes.ts | 36 ++++- src/routes/swagger.json | 140 +++++++++++++++++- src/securityMiddleware.ts | 2 +- tsoa.json | 8 +- 7 files changed, 242 insertions(+), 70 deletions(-) rename src/controllers/additional-endpoint/{context.controller.ts => context.Controller.ts} (77%) diff --git a/src/authentication.ts b/src/authentication.ts index da206a37..792002d0 100644 --- a/src/authentication.ts +++ b/src/authentication.ts @@ -7,7 +7,7 @@ import type { Request } from 'express' import { Agent, LogLevel } from '@aries-framework/core' import { TenantAgent } from '@aries-framework/tenants/build/TenantAgent' -import jwt from 'jsonwebtoken' +import jwt, { decode } from 'jsonwebtoken' import { container } from 'tsyringe' import { AgentType } from './enums/enum' @@ -65,12 +65,16 @@ export async function expressAuthentication( } } - if (securityName === 'NewAuth') { + if (securityName === 'jwt') { const tenancy = true - const token = apiKeyHeader - const decodedToken: jwt.JwtPayload = jwt.decode(token) as jwt.JwtPayload - const role: AgentType = decodedToken.role + const tokenWithHeader = apiKeyHeader + console.log(`This is tokenWithHeader:::${tokenWithHeader}`) + const token = tokenWithHeader.replace('Bearer ', '') + console.log(`This is token:::${token}`) const reqPath = request.path + console.log(`This is reqPath:::${reqPath}`) + const decodedToken: jwt.JwtPayload = decode(token) as jwt.JwtPayload + const role: AgentType = decodedToken.role // Shound not contain any // const rootAgent = container.resolve(Agent) // Krish: figure out how can we get token from agent's generic records @@ -83,7 +87,7 @@ export async function expressAuthentication( return 'The agent is a multi-tenant agent' } - if (role === AgentType.TenantAgent && decodedToken.tenantId) { + if (role === AgentType.TenantAgent) { // Logic if the token is of tenant agent console.log('Middleware: Authentication: TenantAgent. The token is::', token) if (reqPath.includes('/multi-tenant/')) { @@ -91,16 +95,18 @@ export async function expressAuthentication( } else { // verify tenant agent const tenantId: string = decodedToken.tenantId - const tenantAgent = await rootAgent.modules.tenants.getTenantAgent({ - tenantId, - }) - const tenantAgent1: TenantAgent = await getTenantAgent(rootAgent, tenantId) - console.log('Log from console, tenantAgent1::::', tenantAgent1) - console.log('Log from console, tenantAgent::::', tenantAgent) + // const tenantAgent = await rootAgent.modules.tenants.getTenantAgent({ + // tenantId, + // }) + const tenantAgent: TenantAgent = await getTenantAgent(rootAgent, tenantId) + // console.log('Log from console, tenantAgent1::::', tenantAgent1) + // console.log('Log from console, tenantAgent::::', tenantAgent) if (!tenantAgent) return const secretKey = await getSecretKey(tenantAgent) + console.log('This is the secretkey for tenantAgent:::::', secretKey) const verified = jwt.verify(token, secretKey) + console.log('This is the verified for tenantAgent:::::', verified) // Failed to verify token if (!verified) return @@ -108,6 +114,7 @@ export async function expressAuthentication( // Only need to registerInstance for TenantAgent. // As Instance of RootAgent with and without tenant will already be registered while starting the server container.registerInstance(TenantAgent, tenantAgent) + return 'success' } } else if (role === AgentType.AgentWithTenant) { // Logic for base wallet verification diff --git a/src/controllers/additional-endpoint/context.controller.ts b/src/controllers/additional-endpoint/context.Controller.ts similarity index 77% rename from src/controllers/additional-endpoint/context.controller.ts rename to src/controllers/additional-endpoint/context.Controller.ts index e633a2c9..cf254aaf 100644 --- a/src/controllers/additional-endpoint/context.controller.ts +++ b/src/controllers/additional-endpoint/context.Controller.ts @@ -48,16 +48,17 @@ import { Security, } from 'tsoa' -@Tags('Out Of Band') +@Tags('Test Connection') // @Security('authorization') -@Route('/testEndpoint') +@Security('jwt') +@Route('/test-endpoint') @injectable() export class ContextController extends Controller { // private agent: Agent - // public constructor(agent: Agent) { - // super() - // this.agent = agent - // } + public constructor(private readonly agent: Agent) { + super() + this.agent = agent + } // @Get('/get-token') // public async getAgentToken(): Promise { // const agentDetails = await this.agent.genericRecords.getAll() @@ -162,44 +163,44 @@ export class ContextController extends Controller { * @param config configuration of how a invitation should be created * @returns out-of-band record and invitation */ - // @Example<{ invitation: OutOfBandInvitationProps; outOfBandRecord: OutOfBandRecordWithInvitationProps }>({ - // invitation: outOfBandInvitationExample, - // outOfBandRecord: outOfBandRecordExample, - // }) - // @Post('/create-legacy-invitation') - // public async createLegacyInvitation( - // @Res() internalServerError: TsoaResponse<500, { message: string }>, - // @Body() config?: Omit & RecipientKeyOption - // ) { - // try { - // let routing: Routing - // if (config?.recipientKey) { - // routing = { - // endpoints: this.agent.config.endpoints, - // routingKeys: [], - // recipientKey: Key.fromPublicKeyBase58(config.recipientKey, KeyType.Ed25519), - // mediatorId: undefined, - // } - // } else { - // routing = await this.agent.mediationRecipient.getRouting({}) - // } - // const { outOfBandRecord, invitation } = await this.agent.oob.createLegacyInvitation({ - // ...config, - // routing, - // }) - // return { - // invitationUrl: invitation.toUrl({ - // domain: this.agent.config.endpoints[0], - // useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, - // }), - // invitation: invitation.toJSON({ - // useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, - // }), - // outOfBandRecord: outOfBandRecord.toJSON(), - // ...(config?.recipientKey ? {} : { recipientKey: routing.recipientKey.publicKeyBase58 }), - // } - // } catch (error) { - // return internalServerError(500, { message: `something went wrong: ${error}` }) - // } - // } + @Example<{ invitation: OutOfBandInvitationProps; outOfBandRecord: OutOfBandRecordWithInvitationProps }>({ + invitation: outOfBandInvitationExample, + outOfBandRecord: outOfBandRecordExample, + }) + @Post('/create-legacy-invitation') + public async createLegacyInvitation( + @Res() internalServerError: TsoaResponse<500, { message: string }>, + @Body() config?: Omit & RecipientKeyOption + ) { + try { + let routing: Routing + if (config?.recipientKey) { + routing = { + endpoints: this.agent.config.endpoints, + routingKeys: [], + recipientKey: Key.fromPublicKeyBase58(config.recipientKey, KeyType.Ed25519), + mediatorId: undefined, + } + } else { + routing = await this.agent.mediationRecipient.getRouting({}) + } + const { outOfBandRecord, invitation } = await this.agent.oob.createLegacyInvitation({ + ...config, + routing, + }) + return { + invitationUrl: invitation.toUrl({ + domain: this.agent.config.endpoints[0], + useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, + }), + invitation: invitation.toJSON({ + useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, + }), + outOfBandRecord: outOfBandRecord.toJSON(), + ...(config?.recipientKey ? {} : { recipientKey: routing.recipientKey.publicKeyBase58 }), + } + } catch (error) { + return internalServerError(500, { message: `something went wrong: ${error}` }) + } + } } diff --git a/src/controllers/additional-endpoint/multitenant.Controller.ts b/src/controllers/additional-endpoint/multitenant.Controller.ts index 77f61ae6..bf2b8e0d 100644 --- a/src/controllers/additional-endpoint/multitenant.Controller.ts +++ b/src/controllers/additional-endpoint/multitenant.Controller.ts @@ -28,7 +28,7 @@ export class MultiTenantController extends Controller { } // @Security('RootAuthorization') - @Security('NewAuth') + @Security('jwt') @Post('/create-tenant') public async createTenant( @Request() request: RequestWithRootTenantAgent, diff --git a/src/routes/routes.ts b/src/routes/routes.ts index 738559d6..a66158fe 100644 --- a/src/routes/routes.ts +++ b/src/routes/routes.ts @@ -29,6 +29,8 @@ import { Polygon } from './../controllers/polygon/PolygonController'; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa import { MultiTenantController } from './../controllers/additional-endpoint/multitenant.Controller'; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa +import { ContextController } from './../controllers/additional-endpoint/context.Controller'; +// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa import { QuestionAnswerController } from './../controllers/question-answer/QuestionAnswerController'; import { expressAuthentication } from './../authentication'; // @ts-ignore - no great way to install types from subpackage @@ -3806,7 +3808,7 @@ export function RegisterRoutes(app: Router) { }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.post('/test-endpoint/multi-tenant/create-tenant', - authenticateMiddleware([{"NewAuth":[]}]), + authenticateMiddleware([{"jwt":[]}]), ...(fetchMiddlewares(MultiTenantController)), ...(fetchMiddlewares(MultiTenantController.prototype.createTenant)), @@ -3839,6 +3841,38 @@ export function RegisterRoutes(app: Router) { } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + app.post('/test-endpoint/create-legacy-invitation', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(ContextController)), + ...(fetchMiddlewares(ContextController.prototype.createLegacyInvitation)), + + async function ContextController_createLegacyInvitation(request: any, response: any, next: any) { + const args = { + internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, + config: {"in":"body","name":"config","dataType":"intersection","subSchemas":[{"ref":"Omit_CreateLegacyInvitationConfig.routing_"},{"ref":"RecipientKeyOption"}]}, + }; + + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + + let validatedArgs: any[] = []; + try { + validatedArgs = getValidatedArgs(args, request, response); + + const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; + + const controller: any = await container.get(ContextController); + if (typeof controller['setStatus'] === 'function') { + controller.setStatus(undefined); + } + + + const promise = controller.createLegacyInvitation.apply(controller, validatedArgs as any); + promiseHandler(controller, promise, response, undefined, next); + } catch (err) { + return next(err); + } + }); + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.get('/question-answer', authenticateMiddleware([{"apiKey":[]}]), ...(fetchMiddlewares(QuestionAnswerController)), diff --git a/src/routes/swagger.json b/src/routes/swagger.json index d8e8b404..c0f5782a 100644 --- a/src/routes/swagger.json +++ b/src/routes/swagger.json @@ -1742,10 +1742,10 @@ "name": "Authorization", "in": "header" }, - "NewAuth": { - "type": "NewAuth", - "name": "Authorization", - "in": "header" + "jwt": { + "type": "http", + "scheme": "bearer", + "bearerFormat": "JWT" } } }, @@ -9171,7 +9171,7 @@ ], "security": [ { - "NewAuth": [] + "jwt": [] } ], "parameters": [], @@ -9187,6 +9187,136 @@ } } }, + "/test-endpoint/create-legacy-invitation": { + "post": { + "operationId": "CreateLegacyInvitation", + "responses": { + "200": { + "description": "out-of-band record and invitation", + "content": { + "application/json": { + "schema": {}, + "examples": { + "Example 1": { + "value": { + "invitation": { + "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.1/invitation", + "@id": "d6472943-e5d0-4d95-8b48-790ed5a41931", + "label": "Aries Test Agent", + "accept": [ + "didcomm/aip1", + "didcomm/aip2;env=rfc19" + ], + "handshake_protocols": [ + "https://didcomm.org/didexchange/1.0", + "https://didcomm.org/connections/1.0" + ], + "services": [ + { + "id": "#inline-0", + "serviceEndpoint": "https://6b77-89-20-162-146.ngrok.io", + "type": "did-communication", + "recipientKeys": [ + "did:key:z6MkmTBHTWrvLPN8pBmUj7Ye5ww9GiacXCYMNVvpScSpf1DM" + ], + "routingKeys": [] + } + ] + }, + "outOfBandRecord": { + "_tags": { + "invitationId": "1cbd22e4-1906-41e9-8807-83d84437f978", + "state": "await-response", + "role": "sender", + "recipientKeyFingerprints": [ + "z6MktUCPZjfRJXD4GMcYuXiqX2qZ8vBw6UAYpDFiHEUfwuLj" + ] + }, + "outOfBandInvitation": { + "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.1/invitation", + "@id": "d6472943-e5d0-4d95-8b48-790ed5a41931", + "label": "Aries Test Agent", + "accept": [ + "didcomm/aip1", + "didcomm/aip2;env=rfc19" + ], + "handshake_protocols": [ + "https://didcomm.org/didexchange/1.0", + "https://didcomm.org/connections/1.0" + ], + "services": [ + { + "id": "#inline-0", + "serviceEndpoint": "https://6b77-89-20-162-146.ngrok.io", + "type": "did-communication", + "recipientKeys": [ + "did:key:z6MkmTBHTWrvLPN8pBmUj7Ye5ww9GiacXCYMNVvpScSpf1DM" + ], + "routingKeys": [] + } + ] + }, + "metadata": {}, + "id": "42a95528-0e30-4f86-a462-0efb02178b53", + "createdAt": "2022-01-01T00:00:00.000Z", + "reusable": false + } + } + } + } + } + } + }, + "500": { + "description": "", + "content": { + "application/json": { + "schema": { + "properties": { + "message": { + "type": "string" + } + }, + "required": [ + "message" + ], + "type": "object" + } + } + } + } + }, + "description": "Creates an outbound out-of-band record in the same way how `createInvitation` method does it,\nbut it also converts out-of-band invitation message to an \"legacy\" invitation message defined\nin RFC 0160: Connection Protocol and returns it together with out-of-band record.", + "tags": [ + "Test Connection" + ], + "security": [ + { + "jwt": [] + } + ], + "parameters": [], + "requestBody": { + "description": "configuration of how a invitation should be created", + "required": false, + "content": { + "application/json": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/Omit_CreateLegacyInvitationConfig.routing_" + }, + { + "$ref": "#/components/schemas/RecipientKeyOption" + } + ], + "description": "configuration of how a invitation should be created" + } + } + } + } + } + }, "/question-answer": { "get": { "operationId": "GetQuestionAnswerRecords", diff --git a/src/securityMiddleware.ts b/src/securityMiddleware.ts index 555b90d4..70640706 100644 --- a/src/securityMiddleware.ts +++ b/src/securityMiddleware.ts @@ -23,7 +23,7 @@ export class SecurityMiddleware { // Krish: here test endpoints will be replaced by all enpoints except 'pathsToSkipAuthentication' if (routePath.includes('/test-endpoint/')) { - securityName = 'NewAuth' + securityName = 'jwt' console.log('Reached in securityMiddleware::::: /test-endpoint/') // const result = await expressAuthentication(request, securityName); } diff --git a/tsoa.json b/tsoa.json index 8ebbac4d..2a7a56b2 100644 --- a/tsoa.json +++ b/tsoa.json @@ -11,10 +11,10 @@ "name": "Authorization", "in": "header" }, - "NewAuth": { - "type": "NewAuth", - "name": "Authorization", - "in": "header" + "jwt": { + "type": "http", + "scheme": "bearer", + "bearerFormat": "JWT" } } }, From fd2000d353d0668ba359ddc5e225c0b56dcee267 Mon Sep 17 00:00:00 2001 From: Krishna Date: Mon, 8 Apr 2024 16:57:32 +0530 Subject: [PATCH 04/16] add: token enhancement Signed-off-by: Krishna --- samples/cliConfig.json | 4 +- src/authentication.ts | 142 +++++++----------- src/cliAgent.ts | 19 +-- .../additional-endpoint/context.Controller.ts | 60 ++++++-- .../multitenant.Controller.ts | 43 +++--- src/controllers/agent/AgentController.ts | 20 ++- src/controllers/types.ts | 5 +- src/enums/enum.ts | 8 +- src/server.ts | 6 +- tsoa.json | 2 +- 10 files changed, 167 insertions(+), 142 deletions(-) diff --git a/samples/cliConfig.json b/samples/cliConfig.json index 7e87ff4a..e46876b1 100644 --- a/samples/cliConfig.json +++ b/samples/cliConfig.json @@ -1,6 +1,6 @@ { - "label": "AFJ Rest Agent 1", - "walletId": "sample1", + "label": "Credo Rest Agent", + "walletId": "sharedAgent", "walletKey": "sample", "walletType": "postgres", "walletUrl": "localhost:5432", diff --git a/src/authentication.ts b/src/authentication.ts index 792002d0..1d8e3eec 100644 --- a/src/authentication.ts +++ b/src/authentication.ts @@ -1,18 +1,21 @@ import type { RestAgentModules, RestMultiTenantAgentModules } from './cliAgent' -import type * as express from 'express' - -// import { Agent } from '@aries-framework/core' -// eslint-disable-next-line import/namespace +import type { TenantAgent } from '@aries-framework/tenants/build/TenantAgent' import type { Request } from 'express' import { Agent, LogLevel } from '@aries-framework/core' -import { TenantAgent } from '@aries-framework/tenants/build/TenantAgent' import jwt, { decode } from 'jsonwebtoken' import { container } from 'tsyringe' -import { AgentType } from './enums/enum' +import { AgentRole } from './enums/enum' import { TsLogger } from './utils/logger' +export type AgentType = Agent | Agent | TenantAgent +// export type RequestWithAgent = Request & { +// name: string +// user: { +// agent: TenantAgent | Agent | Agent +// } +// } export type RequestWithAgent = RequestWithRootAgent | RequestWithTenantAgent | RequestWithRootTenantAgent export type RequestWithTenantAgent = Request & { @@ -36,13 +39,16 @@ export type RequestWithRootTenantAgent = Request & { let dynamicApiKey: string = 'api_key' // Initialize with a default value export async function expressAuthentication( - request: express.Request, + request: Request, securityName: string, secMethod?: { [key: string]: any }, scopes?: string -) { +): Promise { + // ): Promise | Agent | TenantAgent> { try { const logger = new TsLogger(LogLevel.info) + const req = request as RequestWithAgent + const agent = container.resolve(Agent) logger.info(`secMethod::: ${JSON.stringify(secMethod)}`) logger.info(`scopes::: ${JSON.stringify(scopes)}`) @@ -60,135 +66,97 @@ export async function expressAuthentication( const providedApiKey = apiKeyHeader as string if (providedApiKey === dynamicApiKey) { - return 'success' + return agent } } } if (securityName === 'jwt') { - const tenancy = true + const tenancy = agent.modules.tenants ? true : false const tokenWithHeader = apiKeyHeader - console.log(`This is tokenWithHeader:::${tokenWithHeader}`) const token = tokenWithHeader.replace('Bearer ', '') - console.log(`This is token:::${token}`) const reqPath = request.path - console.log(`This is reqPath:::${reqPath}`) const decodedToken: jwt.JwtPayload = decode(token) as jwt.JwtPayload - const role: AgentType = decodedToken.role - // Shound not contain any - // const rootAgent = container.resolve(Agent) - // Krish: figure out how can we get token from agent's generic records - // const secretKey = this.agent + const role: AgentRole = decodedToken.role if (tenancy) { - const rootAgent = container.resolve(Agent) + // const rootAgent = container.resolve(Agent) // it should be a shared agent - if (role !== AgentType.AgentWithTenant && role !== AgentType.TenantAgent) { - return 'The agent is a multi-tenant agent' + if (role !== AgentRole.RestRootAgentWithTenants && role !== AgentRole.TenantAgent) { + return false //'The agent is a multi-tenant agent' } - if (role === AgentType.TenantAgent) { + if (role === AgentRole.TenantAgent) { // Logic if the token is of tenant agent - console.log('Middleware: Authentication: TenantAgent. The token is::', token) if (reqPath.includes('/multi-tenant/')) { - return `Tenants can't manage tenants` + return false //'Tenants cannot manage tenants' } else { // verify tenant agent const tenantId: string = decodedToken.tenantId - // const tenantAgent = await rootAgent.modules.tenants.getTenantAgent({ - // tenantId, - // }) - const tenantAgent: TenantAgent = await getTenantAgent(rootAgent, tenantId) - // console.log('Log from console, tenantAgent1::::', tenantAgent1) - // console.log('Log from console, tenantAgent::::', tenantAgent) - if (!tenantAgent) return - - const secretKey = await getSecretKey(tenantAgent) - console.log('This is the secretkey for tenantAgent:::::', secretKey) - const verified = jwt.verify(token, secretKey) - console.log('This is the verified for tenantAgent:::::', verified) + if (!tenantId) return false + const tenantAgent = await getTenantAgent(agent, tenantId) + if (!tenantAgent) return false + + const verified = await verifyToken(tenantAgent, token) // Failed to verify token - if (!verified) return + if (!verified) return false // Only need to registerInstance for TenantAgent. - // As Instance of RootAgent with and without tenant will already be registered while starting the server - container.registerInstance(TenantAgent, tenantAgent) - return 'success' + req['user'] = { agent: tenantAgent } + // return { req } + return tenantAgent } - } else if (role === AgentType.AgentWithTenant) { + } else if (role === AgentRole.RestRootAgentWithTenants) { // Logic for base wallet verification - const verified = await verifyToken(rootAgent, token) + const verified = await verifyToken(agent, token) - console.log('Middleware: Authentication: Basewallet. The token is::', token) - console.log('The verified is::', verified) - if (!verified) return + // Base wallet cant access any endpoints apart from multi-tenant endpoint + // if (!reqPath.includes('/multi-tenant/') && !reqPath.includes('/multi-tenancy/')) + // return 'Basewallet can only manage tenants and can`t perform other operations' + if (!verified) return false - return 'success' + // req['user'] = {agent} + req['user'] = { agent: agent } + // return { req } + return agent } else { - return 'Invalid Token' + return false //'Invalid Token' } } else { - const rootAgent = container.resolve(Agent) - // it should be a dedicated agent - if (role !== AgentType.AgentWithoutTenant) { - return 'This is a dedicated agent' + if (role !== AgentRole.RestRootAgent) { + return false //'This is a dedicated agent' } else { - // It has a role of dedicated agent - // Verify dedicated agent - const verified = await verifyToken(rootAgent, token) + // It has a role of dedicated agent, verify - console.log('Reached here. The token is::', token) - console.log('The verified is::', verified) - if (!verified) return + if (reqPath.includes('/multi-tenant/')) return false + + const verified = await verifyToken(agent, token) + if (!verified) return false // Can have an enum instead of 'success' string - // return RESULT.SUCCESS - return 'success' + // req['user'] = { agent: agent } + // return { req } + return agent } } - - // if (role === AgentType.AgentWithoutTenant) { - // if (tenancy === true) { - // return false - // } - // } - - // if (role === AgentType.AgentWithTenant) { - // if (tenancy === false) { - // return false - // } - // else { - // // eslint-disable-next-line @typescript-eslint/no-unused-vars - // const agent: Agent - // const genericRecord = await agent.genericRecords.getAll() - // const recordWithToken = genericRecord.find((record) => record?.content?.token !== undefined) - // token = recordWithToken?.content.token as string - // return 'success' - // } - // } - - // const verified = jwt.verify(token, ) } + return false } catch (error) { const logger = new TsLogger(LogLevel.error) if (error instanceof Error) { logger.error('Error in Authentication', error) } + return false } } -async function verifyToken(agent: Agent, token: string): Promise { +async function verifyToken(agent: Agent | TenantAgent, token: string): Promise { // try { const secretKey = await getSecretKey(agent) const verified = jwt.verify(token, secretKey) return verified ? true : false - // } catch (error) { - // if (error instanceof Error) { - // logger.error('Token Invalid') - // } - // } } // Common function to pass agent object and get secretKey diff --git a/src/cliAgent.ts b/src/cliAgent.ts index 8d501af5..ea261f44 100644 --- a/src/cliAgent.ts +++ b/src/cliAgent.ts @@ -50,13 +50,10 @@ import { ariesAskar } from '@hyperledger/aries-askar-nodejs' import { indyVdr } from '@hyperledger/indy-vdr-nodejs' import axios from 'axios' import { readFile } from 'fs/promises' -// eslint-disable-next-line import/order import jwt from 'jsonwebtoken' -// eslint-disable-next-line @typescript-eslint/no-unused-vars -import { container } from 'tsyringe' - -import { AgentType } from './enums/enum' +import { AgentRole } from './enums/enum' +// eslint-disable-next-line import/no-cycle import { setupServer } from './server' import { generateSecretKey } from './utils/common.service' import { TsLogger } from './utils/logger' @@ -119,10 +116,10 @@ export type RestMultiTenantAgentModules = Awaited> // export type RestMultiTenantAgentModules = Awaited> -// type AgentWithTenantModules = Awaited> -// type AgentWithoutTenantModules = Awaited> -// export type RestMultiTenantAgentModules = Agent -// export type RestAgentModules = Agent +// type RestRootAgentWithTenantsModules = Awaited> +// type RestRootAgentModules = Awaited> +// export type RestMultiTenantAgentModules = Agent +// export type RestAgentModules = Agent const getModules = (networkConfig: [IndyVdrPoolConfig, ...IndyVdrPoolConfig[]]) => { const legacyIndyCredentialFormat = new LegacyIndyCredentialFormatService() @@ -368,9 +365,9 @@ export async function runRestAgent(restConfig: AriesRestConfig) { // agent role set for dedicated agent and base-wallet respectively if (!('tenants' in agent.modules)) { - token = jwt.sign({ role: AgentType.AgentWithoutTenant }, secretKeyInfo) + token = jwt.sign({ role: AgentRole.RestRootAgent }, secretKeyInfo) } else { - token = jwt.sign({ role: AgentType.AgentWithTenant }, secretKeyInfo) + token = jwt.sign({ role: AgentRole.RestRootAgentWithTenants }, secretKeyInfo) } // Krish: there should be no need to store the token if it is a refresh token. It's okay to save it for now and return it in the additional endpoint diff --git a/src/controllers/additional-endpoint/context.Controller.ts b/src/controllers/additional-endpoint/context.Controller.ts index cf254aaf..65a09f3d 100644 --- a/src/controllers/additional-endpoint/context.Controller.ts +++ b/src/controllers/additional-endpoint/context.Controller.ts @@ -1,24 +1,17 @@ -/* eslint-disable @typescript-eslint/no-unused-vars */ -// import type { OutOfBandInvitationProps, OutOfBandRecordWithInvitationProps } from '../examples' import type { OutOfBandInvitationProps, OutOfBandRecordWithInvitationProps } from '../examples' // eslint-disable-next-line import/order import type { RecipientKeyOption } from '../types' // AgentMessageType, // import type { ConnectionRecordProps, CreateLegacyInvitationConfig, Routing } from '@aries-framework/core' -import type { CreateLegacyInvitationConfig, Routing } from '@aries-framework/core' -// eslint-disable-next-line @typescript-eslint/no-unused-vars -import type { GenericRecord } from '@aries-framework/core/build/modules/generic-records/repository/GenericRecord' +import type { ConnectionRecordProps, CreateLegacyInvitationConfig, Routing } from '@aries-framework/core' import { - // AgentMessage, - // JsonTransformer, - // OutOfBandInvitation, - Agent, Key, KeyType, // RecordNotFoundError, // Key, // KeyType, + Agent, } from '@aries-framework/core' import { injectable } from 'tsyringe' @@ -30,15 +23,15 @@ import { injectable } from 'tsyringe' // CreateInvitationOptions, // } from '../types' -import { outOfBandInvitationExample, outOfBandRecordExample } from '../examples' +import { RequestWithAgent } from '../../authentication' +import { ConnectionRecordExample, outOfBandInvitationExample, outOfBandRecordExample } from '../examples' +import { ReceiveInvitationByUrlProps } from '../types' import { Body, Controller, // Delete, Example, - Get, - Path, Post, // Query, Res, @@ -46,6 +39,7 @@ import { Tags, TsoaResponse, Security, + Request, } from 'tsoa' @Tags('Test Connection') @@ -169,10 +163,13 @@ export class ContextController extends Controller { }) @Post('/create-legacy-invitation') public async createLegacyInvitation( + // Request implementation + // @Request() request: RequestWithAgent, @Res() internalServerError: TsoaResponse<500, { message: string }>, @Body() config?: Omit & RecipientKeyOption ) { try { + // console.log('this is request::::::::::', JSON.stringify(request)) let routing: Routing if (config?.recipientKey) { routing = { @@ -203,4 +200,43 @@ export class ContextController extends Controller { return internalServerError(500, { message: `something went wrong: ${error}` }) } } + + /** + * Creates inbound out-of-band record and assigns out-of-band invitation message to it if the + * message is valid. + * + * @param invitationUrl invitation url + * @param config config for handling of invitation + * @returns out-of-band record and connection record if one has been created. + */ + @Example<{ outOfBandRecord: OutOfBandRecordWithInvitationProps; connectionRecord: ConnectionRecordProps }>({ + outOfBandRecord: outOfBandRecordExample, + connectionRecord: ConnectionRecordExample, + }) + @Post('/receive-invitation-url') + public async receiveInvitationFromUrl( + // Request implementation + @Request() request: RequestWithAgent, + @Body() invitationRequest: ReceiveInvitationByUrlProps, + @Res() internalServerError: TsoaResponse<500, { message: string }> + ) { + const { invitationUrl, ...config } = invitationRequest + + try { + const linkSecretIds = await request.user.agent.modules.anoncreds.getLinkSecretIds() + if (linkSecretIds.length === 0) { + await request.user.agent.modules.anoncreds.createLinkSecret() + } + const { outOfBandRecord, connectionRecord } = await request.user.agent.oob.receiveInvitationFromUrl( + invitationUrl, + config + ) + return { + outOfBandRecord: outOfBandRecord.toJSON(), + connectionRecord: connectionRecord?.toJSON(), + } + } catch (error) { + return internalServerError(500, { message: `something went wrong: ${error}` }) + } + } } diff --git a/src/controllers/additional-endpoint/multitenant.Controller.ts b/src/controllers/additional-endpoint/multitenant.Controller.ts index bf2b8e0d..a98623bd 100644 --- a/src/controllers/additional-endpoint/multitenant.Controller.ts +++ b/src/controllers/additional-endpoint/multitenant.Controller.ts @@ -1,20 +1,20 @@ import type { RestMultiTenantAgentModules } from '../../cliAgent' +import type { Agent } from '@aries-framework/core' import type { TenantRecord } from '@aries-framework/tenants' -// eslint-disable-next-line import/order -import { Agent, RecordNotFoundError, injectable } from '@aries-framework/core' - +import { RecordNotFoundError, injectable } from '@aries-framework/core' import jwt from 'jsonwebtoken' import { RequestWithRootTenantAgent } from '../../authentication' -import { AgentType } from '../../enums/enum' +import { AgentRole } from '../../enums/enum' import { generateSecretKey } from '../../utils/common.service' import { CreateTenantOptions } from '../types' -// import { AgentType } from 'src/enums/enum' +// import { AgentRole } from 'src/enums/enum' import { Body, Controller, Post, Request, Res, Route, Security, Tags, TsoaResponse } from 'tsoa' @Tags('Multi Tenant') +@Security('jwt') @Route('/test-endpoint/multi-tenant') // @Security('NewAuth') @injectable() @@ -22,13 +22,12 @@ export class MultiTenantController extends Controller { // private readonly agent: Agent // Krish: can simply add 'private readonly' in constructor - public constructor(private readonly agent: Agent) { - super() - this.agent = agent - } + // public constructor(private readonly agent: Agent) { + // super() + // this.agent = agent + // } // @Security('RootAuthorization') - @Security('jwt') @Post('/create-tenant') public async createTenant( @Request() request: RequestWithRootTenantAgent, @@ -38,8 +37,9 @@ export class MultiTenantController extends Controller { ) { const { config } = createTenantOptions try { - const tenantRecord: TenantRecord = await this.agent.modules.tenants.createTenant({ config }) - const token = await this.getToken(tenantRecord.id) + console.log('reached in create tenant') + const tenantRecord: TenantRecord = await request.user.agent.modules.tenants.createTenant({ config }) + const token = await this.getToken(request.user.agent, tenantRecord.id) const withToken = { token, ...tenantRecord } return withToken return 'success' @@ -54,19 +54,24 @@ export class MultiTenantController extends Controller { } } - private async createToken(tenantId: string) { + private async createToken(agent: Agent, tenantId: string) { const secretKey = await generateSecretKey() // const genericRecord = await this.agent.genericRecords.getAll() // const records = genericRecord.find((record) => record?.content?.secretKey !== undefined) // const secretKey = records?.content.secretKey as string - const token = jwt.sign({ role: AgentType.TenantAgent, tenantId }, secretKey) + const token = jwt.sign({ role: AgentRole.TenantAgent, tenantId }, secretKey) // Save token to individual tenants generic records - await this.saveTokenAndSecretKey(token, secretKey, tenantId) + await this.saveTokenAndSecretKey(agent, token, secretKey, tenantId) return token } - private async saveTokenAndSecretKey(token: string, secretKey: string, tenantId: string) { - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + private async saveTokenAndSecretKey( + agent: Agent, + token: string, + secretKey: string, + tenantId: string + ) { + await agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { tenantAgent.genericRecords.save({ content: { secretKey: secretKey, @@ -75,8 +80,8 @@ export class MultiTenantController extends Controller { }) } - private async getToken(tenantId: string) { - const token: string = await this.createToken(tenantId) + private async getToken(agent: Agent, tenantId: string) { + const token: string = await this.createToken(agent, tenantId) return token } } diff --git a/src/controllers/agent/AgentController.ts b/src/controllers/agent/AgentController.ts index 0ce8c96a..fdce5d11 100644 --- a/src/controllers/agent/AgentController.ts +++ b/src/controllers/agent/AgentController.ts @@ -1,4 +1,4 @@ -import type { AgentInfo } from '../types' +import type { AgentInfo, AgentToken } from '../types' import { Agent } from '@aries-framework/core' import { injectable } from 'tsyringe' @@ -19,11 +19,12 @@ export class AgentController extends Controller { /** * Retrieve basic agent information */ - @Get('/') + @Get('/info') public async getAgentInfo(): Promise { // const details = await this.agent.genericRecords.getAll() const genericRecord = await this.agent.genericRecords.getAll() const recordWithToken = genericRecord.find((record) => record?.content?.token !== undefined) + // eslint-disable-next-line @typescript-eslint/no-unused-vars const token = recordWithToken?.content.token as string return { label: this.agent.config.label, @@ -31,6 +32,21 @@ export class AgentController extends Controller { isInitialized: this.agent.isInitialized, publicDid: undefined, // token: details[0].content.token, + // token: token, + } + } + + /** + * Retrieve agent token + */ + @Get('/token') + @Security('apiKey') + public async getAgentToken(): Promise { + // const details = await this.agent.genericRecords.getAll() + const genericRecord = await this.agent.genericRecords.getAll() + const recordWithToken = genericRecord.find((record) => record?.content?.token !== undefined) + const token = recordWithToken?.content.token as string + return { token: token, } } diff --git a/src/controllers/types.ts b/src/controllers/types.ts index 929f0740..b43cf4ab 100644 --- a/src/controllers/types.ts +++ b/src/controllers/types.ts @@ -44,13 +44,16 @@ export interface AgentInfo { endpoints: string[] isInitialized: boolean publicDid: void - token: any // publicDid?: { // did: string // verkey: string // } } +export interface AgentToken { + token: string +} + export interface AgentMessageType { '@id': string '@type': string diff --git a/src/enums/enum.ts b/src/enums/enum.ts index 9e0bbcd9..8672c946 100644 --- a/src/enums/enum.ts +++ b/src/enums/enum.ts @@ -22,8 +22,8 @@ export enum Network { Indicio_Mainnet = 'indicio:mainnet', } -export enum AgentType { - AgentWithTenant = 'AgentWithTenant', - AgentWithoutTenant = 'AgentWithoutTenant', - TenantAgent = 'TenantAgent', +export enum AgentRole { + RestRootAgentWithTenants = 'RestRootAgentWithTenants', // Basewallet // Better name: RestRootRestRootAgentWithTenantss + RestRootAgent = 'RestRootAgent', // Dedicated // Better name: RestRootAgent + TenantAgent = 'TenantAgent', // Tenant // Better name: RestTenantAgent } diff --git a/src/server.ts b/src/server.ts index a32bec57..10c95f99 100644 --- a/src/server.ts +++ b/src/server.ts @@ -1,8 +1,7 @@ import 'reflect-metadata' import type { RestAgentModules, RestMultiTenantAgentModules } from './cliAgent' import type { ServerConfig } from './utils/ServerConfig' -import type { AgentModulesInput } from '@aries-framework/core/build/agent/AgentModules' -import type { Response as ExResponse, Request as ExRequest, NextFunction } from 'express' +import type { Response as ExResponse, Request as ExRequest, NextFunction, Request, Response } from 'express' import { Agent } from '@aries-framework/core' import bodyParser from 'body-parser' @@ -13,13 +12,14 @@ import { serve, generateHTML } from 'swagger-ui-express' import { container } from 'tsyringe' // eslint-disable-next-line import/namespace -import { setDynamicApiKey } from './authentication' +import { RequestWithAgent, setDynamicApiKey } from './authentication' import { basicMessageEvents } from './events/BasicMessageEvents' import { connectionEvents } from './events/ConnectionEvents' import { credentialEvents } from './events/CredentialEvents' import { proofEvents } from './events/ProofEvents' import { questionAnswerEvents } from './events/QuestionAnswerEvents' import { RegisterRoutes } from './routes/routes' +// eslint-disable-next-line import/no-cycle import { SecurityMiddleware } from './securityMiddleware' import { maxRateLimit, windowMs } from './utils/util' diff --git a/tsoa.json b/tsoa.json index 2a7a56b2..92e95bd7 100644 --- a/tsoa.json +++ b/tsoa.json @@ -19,7 +19,7 @@ } }, "routes": { - "routesDir": "src/routes", + "routesDir": "./src/routes", "iocModule": "./src/utils/tsyringeTsoaIocContainer", "authenticationModule": "src/authentication" } From 2a708044f91daa6fbb7ccf9bc727324fd0958b4f Mon Sep 17 00:00:00 2001 From: Krishna Date: Wed, 10 Apr 2024 18:46:40 +0530 Subject: [PATCH 05/16] add request based context passing Signed-off-by: Krishna --- src/authentication.ts | 50 +-- .../additional-endpoint/context.Controller.ts | 69 +++- .../multitenant.Controller.ts | 15 +- src/controllers/agent/AgentController.ts | 22 +- src/error/ApiError.ts | 4 + src/error/StatusException.ts | 8 + src/error/index.ts | 2 + src/routes/routes.ts | 141 +++++++- src/routes/swagger.json | 337 +++++++++++++++++- src/securityMiddleware.ts | 97 +++-- src/types/request.d.ts | 38 ++ tsconfig.json | 7 +- 12 files changed, 700 insertions(+), 90 deletions(-) create mode 100644 src/error/ApiError.ts create mode 100644 src/error/StatusException.ts create mode 100644 src/error/index.ts create mode 100644 src/types/request.d.ts diff --git a/src/authentication.ts b/src/authentication.ts index 1d8e3eec..15e09d06 100644 --- a/src/authentication.ts +++ b/src/authentication.ts @@ -10,31 +10,31 @@ import { AgentRole } from './enums/enum' import { TsLogger } from './utils/logger' export type AgentType = Agent | Agent | TenantAgent -// export type RequestWithAgent = Request & { -// name: string -// user: { -// agent: TenantAgent | Agent | Agent -// } -// } -export type RequestWithAgent = RequestWithRootAgent | RequestWithTenantAgent | RequestWithRootTenantAgent - -export type RequestWithTenantAgent = Request & { +export type RequestWithAgent = Request & { + name: string user: { - agent: TenantAgent + agent: TenantAgent | Agent | Agent } } +// export type RequestWithAgent = RequestWithRootAgent | RequestWithTenantAgent | RequestWithRootTenantAgent -export type RequestWithRootAgent = Request & { - user: { - agent: Agent - } -} +// export type RequestWithTenantAgent = Request & { +// user: { +// agent: TenantAgent +// } +// } -export type RequestWithRootTenantAgent = Request & { - user: { - agent: Agent - } -} +// export type RequestWithRootAgent = Request & { +// user: { +// agent: Agent +// } +// } + +// export type RequestWithRootTenantAgent = Request & { +// user: { +// agent: Agent +// } +// } let dynamicApiKey: string = 'api_key' // Initialize with a default value @@ -43,11 +43,10 @@ export async function expressAuthentication( securityName: string, secMethod?: { [key: string]: any }, scopes?: string -): Promise { - // ): Promise | Agent | TenantAgent> { + // ): Promise { +): Promise | Agent | TenantAgent> { try { const logger = new TsLogger(LogLevel.info) - const req = request as RequestWithAgent const agent = container.resolve(Agent) logger.info(`secMethod::: ${JSON.stringify(secMethod)}`) @@ -103,7 +102,7 @@ export async function expressAuthentication( if (!verified) return false // Only need to registerInstance for TenantAgent. - req['user'] = { agent: tenantAgent } + // req['user'] = { agent: tenantAgent } // return { req } return tenantAgent } @@ -117,8 +116,9 @@ export async function expressAuthentication( if (!verified) return false // req['user'] = {agent} - req['user'] = { agent: agent } + // req['user'] = { agent: agent } // return { req } + console.log('verified in authentication for BW') return agent } else { return false //'Invalid Token' diff --git a/src/controllers/additional-endpoint/context.Controller.ts b/src/controllers/additional-endpoint/context.Controller.ts index 65a09f3d..b37cebf8 100644 --- a/src/controllers/additional-endpoint/context.Controller.ts +++ b/src/controllers/additional-endpoint/context.Controller.ts @@ -1,4 +1,4 @@ -import type { OutOfBandInvitationProps, OutOfBandRecordWithInvitationProps } from '../examples' +import type { OutOfBandInvitationProps, OutOfBandRecordWithInvitationProps, RecordId } from '../examples' // eslint-disable-next-line import/order import type { RecipientKeyOption } from '../types' // AgentMessageType, // import type { ConnectionRecordProps, CreateLegacyInvitationConfig, Routing } from '@aries-framework/core' @@ -40,7 +40,12 @@ import { TsoaResponse, Security, Request, + Get, + Path, + Query, } from 'tsoa' +import { Request as Req} from 'express' +import { request } from 'http' @Tags('Test Connection') // @Security('authorization') @@ -49,10 +54,10 @@ import { @injectable() export class ContextController extends Controller { // private agent: Agent - public constructor(private readonly agent: Agent) { - super() - this.agent = agent - } + // public constructor(private readonly agent: Agent) { + // super() + // this.agent = agent + // } // @Get('/get-token') // public async getAgentToken(): Promise { // const agentDetails = await this.agent.genericRecords.getAll() @@ -164,7 +169,7 @@ export class ContextController extends Controller { @Post('/create-legacy-invitation') public async createLegacyInvitation( // Request implementation - // @Request() request: RequestWithAgent, + @Request() request: Req, @Res() internalServerError: TsoaResponse<500, { message: string }>, @Body() config?: Omit & RecipientKeyOption ) { @@ -173,25 +178,25 @@ export class ContextController extends Controller { let routing: Routing if (config?.recipientKey) { routing = { - endpoints: this.agent.config.endpoints, + endpoints: request.user.agent.config.endpoints, routingKeys: [], recipientKey: Key.fromPublicKeyBase58(config.recipientKey, KeyType.Ed25519), mediatorId: undefined, } } else { - routing = await this.agent.mediationRecipient.getRouting({}) + routing = await request.user.agent.mediationRecipient.getRouting({}) } - const { outOfBandRecord, invitation } = await this.agent.oob.createLegacyInvitation({ + const { outOfBandRecord, invitation } = await request.user.agent.oob.createLegacyInvitation({ ...config, routing, }) return { invitationUrl: invitation.toUrl({ - domain: this.agent.config.endpoints[0], - useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, + domain: request.user.agent.config.endpoints[0], + useDidSovPrefixWhereAllowed: request.user.agent.config.useDidSovPrefixWhereAllowed, }), invitation: invitation.toJSON({ - useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, + useDidSovPrefixWhereAllowed: request.user.agent.config.useDidSovPrefixWhereAllowed, }), outOfBandRecord: outOfBandRecord.toJSON(), ...(config?.recipientKey ? {} : { recipientKey: routing.recipientKey.publicKeyBase58 }), @@ -216,7 +221,7 @@ export class ContextController extends Controller { @Post('/receive-invitation-url') public async receiveInvitationFromUrl( // Request implementation - @Request() request: RequestWithAgent, + @Request() request: Req, @Body() invitationRequest: ReceiveInvitationByUrlProps, @Res() internalServerError: TsoaResponse<500, { message: string }> ) { @@ -239,4 +244,42 @@ export class ContextController extends Controller { return internalServerError(500, { message: `something went wrong: ${error}` }) } } + + /** + * Retrieve all out of band records + * @param invitationId invitation identifier + * @returns OutOfBandRecord[] + */ + @Example([outOfBandRecordExample]) + @Get() + public async getAllOutOfBandRecords(@Request() request: Req, @Query('invitationId') invitationId?: RecordId) { + let outOfBandRecords = await request.user.agent.oob.getAll() + + if (invitationId) + outOfBandRecords = outOfBandRecords.filter( + (o: { outOfBandInvitation: { id: string } }) => o.outOfBandInvitation.id === invitationId + ) + + return outOfBandRecords.map((c: { toJSON: () => any }) => c.toJSON()) + } + + /** + * Retrieve an out of band record by id + * @param recordId record identifier + * @returns OutOfBandRecord + */ + @Example(outOfBandRecordExample) + @Get('/:outOfBandId') + public async getOutOfBandRecordById( + @Request() request: Req, + @Path('outOfBandId') outOfBandId: RecordId, + @Res() notFoundError: TsoaResponse<404, { reason: string }> + ) { + const outOfBandRecord = await request.user.agent.oob.findById(outOfBandId) + + if (!outOfBandRecord) + return notFoundError(404, { reason: `Out of band record with id "${outOfBandId}" not found.` }) + + return outOfBandRecord.toJSON() + } } diff --git a/src/controllers/additional-endpoint/multitenant.Controller.ts b/src/controllers/additional-endpoint/multitenant.Controller.ts index a98623bd..7cb178e6 100644 --- a/src/controllers/additional-endpoint/multitenant.Controller.ts +++ b/src/controllers/additional-endpoint/multitenant.Controller.ts @@ -3,9 +3,9 @@ import type { Agent } from '@aries-framework/core' import type { TenantRecord } from '@aries-framework/tenants' import { RecordNotFoundError, injectable } from '@aries-framework/core' +import { Request as Req } from 'express' import jwt from 'jsonwebtoken' -import { RequestWithRootTenantAgent } from '../../authentication' import { AgentRole } from '../../enums/enum' import { generateSecretKey } from '../../utils/common.service' import { CreateTenantOptions } from '../types' @@ -30,7 +30,7 @@ export class MultiTenantController extends Controller { // @Security('RootAuthorization') @Post('/create-tenant') public async createTenant( - @Request() request: RequestWithRootTenantAgent, + @Request() request: Req, @Body() createTenantOptions: CreateTenantOptions, @Res() notFoundError: TsoaResponse<404, { reason: string }>, @Res() internalServerError: TsoaResponse<500, { message: string }> @@ -38,11 +38,15 @@ export class MultiTenantController extends Controller { const { config } = createTenantOptions try { console.log('reached in create tenant') - const tenantRecord: TenantRecord = await request.user.agent.modules.tenants.createTenant({ config }) - const token = await this.getToken(request.user.agent, tenantRecord.id) + console.log('this is request.user::::::', request.user) + console.log('this is request.user.agent::::::', request.user.agent) + const agent = request.user as unknown as Agent + const tenantRecord: TenantRecord = await agent.modules.tenants?.createTenant({ config }) + const token = await this.getToken(agent, tenantRecord.id) const withToken = { token, ...tenantRecord } return withToken - return 'success' + // return typeof request['user'].agent + // return 'success' } catch (error) { if (error instanceof RecordNotFoundError) { return notFoundError(404, { @@ -75,6 +79,7 @@ export class MultiTenantController extends Controller { tenantAgent.genericRecords.save({ content: { secretKey: secretKey, + token, }, }) }) diff --git a/src/controllers/agent/AgentController.ts b/src/controllers/agent/AgentController.ts index fdce5d11..cc0ed440 100644 --- a/src/controllers/agent/AgentController.ts +++ b/src/controllers/agent/AgentController.ts @@ -3,7 +3,10 @@ import type { AgentInfo, AgentToken } from '../types' import { Agent } from '@aries-framework/core' import { injectable } from 'tsyringe' -import { Controller, Delete, Get, Route, Tags, Security } from 'tsoa' +import { RequestWithAgent } from '../../authentication' + +import { Controller, Delete, Get, Route, Tags, Security, Request } from 'tsoa' +import { Request as Req } from 'express' @Tags('Agent') @Route('/agent') @@ -41,14 +44,17 @@ export class AgentController extends Controller { */ @Get('/token') @Security('apiKey') - public async getAgentToken(): Promise { + public async getAgentToken(@Request() request: Req): Promise { // const details = await this.agent.genericRecords.getAll() - const genericRecord = await this.agent.genericRecords.getAll() - const recordWithToken = genericRecord.find((record) => record?.content?.token !== undefined) - const token = recordWithToken?.content.token as string - return { - token: token, - } + console.log(`This is in agent token request['user'].agent::::::`, request['user']) + const genericRecord = await request.user.agent.genericRecords.getAll() + console.log('genericRecord:::::', genericRecord) + // const recordWithToken = genericRecord.find((record) => record?.content?.token !== undefined) + // const token = recordWithToken?.content.token as string + // return { + // token: token, + // } + return 'success' } /** diff --git a/src/error/ApiError.ts b/src/error/ApiError.ts new file mode 100644 index 00000000..fb733e1e --- /dev/null +++ b/src/error/ApiError.ts @@ -0,0 +1,4 @@ +export interface ApiError { + message: string + details?: unknown +} diff --git a/src/error/StatusException.ts b/src/error/StatusException.ts new file mode 100644 index 00000000..c41dced6 --- /dev/null +++ b/src/error/StatusException.ts @@ -0,0 +1,8 @@ +export class StatusException extends Error { + public status: number + + public constructor(message: string, status: number) { + super(message) + this.status = status + } +} diff --git a/src/error/index.ts b/src/error/index.ts new file mode 100644 index 00000000..1a8ad899 --- /dev/null +++ b/src/error/index.ts @@ -0,0 +1,2 @@ +export * from './ApiError' +export * from './StatusException' diff --git a/src/routes/routes.ts b/src/routes/routes.ts index a66158fe..4bbd4a5d 100644 --- a/src/routes/routes.ts +++ b/src/routes/routes.ts @@ -48,7 +48,14 @@ const models: TsoaRoute.Models = { "endpoints": {"dataType":"array","array":{"dataType":"string"},"required":true}, "isInitialized": {"dataType":"boolean","required":true}, "publicDid": {"dataType":"void","required":true}, - "token": {"dataType":"any","required":true}, + }, + "additionalProperties": false, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "AgentToken": { + "dataType": "refObject", + "properties": { + "token": {"dataType":"string","required":true}, }, "additionalProperties": false, }, @@ -767,7 +774,7 @@ export function RegisterRoutes(app: Router) { // NOTE: If you do not see routes for all of your controllers in this file, then you might not have informed tsoa of where to look // Please look into the "controllerPathGlobs" config option described in the readme: https://github.com/lukeautry/tsoa // ########################################################################################################### - app.get('/agent', + app.get('/agent/info', ...(fetchMiddlewares(AgentController)), ...(fetchMiddlewares(AgentController.prototype.getAgentInfo)), @@ -796,6 +803,37 @@ export function RegisterRoutes(app: Router) { } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + app.get('/agent/token', + authenticateMiddleware([{"apiKey":[]}]), + ...(fetchMiddlewares(AgentController)), + ...(fetchMiddlewares(AgentController.prototype.getAgentToken)), + + async function AgentController_getAgentToken(request: any, response: any, next: any) { + const args = { + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + }; + + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + + let validatedArgs: any[] = []; + try { + validatedArgs = getValidatedArgs(args, request, response); + + const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; + + const controller: any = await container.get(AgentController); + if (typeof controller['setStatus'] === 'function') { + controller.setStatus(undefined); + } + + + const promise = controller.getAgentToken.apply(controller, validatedArgs as any); + promiseHandler(controller, promise, response, undefined, next); + } catch (err) { + return next(err); + } + }); + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.delete('/agent/wallet', authenticateMiddleware([{"apiKey":[]}]), ...(fetchMiddlewares(AgentController)), @@ -3848,6 +3886,7 @@ export function RegisterRoutes(app: Router) { async function ContextController_createLegacyInvitation(request: any, response: any, next: any) { const args = { + request: {"in":"request","name":"request","required":true,"dataType":"object"}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, config: {"in":"body","name":"config","dataType":"intersection","subSchemas":[{"ref":"Omit_CreateLegacyInvitationConfig.routing_"},{"ref":"RecipientKeyOption"}]}, }; @@ -3873,6 +3912,104 @@ export function RegisterRoutes(app: Router) { } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + app.post('/test-endpoint/receive-invitation-url', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(ContextController)), + ...(fetchMiddlewares(ContextController.prototype.receiveInvitationFromUrl)), + + async function ContextController_receiveInvitationFromUrl(request: any, response: any, next: any) { + const args = { + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + invitationRequest: {"in":"body","name":"invitationRequest","required":true,"ref":"ReceiveInvitationByUrlProps"}, + internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, + }; + + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + + let validatedArgs: any[] = []; + try { + validatedArgs = getValidatedArgs(args, request, response); + + const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; + + const controller: any = await container.get(ContextController); + if (typeof controller['setStatus'] === 'function') { + controller.setStatus(undefined); + } + + + const promise = controller.receiveInvitationFromUrl.apply(controller, validatedArgs as any); + promiseHandler(controller, promise, response, undefined, next); + } catch (err) { + return next(err); + } + }); + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + app.get('/test-endpoint', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(ContextController)), + ...(fetchMiddlewares(ContextController.prototype.getAllOutOfBandRecords)), + + async function ContextController_getAllOutOfBandRecords(request: any, response: any, next: any) { + const args = { + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + invitationId: {"in":"query","name":"invitationId","ref":"RecordId"}, + }; + + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + + let validatedArgs: any[] = []; + try { + validatedArgs = getValidatedArgs(args, request, response); + + const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; + + const controller: any = await container.get(ContextController); + if (typeof controller['setStatus'] === 'function') { + controller.setStatus(undefined); + } + + + const promise = controller.getAllOutOfBandRecords.apply(controller, validatedArgs as any); + promiseHandler(controller, promise, response, undefined, next); + } catch (err) { + return next(err); + } + }); + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + app.get('/test-endpoint/:outOfBandId', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(ContextController)), + ...(fetchMiddlewares(ContextController.prototype.getOutOfBandRecordById)), + + async function ContextController_getOutOfBandRecordById(request: any, response: any, next: any) { + const args = { + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + outOfBandId: {"in":"path","name":"outOfBandId","required":true,"ref":"RecordId"}, + notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, + }; + + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + + let validatedArgs: any[] = []; + try { + validatedArgs = getValidatedArgs(args, request, response); + + const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; + + const controller: any = await container.get(ContextController); + if (typeof controller['setStatus'] === 'function') { + controller.setStatus(undefined); + } + + + const promise = controller.getOutOfBandRecordById.apply(controller, validatedArgs as any); + promiseHandler(controller, promise, response, undefined, next); + } catch (err) { + return next(err); + } + }); + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.get('/question-answer', authenticateMiddleware([{"apiKey":[]}]), ...(fetchMiddlewares(QuestionAnswerController)), diff --git a/src/routes/swagger.json b/src/routes/swagger.json index c0f5782a..eedceb0d 100644 --- a/src/routes/swagger.json +++ b/src/routes/swagger.json @@ -21,14 +21,24 @@ "isInitialized": { "type": "boolean" }, - "publicDid": {}, - "token": {} + "publicDid": {} }, "required": [ "label", "endpoints", "isInitialized", - "publicDid", + "publicDid" + ], + "type": "object", + "additionalProperties": false + }, + "AgentToken": { + "properties": { + "token": { + "type": "string" + } + }, + "required": [ "token" ], "type": "object", @@ -1759,7 +1769,7 @@ "contact": {} }, "paths": { - "/agent": { + "/agent/info": { "get": { "operationId": "GetAgentInfo", "responses": { @@ -1782,6 +1792,40 @@ "parameters": [] } }, + "/agent/token": { + "get": { + "operationId": "GetAgentToken", + "responses": { + "200": { + "description": "Ok", + "content": { + "application/json": { + "schema": { + "anyOf": [ + { + "$ref": "#/components/schemas/AgentToken" + }, + { + "type": "string" + } + ] + } + } + } + } + }, + "description": "Retrieve agent token", + "tags": [ + "Agent" + ], + "security": [ + { + "apiKey": [] + } + ], + "parameters": [] + } + }, "/agent/wallet": { "delete": { "operationId": "DeleteWallet", @@ -9317,6 +9361,291 @@ } } }, + "/test-endpoint/receive-invitation-url": { + "post": { + "operationId": "ReceiveInvitationFromUrl", + "responses": { + "200": { + "description": "out-of-band record and connection record if one has been created.", + "content": { + "application/json": { + "schema": {}, + "examples": { + "Example 1": { + "value": { + "outOfBandRecord": { + "_tags": { + "invitationId": "1cbd22e4-1906-41e9-8807-83d84437f978", + "state": "await-response", + "role": "sender", + "recipientKeyFingerprints": [ + "z6MktUCPZjfRJXD4GMcYuXiqX2qZ8vBw6UAYpDFiHEUfwuLj" + ] + }, + "outOfBandInvitation": { + "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.1/invitation", + "@id": "d6472943-e5d0-4d95-8b48-790ed5a41931", + "label": "Aries Test Agent", + "accept": [ + "didcomm/aip1", + "didcomm/aip2;env=rfc19" + ], + "handshake_protocols": [ + "https://didcomm.org/didexchange/1.0", + "https://didcomm.org/connections/1.0" + ], + "services": [ + { + "id": "#inline-0", + "serviceEndpoint": "https://6b77-89-20-162-146.ngrok.io", + "type": "did-communication", + "recipientKeys": [ + "did:key:z6MkmTBHTWrvLPN8pBmUj7Ye5ww9GiacXCYMNVvpScSpf1DM" + ], + "routingKeys": [] + } + ] + }, + "metadata": {}, + "id": "42a95528-0e30-4f86-a462-0efb02178b53", + "createdAt": "2022-01-01T00:00:00.000Z", + "reusable": false + }, + "connectionRecord": { + "_tags": { + "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", + "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", + "invitationKey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz", + "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d", + "verkey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz" + }, + "metadata": {}, + "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", + "createdAt": "2022-01-01T00:00:00.000Z", + "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", + "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", + "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d" + } + } + } + } + } + } + }, + "500": { + "description": "", + "content": { + "application/json": { + "schema": { + "properties": { + "message": { + "type": "string" + } + }, + "required": [ + "message" + ], + "type": "object" + } + } + } + } + }, + "description": "Creates inbound out-of-band record and assigns out-of-band invitation message to it if the\nmessage is valid.", + "tags": [ + "Test Connection" + ], + "security": [ + { + "jwt": [] + } + ], + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ReceiveInvitationByUrlProps" + } + } + } + } + } + }, + "/test-endpoint": { + "get": { + "operationId": "GetAllOutOfBandRecords", + "responses": { + "200": { + "description": "OutOfBandRecord[]", + "content": { + "application/json": { + "schema": {}, + "examples": { + "Example 1": { + "value": [ + { + "_tags": { + "invitationId": "1cbd22e4-1906-41e9-8807-83d84437f978", + "state": "await-response", + "role": "sender", + "recipientKeyFingerprints": [ + "z6MktUCPZjfRJXD4GMcYuXiqX2qZ8vBw6UAYpDFiHEUfwuLj" + ] + }, + "outOfBandInvitation": { + "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.1/invitation", + "@id": "d6472943-e5d0-4d95-8b48-790ed5a41931", + "label": "Aries Test Agent", + "accept": [ + "didcomm/aip1", + "didcomm/aip2;env=rfc19" + ], + "handshake_protocols": [ + "https://didcomm.org/didexchange/1.0", + "https://didcomm.org/connections/1.0" + ], + "services": [ + { + "id": "#inline-0", + "serviceEndpoint": "https://6b77-89-20-162-146.ngrok.io", + "type": "did-communication", + "recipientKeys": [ + "did:key:z6MkmTBHTWrvLPN8pBmUj7Ye5ww9GiacXCYMNVvpScSpf1DM" + ], + "routingKeys": [] + } + ] + }, + "metadata": {}, + "id": "42a95528-0e30-4f86-a462-0efb02178b53", + "createdAt": "2022-01-01T00:00:00.000Z", + "reusable": false + } + ] + } + } + } + } + } + }, + "description": "Retrieve all out of band records", + "tags": [ + "Test Connection" + ], + "security": [ + { + "jwt": [] + } + ], + "parameters": [ + { + "description": "invitation identifier", + "in": "query", + "name": "invitationId", + "required": false, + "schema": { + "$ref": "#/components/schemas/RecordId" + } + } + ] + } + }, + "/test-endpoint/{outOfBandId}": { + "get": { + "operationId": "GetOutOfBandRecordById", + "responses": { + "200": { + "description": "OutOfBandRecord", + "content": { + "application/json": { + "schema": {}, + "examples": { + "Example 1": { + "value": { + "_tags": { + "invitationId": "1cbd22e4-1906-41e9-8807-83d84437f978", + "state": "await-response", + "role": "sender", + "recipientKeyFingerprints": [ + "z6MktUCPZjfRJXD4GMcYuXiqX2qZ8vBw6UAYpDFiHEUfwuLj" + ] + }, + "outOfBandInvitation": { + "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.1/invitation", + "@id": "d6472943-e5d0-4d95-8b48-790ed5a41931", + "label": "Aries Test Agent", + "accept": [ + "didcomm/aip1", + "didcomm/aip2;env=rfc19" + ], + "handshake_protocols": [ + "https://didcomm.org/didexchange/1.0", + "https://didcomm.org/connections/1.0" + ], + "services": [ + { + "id": "#inline-0", + "serviceEndpoint": "https://6b77-89-20-162-146.ngrok.io", + "type": "did-communication", + "recipientKeys": [ + "did:key:z6MkmTBHTWrvLPN8pBmUj7Ye5ww9GiacXCYMNVvpScSpf1DM" + ], + "routingKeys": [] + } + ] + }, + "metadata": {}, + "id": "42a95528-0e30-4f86-a462-0efb02178b53", + "createdAt": "2022-01-01T00:00:00.000Z", + "reusable": false + } + } + } + } + } + }, + "404": { + "description": "", + "content": { + "application/json": { + "schema": { + "properties": { + "reason": { + "type": "string" + } + }, + "required": [ + "reason" + ], + "type": "object" + } + } + } + } + }, + "description": "Retrieve an out of band record by id", + "tags": [ + "Test Connection" + ], + "security": [ + { + "jwt": [] + } + ], + "parameters": [ + { + "in": "path", + "name": "outOfBandId", + "required": true, + "schema": { + "$ref": "#/components/schemas/RecordId" + } + } + ] + } + }, "/question-answer": { "get": { "operationId": "GetQuestionAnswerRecords", diff --git a/src/securityMiddleware.ts b/src/securityMiddleware.ts index 70640706..57a4b4dd 100644 --- a/src/securityMiddleware.ts +++ b/src/securityMiddleware.ts @@ -1,54 +1,87 @@ +import type { RestAgentModules, RestMultiTenantAgentModules } from './cliAgent' import type * as express from 'express' import type { NextFunction } from 'express' +// eslint-disable-next-line import/order +import { Agent } from '@aries-framework/core' // eslint-disable-next-line import/order import { Middlewares } from '@tsoa/runtime' +// eslint-disable-next-line import/namespace + +import { container } from 'tsyringe' + import { expressAuthentication } from './authentication' // Import your authentication function @Middlewares() export class SecurityMiddleware { public async use(request: express.Request, response: express.Response, next: NextFunction) { - try { - let securityName = 'apiKey' + // public async use(request: express.Request, response: express.Response) { + // try { - // Extract route path or controller name from the request - const routePath = request.path + const agent = container.resolve(Agent) + let securityName = 'jwt' - // List of paths for which authentication should be skipped - const pathsToSkipAuthentication = ['/url/', '/multi-tenancy/url/', '/agent'] + // Extract route path or controller name from the request + const routePath = request.path - // Check if authentication should be skipped for this route or controller - const skipAuthentication = pathsToSkipAuthentication.some((path) => routePath.includes(path)) + // List of paths for which authentication should be skipped + const pathsToSkipAuthentication = ['/url/', '/multi-tenancy/url/', '/agent/info'] - // Krish: here test endpoints will be replaced by all enpoints except 'pathsToSkipAuthentication' - if (routePath.includes('/test-endpoint/')) { - securityName = 'jwt' - console.log('Reached in securityMiddleware::::: /test-endpoint/') - // const result = await expressAuthentication(request, securityName); - } + // Check if authentication should be skipped for this route or controller + const skipAuthentication = pathsToSkipAuthentication.some((path) => routePath.includes(path)) - if (skipAuthentication) { - // Skip authentication for this route or controller - console.log('Skipped authentication') - next() - } else if (securityName) { - const result = await expressAuthentication(request, securityName) - console.log('This is result in securityMiddleware:::::', result) + // Krish: here test endpoints will be replaced by all enpoints except 'pathsToSkipAuthentication' + if (routePath.includes('/agent/token')) { + securityName = 'apiKey' + console.log('Reached in securityMiddleware::::: /test-endpoint/') + // const result = await expressAuthentication(request, securityName); + } - if (result === 'success') { - console.log('Successfully resulted') + if (skipAuthentication) { + // Skip authentication for this route or controller + console.log('Skipped authentication') + // for skipped authentication there are two ways to handle + request.user = { agent: agent } + next() + // const agent = container.resolve(Agent) + // return Promise.resolve({ agent: agent }) + } else if (securityName) { + const result = await expressAuthentication(request, securityName, next) + console.log('Result:::::', result) + if (typeof result === 'boolean') { + console.log('Successfully resulted') + if (result) { + // Validation for api-key + request.user = { agent: agent } next() - } else if (result) { - response.status(401).json({ message: `Unauthorized ${result}` }) - } else { - response.status(401).json({ message: 'Unauthorized' }) - } - } else { - response.status(400).json({ message: 'Bad Request' }) + } else response.status(401).json({ message: `Unauthorized` }) + // } else return Promise.reject(new StatusException('Unauthorized', 401)) + } else if (!result) { + response.status(401).json({ message: `Unauthorized` }) + // return Promise.reject(new StatusException('Unauthorized', 401)) + } else if (result.wallet) { + console.log('this is type of result', result) + console.log('From securityMiddleware:::::::::') + // return Promise.resolve({ agent: result }) + // return result + // const temp = request.user + // temp['agent'] = result + // request.user = temp + request.user = { agent: result } + // request.user['agent'] = result + console.log('verified agent from middleware') + console.log(`this is request.user`, request.user) + console.log(`this is request.user.agent`, request.user.agent) + console.log(`this is request.user.agent.config`, request.user.agent.config) + next() } - } catch (error) { - next(error) + } else { + response.status(400).json({ message: 'Bad Request' }) + // return Promise.reject(new StatusException('Bad Request', 400)) } + // } catch (error) { + // next(error) + // } } } diff --git a/src/types/request.d.ts b/src/types/request.d.ts new file mode 100644 index 00000000..b1b878b4 --- /dev/null +++ b/src/types/request.d.ts @@ -0,0 +1,38 @@ +import type { RestAgentModules, RestMultiTenantAgentModules } from '../cliAgent' +import type { Agent } from '@aries-framework/core' +import type { TenantAgent } from '@aries-framework/tenants/build/TenantAgent' + +// declare global { +// namespace Express { +// interface Request { +// user: { +// [x: string]: any +// agent: Agent | Agent | TenantAgent +// } +// } +// } +// } +type AgentType = Agent | Agent | TenantAgent + +interface IAgent { + agent: AgentType +} + +declare global { + namespace Express { + interface Request { + user: IAgent + } + } +} + +// declare global { +// namespace Express { +// interface Request { +// user: { +// [x: string]: any +// agent: any +// } +// } +// } +// } diff --git a/tsconfig.json b/tsconfig.json index de0ca16d..972d61fb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,12 @@ }, "experimentalDecorators": true, "emitDecoratorMetadata": true, - "types": ["jest", "node"] + "types": ["jest", "node"], + "typeRoots": [ + "@types", + "./node_modules/@types", + "src/types" // Add your custom types directory + ] }, "exclude": ["node_modules", "build"] } From b4497d9f25a29b28cddf28dbb284ede142ed3265 Mon Sep 17 00:00:00 2001 From: Krishna Date: Wed, 17 Apr 2024 17:35:49 +0530 Subject: [PATCH 06/16] add: auth updates Signed-off-by: Krishna --- src/authentication.ts | 61 ++++++------------- .../additional-endpoint/context.Controller.ts | 42 ++++++------- .../multitenant.Controller.ts | 7 ++- src/controllers/agent/AgentController.ts | 8 +-- src/securityMiddleware.ts | 22 ++++--- src/server.ts | 2 +- src/types/request.d.ts | 2 +- 7 files changed, 59 insertions(+), 85 deletions(-) diff --git a/src/authentication.ts b/src/authentication.ts index 15e09d06..0c1ea4a1 100644 --- a/src/authentication.ts +++ b/src/authentication.ts @@ -1,40 +1,15 @@ import type { RestAgentModules, RestMultiTenantAgentModules } from './cliAgent' +import type { Agent } from '@aries-framework/core' import type { TenantAgent } from '@aries-framework/tenants/build/TenantAgent' import type { Request } from 'express' -import { Agent, LogLevel } from '@aries-framework/core' +import { LogLevel } from '@aries-framework/core' import jwt, { decode } from 'jsonwebtoken' -import { container } from 'tsyringe' import { AgentRole } from './enums/enum' import { TsLogger } from './utils/logger' -export type AgentType = Agent | Agent | TenantAgent -export type RequestWithAgent = Request & { - name: string - user: { - agent: TenantAgent | Agent | Agent - } -} -// export type RequestWithAgent = RequestWithRootAgent | RequestWithTenantAgent | RequestWithRootTenantAgent - -// export type RequestWithTenantAgent = Request & { -// user: { -// agent: TenantAgent -// } -// } - -// export type RequestWithRootAgent = Request & { -// user: { -// agent: Agent -// } -// } - -// export type RequestWithRootTenantAgent = Request & { -// user: { -// agent: Agent -// } -// } +// export type AgentType = Agent | Agent | TenantAgent let dynamicApiKey: string = 'api_key' // Initialize with a default value @@ -42,15 +17,18 @@ export async function expressAuthentication( request: Request, securityName: string, secMethod?: { [key: string]: any }, - scopes?: string - // ): Promise { + scopes?: string, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + agent?: Agent ): Promise | Agent | TenantAgent> { try { + console.log('Race: Reached in Authentication') const logger = new TsLogger(LogLevel.info) - const agent = container.resolve(Agent) + // const agent = container.resolve(Agent) logger.info(`secMethod::: ${JSON.stringify(secMethod)}`) logger.info(`scopes::: ${JSON.stringify(scopes)}`) + logger.info(`scopes::: ${JSON.stringify(scopes)}`) const apiKeyHeader = request.headers['authorization'] @@ -61,17 +39,18 @@ export async function expressAuthentication( // add additional logic to get the token from wallet for validating the passed if (securityName === 'apiKey') { + // Auth: For BW/Dedicated agent to GET their token if (apiKeyHeader) { const providedApiKey = apiKeyHeader as string if (providedApiKey === dynamicApiKey) { - return agent + return true } } } if (securityName === 'jwt') { - const tenancy = agent.modules.tenants ? true : false + const tenancy = agent!.modules.tenants ? true : false const tokenWithHeader = apiKeyHeader const token = tokenWithHeader.replace('Bearer ', '') const reqPath = request.path @@ -90,10 +69,10 @@ export async function expressAuthentication( if (reqPath.includes('/multi-tenant/')) { return false //'Tenants cannot manage tenants' } else { - // verify tenant agent + // Auth: tenant agent const tenantId: string = decodedToken.tenantId if (!tenantId) return false - const tenantAgent = await getTenantAgent(agent, tenantId) + const tenantAgent = await getTenantAgent(agent!, tenantId) if (!tenantAgent) return false const verified = await verifyToken(tenantAgent, token) @@ -107,8 +86,8 @@ export async function expressAuthentication( return tenantAgent } } else if (role === AgentRole.RestRootAgentWithTenants) { - // Logic for base wallet verification - const verified = await verifyToken(agent, token) + // Auth: base wallet + const verified = await verifyToken(agent!, token) // Base wallet cant access any endpoints apart from multi-tenant endpoint // if (!reqPath.includes('/multi-tenant/') && !reqPath.includes('/multi-tenancy/')) @@ -119,7 +98,7 @@ export async function expressAuthentication( // req['user'] = { agent: agent } // return { req } console.log('verified in authentication for BW') - return agent + return true } else { return false //'Invalid Token' } @@ -127,17 +106,17 @@ export async function expressAuthentication( if (role !== AgentRole.RestRootAgent) { return false //'This is a dedicated agent' } else { - // It has a role of dedicated agent, verify + // Auth: dedicated agent if (reqPath.includes('/multi-tenant/')) return false - const verified = await verifyToken(agent, token) + const verified = await verifyToken(agent!, token) if (!verified) return false // Can have an enum instead of 'success' string // req['user'] = { agent: agent } // return { req } - return agent + return true } } } diff --git a/src/controllers/additional-endpoint/context.Controller.ts b/src/controllers/additional-endpoint/context.Controller.ts index b37cebf8..daf6a524 100644 --- a/src/controllers/additional-endpoint/context.Controller.ts +++ b/src/controllers/additional-endpoint/context.Controller.ts @@ -1,18 +1,12 @@ -import type { OutOfBandInvitationProps, OutOfBandRecordWithInvitationProps, RecordId } from '../examples' +import type { OutOfBandInvitationProps, OutOfBandRecordWithInvitationProps } from '../examples' // eslint-disable-next-line import/order import type { RecipientKeyOption } from '../types' // AgentMessageType, // import type { ConnectionRecordProps, CreateLegacyInvitationConfig, Routing } from '@aries-framework/core' import type { ConnectionRecordProps, CreateLegacyInvitationConfig, Routing } from '@aries-framework/core' -import { - Key, - KeyType, - // RecordNotFoundError, - // Key, - // KeyType, - Agent, -} from '@aries-framework/core' +import { Key, KeyType } from '@aries-framework/core' +import { Request as Req } from 'express' import { injectable } from 'tsyringe' // import { ConnectionRecordExample, outOfBandInvitationExample, outOfBandRecordExample, RecordId } from '../examples' @@ -23,8 +17,7 @@ import { injectable } from 'tsyringe' // CreateInvitationOptions, // } from '../types' -import { RequestWithAgent } from '../../authentication' -import { ConnectionRecordExample, outOfBandInvitationExample, outOfBandRecordExample } from '../examples' +import { ConnectionRecordExample, outOfBandInvitationExample, outOfBandRecordExample, RecordId } from '../examples' import { ReceiveInvitationByUrlProps } from '../types' import { @@ -44,8 +37,6 @@ import { Path, Query, } from 'tsoa' -import { Request as Req} from 'express' -import { request } from 'http' @Tags('Test Connection') // @Security('authorization') @@ -174,29 +165,29 @@ export class ContextController extends Controller { @Body() config?: Omit & RecipientKeyOption ) { try { - // console.log('this is request::::::::::', JSON.stringify(request)) + console.log('this is request.agent.config in [createLegacyInvitation]::::::::::', request.agent.config) let routing: Routing if (config?.recipientKey) { routing = { - endpoints: request.user.agent.config.endpoints, + endpoints: request.agent.config.endpoints, routingKeys: [], recipientKey: Key.fromPublicKeyBase58(config.recipientKey, KeyType.Ed25519), mediatorId: undefined, } } else { - routing = await request.user.agent.mediationRecipient.getRouting({}) + routing = await request.agent.mediationRecipient.getRouting({}) } - const { outOfBandRecord, invitation } = await request.user.agent.oob.createLegacyInvitation({ + const { outOfBandRecord, invitation } = await request.agent.oob.createLegacyInvitation({ ...config, routing, }) return { invitationUrl: invitation.toUrl({ - domain: request.user.agent.config.endpoints[0], - useDidSovPrefixWhereAllowed: request.user.agent.config.useDidSovPrefixWhereAllowed, + domain: request.agent.config.endpoints[0], + useDidSovPrefixWhereAllowed: request.agent.config.useDidSovPrefixWhereAllowed, }), invitation: invitation.toJSON({ - useDidSovPrefixWhereAllowed: request.user.agent.config.useDidSovPrefixWhereAllowed, + useDidSovPrefixWhereAllowed: request.agent.config.useDidSovPrefixWhereAllowed, }), outOfBandRecord: outOfBandRecord.toJSON(), ...(config?.recipientKey ? {} : { recipientKey: routing.recipientKey.publicKeyBase58 }), @@ -228,11 +219,12 @@ export class ContextController extends Controller { const { invitationUrl, ...config } = invitationRequest try { - const linkSecretIds = await request.user.agent.modules.anoncreds.getLinkSecretIds() + console.log('Reached in receive invitation') + const linkSecretIds = await request.agent.modules.anoncreds.getLinkSecretIds() if (linkSecretIds.length === 0) { - await request.user.agent.modules.anoncreds.createLinkSecret() + await request.agent.modules.anoncreds.createLinkSecret() } - const { outOfBandRecord, connectionRecord } = await request.user.agent.oob.receiveInvitationFromUrl( + const { outOfBandRecord, connectionRecord } = await request.agent.oob.receiveInvitationFromUrl( invitationUrl, config ) @@ -253,7 +245,7 @@ export class ContextController extends Controller { @Example([outOfBandRecordExample]) @Get() public async getAllOutOfBandRecords(@Request() request: Req, @Query('invitationId') invitationId?: RecordId) { - let outOfBandRecords = await request.user.agent.oob.getAll() + let outOfBandRecords = await request.agent.oob.getAll() if (invitationId) outOfBandRecords = outOfBandRecords.filter( @@ -275,7 +267,7 @@ export class ContextController extends Controller { @Path('outOfBandId') outOfBandId: RecordId, @Res() notFoundError: TsoaResponse<404, { reason: string }> ) { - const outOfBandRecord = await request.user.agent.oob.findById(outOfBandId) + const outOfBandRecord = await request.agent.oob.findById(outOfBandId) if (!outOfBandRecord) return notFoundError(404, { reason: `Out of band record with id "${outOfBandId}" not found.` }) diff --git a/src/controllers/additional-endpoint/multitenant.Controller.ts b/src/controllers/additional-endpoint/multitenant.Controller.ts index 7cb178e6..2db71e8f 100644 --- a/src/controllers/additional-endpoint/multitenant.Controller.ts +++ b/src/controllers/additional-endpoint/multitenant.Controller.ts @@ -38,9 +38,10 @@ export class MultiTenantController extends Controller { const { config } = createTenantOptions try { console.log('reached in create tenant') - console.log('this is request.user::::::', request.user) - console.log('this is request.user.agent::::::', request.user.agent) - const agent = request.user as unknown as Agent + console.log('this is request in controller::::::', request) + console.log('this is request.user::::::', request.agent) + console.log('this is request.agent.config::::::', request.agent.config) + const agent = request.agent as unknown as Agent const tenantRecord: TenantRecord = await agent.modules.tenants?.createTenant({ config }) const token = await this.getToken(agent, tenantRecord.id) const withToken = { token, ...tenantRecord } diff --git a/src/controllers/agent/AgentController.ts b/src/controllers/agent/AgentController.ts index cc0ed440..f6c1a872 100644 --- a/src/controllers/agent/AgentController.ts +++ b/src/controllers/agent/AgentController.ts @@ -1,12 +1,10 @@ import type { AgentInfo, AgentToken } from '../types' import { Agent } from '@aries-framework/core' +import { Request as Req } from 'express' import { injectable } from 'tsyringe' -import { RequestWithAgent } from '../../authentication' - import { Controller, Delete, Get, Route, Tags, Security, Request } from 'tsoa' -import { Request as Req } from 'express' @Tags('Agent') @Route('/agent') @@ -46,8 +44,8 @@ export class AgentController extends Controller { @Security('apiKey') public async getAgentToken(@Request() request: Req): Promise { // const details = await this.agent.genericRecords.getAll() - console.log(`This is in agent token request['user'].agent::::::`, request['user']) - const genericRecord = await request.user.agent.genericRecords.getAll() + console.log(`This is in agent token request.agent::::::`, request.agent) + const genericRecord = await request.agent.genericRecords.getAll() console.log('genericRecord:::::', genericRecord) // const recordWithToken = genericRecord.find((record) => record?.content?.token !== undefined) // const token = recordWithToken?.content.token as string diff --git a/src/securityMiddleware.ts b/src/securityMiddleware.ts index 57a4b4dd..a015890e 100644 --- a/src/securityMiddleware.ts +++ b/src/securityMiddleware.ts @@ -1,4 +1,4 @@ -import type { RestAgentModules, RestMultiTenantAgentModules } from './cliAgent' +import type { RestMultiTenantAgentModules } from './cliAgent' import type * as express from 'express' import type { NextFunction } from 'express' @@ -16,10 +16,11 @@ import { expressAuthentication } from './authentication' // Import your authenti @Middlewares() export class SecurityMiddleware { public async use(request: express.Request, response: express.Response, next: NextFunction) { + console.log('Race: Reached in Middleware') // public async use(request: express.Request, response: express.Response) { // try { - const agent = container.resolve(Agent) + const agent = container.resolve(Agent) let securityName = 'jwt' // Extract route path or controller name from the request @@ -42,18 +43,20 @@ export class SecurityMiddleware { // Skip authentication for this route or controller console.log('Skipped authentication') // for skipped authentication there are two ways to handle - request.user = { agent: agent } + request['agent'] = agent next() // const agent = container.resolve(Agent) // return Promise.resolve({ agent: agent }) } else if (securityName) { - const result = await expressAuthentication(request, securityName, next) + const result = await expressAuthentication(request, securityName, undefined, undefined, agent) console.log('Result:::::', result) if (typeof result === 'boolean') { console.log('Successfully resulted') if (result) { + // Auth: for BW/Dedicated agent // Validation for api-key - request.user = { agent: agent } + // request.user = { agent: agent } + request['agent'] = agent next() } else response.status(401).json({ message: `Unauthorized` }) // } else return Promise.reject(new StatusException('Unauthorized', 401)) @@ -68,12 +71,13 @@ export class SecurityMiddleware { // const temp = request.user // temp['agent'] = result // request.user = temp - request.user = { agent: result } + request['agent'] = result // request.user['agent'] = result console.log('verified agent from middleware') - console.log(`this is request.user`, request.user) - console.log(`this is request.user.agent`, request.user.agent) - console.log(`this is request.user.agent.config`, request.user.agent.config) + console.log('this is request in middleware::::::', request) + console.log(`this is request.agent`, request.agent) + // console.log(`this is request.user.agent`, request.user) + console.log(`this is request.agent.config`, request.agent.config) next() } } else { diff --git a/src/server.ts b/src/server.ts index 10c95f99..6658ac41 100644 --- a/src/server.ts +++ b/src/server.ts @@ -12,7 +12,7 @@ import { serve, generateHTML } from 'swagger-ui-express' import { container } from 'tsyringe' // eslint-disable-next-line import/namespace -import { RequestWithAgent, setDynamicApiKey } from './authentication' +import { setDynamicApiKey } from './authentication' import { basicMessageEvents } from './events/BasicMessageEvents' import { connectionEvents } from './events/ConnectionEvents' import { credentialEvents } from './events/CredentialEvents' diff --git a/src/types/request.d.ts b/src/types/request.d.ts index b1b878b4..1589b1fe 100644 --- a/src/types/request.d.ts +++ b/src/types/request.d.ts @@ -21,7 +21,7 @@ interface IAgent { declare global { namespace Express { interface Request { - user: IAgent + agent: AgentType } } } From 2c15ea53769446ffc308bfdf90f8f1ffc50c66b0 Mon Sep 17 00:00:00 2001 From: Krishna Date: Fri, 19 Apr 2024 15:29:07 +0530 Subject: [PATCH 07/16] fix: skip authentication issues Signed-off-by: Krishna --- src/securityMiddleware.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/securityMiddleware.ts b/src/securityMiddleware.ts index a015890e..e4b9136c 100644 --- a/src/securityMiddleware.ts +++ b/src/securityMiddleware.ts @@ -25,13 +25,19 @@ export class SecurityMiddleware { // Extract route path or controller name from the request const routePath = request.path + const requestMethod = request.method // List of paths for which authentication should be skipped - const pathsToSkipAuthentication = ['/url/', '/multi-tenancy/url/', '/agent/info'] + const pathsToSkipAuthentication = [ + { path: '/url/', method: 'GET' }, + { path: '/multi-tenancy/url/', method: 'GET' }, + { path: '/agent', method: 'GET' }, + ] // Check if authentication should be skipped for this route or controller - const skipAuthentication = pathsToSkipAuthentication.some((path) => routePath.includes(path)) - + const skipAuthentication = pathsToSkipAuthentication.some( + ({ path, method }) => routePath.includes(path) && requestMethod === method + ) // Krish: here test endpoints will be replaced by all enpoints except 'pathsToSkipAuthentication' if (routePath.includes('/agent/token')) { securityName = 'apiKey' From c150c1fd062f659f81fdb28920a1e3d1d113dc0d Mon Sep 17 00:00:00 2001 From: Krishna Date: Mon, 22 Apr 2024 13:02:58 +0530 Subject: [PATCH 08/16] add: changes for static apiKey providing while starting the agent Signed-off-by: Krishna --- samples/cliConfig.json | 3 +- src/cli.ts | 4 ++ src/cliAgent.ts | 54 +++------------ src/controllers/agent/AgentController.ts | 86 ++++++++++++++++++++---- src/routes/routes.ts | 2 +- src/routes/swagger.json | 2 +- 6 files changed, 92 insertions(+), 59 deletions(-) diff --git a/samples/cliConfig.json b/samples/cliConfig.json index e46876b1..13733d39 100644 --- a/samples/cliConfig.json +++ b/samples/cliConfig.json @@ -43,5 +43,6 @@ "schemaManagerContractAddress": "0x552992e9f14b15bBd76488cD4c38c89B80259f37", "rpcUrl": "https://polygon-mumbai.infura.io/v3/0579d305568d404e996e49695e9272a3", "fileServerUrl": "https://schema.credebl.id/", - "fileServerToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJBeWFuV29ya3MiLCJpZCI6ImNhZDI3ZjhjLTMyNWYtNDRmZC04ZmZkLWExNGNhZTY3NTMyMSJ9.I3IR7abjWbfStnxzn1BhxhV0OEzt1x3mULjDdUcgWHk" + "fileServerToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJBeWFuV29ya3MiLCJpZCI6ImNhZDI3ZjhjLTMyNWYtNDRmZC04ZmZkLWExNGNhZTY3NTMyMSJ9.I3IR7abjWbfStnxzn1BhxhV0OEzt1x3mULjDdUcgWHk", + "api-key": "supersecret" } diff --git a/src/cli.ts b/src/cli.ts index 4f57ea24..c5f8c0ca 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -129,6 +129,9 @@ const parsed = yargs boolean: true, default: false, }) + .option('apiKey', { + string: true, + }) // .option('storage-config', { // array: true, // default: [], @@ -198,5 +201,6 @@ export async function runCliServer() { rpcUrl: parsed['rpcUrl'], fileServerUrl: parsed['fileServerUrl'], fileServerToken: parsed['fileServerToken'], + apiKey: parsed['apiKey'], } as unknown as AriesRestConfig) } diff --git a/src/cliAgent.ts b/src/cliAgent.ts index ea261f44..ff334f7f 100644 --- a/src/cliAgent.ts +++ b/src/cliAgent.ts @@ -50,14 +50,12 @@ import { ariesAskar } from '@hyperledger/aries-askar-nodejs' import { indyVdr } from '@hyperledger/indy-vdr-nodejs' import axios from 'axios' import { readFile } from 'fs/promises' -import jwt from 'jsonwebtoken' -import { AgentRole } from './enums/enum' // eslint-disable-next-line import/no-cycle import { setupServer } from './server' -import { generateSecretKey } from './utils/common.service' import { TsLogger } from './utils/logger' import { BCOVRIN_TEST_GENESIS } from './utils/util' +import { generateSecretKey } from './utils/common.service' export type Transports = 'ws' | 'http' export type InboundTransport = { @@ -102,6 +100,7 @@ export interface AriesRestConfig { rpcUrl: string fileServerUrl: string fileServerToken: string + apiKey: string } export async function readRestConfig(path: string) { @@ -237,6 +236,7 @@ export async function runRestAgent(restConfig: AriesRestConfig) { webhookUrl, adminPort, walletConfig, + apiKey, ...afjConfig } = restConfig @@ -336,52 +336,18 @@ export async function runRestAgent(restConfig: AriesRestConfig) { await agent.initialize() - // Add the agent context to container in tsyringe - // container.registerInstance(Agent, agent as Agent) - - let token: string = '' const genericRecord = await agent.genericRecords.getAll() + const recordsWithSecretKey = genericRecord.some((record) => record?.content?.secretKey) - const recordsWithToken = genericRecord.some((record) => record?.content?.token) - if (!genericRecord.length || !recordsWithToken) { - // Call the async function - const secretKeyInfo: string = await generateSecretKey() - // Check if the secretKey already exist in the genericRecords - - // if already exist - then don't generate the secret key again - // Check if the JWT token already available in genericRecords - if yes, and also don't generate the JWT token - // instead use the existin JWT token - // if JWT token is not found, create/generate a new token and save in genericRecords - // next time, the same token should be used - instead of creating a new token on every restart event of the agent - - // if already exist - then don't generate the secret key again - // Check if the JWT token already available in genericRecords - if yes, and also don't generate the JWT token - // instead use the existin JWT token - // if JWT token is not found, create/generate a new token and save in genericRecords - // next time, the same token should be used - instead of creating a new token on every restart event of the agent - - // Krish: Should add agent role and tenant id in case of tenants - // token = jwt.sign({ agentInfo: 'agentInfo' }, secretKeyInfo) - - // agent role set for dedicated agent and base-wallet respectively - if (!('tenants' in agent.modules)) { - token = jwt.sign({ role: AgentRole.RestRootAgent }, secretKeyInfo) - } else { - token = jwt.sign({ role: AgentRole.RestRootAgentWithTenants }, secretKeyInfo) - } - - // Krish: there should be no need to store the token if it is a refresh token. It's okay to save it for now and return it in the additional endpoint - console.log('--------------if---------------', token) + if (!genericRecord.length || !recordsWithSecretKey) { + // If secretKey doesn't exist in genericRecord: i.e. Agent initialized for the first time or secretKey not found + // Generate and store secret key for agent while initialization + const secretKeyInfo = await generateSecretKey() await agent.genericRecords.save({ content: { secretKey: secretKeyInfo, - token, }, }) - } else { - const recordWithToken = genericRecord.find((record) => record?.content?.token !== undefined) - token = recordWithToken?.content.token as string - console.log('--------------else---------------', token) } const app = await setupServer( @@ -390,10 +356,10 @@ export async function runRestAgent(restConfig: AriesRestConfig) { webhookUrl, port: adminPort, }, - token + apiKey ) - logger.info(`*** API Token: ${token}`) + logger.info(`*** API Key: ${apiKey}`) app.listen(adminPort, () => { logger.info(`Successfully started server on port ${adminPort}`) diff --git a/src/controllers/agent/AgentController.ts b/src/controllers/agent/AgentController.ts index f6c1a872..6df02a28 100644 --- a/src/controllers/agent/AgentController.ts +++ b/src/controllers/agent/AgentController.ts @@ -2,9 +2,13 @@ import type { AgentInfo, AgentToken } from '../types' import { Agent } from '@aries-framework/core' import { Request as Req } from 'express' +import jwt from 'jsonwebtoken' import { injectable } from 'tsyringe' -import { Controller, Delete, Get, Route, Tags, Security, Request } from 'tsoa' +import { AgentRole } from '../../enums/enum' + +// import { generateSecretKey } from 'src/utils/common.service' +import { Controller, Delete, Get, Post, Route, Tags, Security, Request } from 'tsoa' @Tags('Agent') @Route('/agent') @@ -22,37 +26,95 @@ export class AgentController extends Controller { */ @Get('/info') public async getAgentInfo(): Promise { - // const details = await this.agent.genericRecords.getAll() - const genericRecord = await this.agent.genericRecords.getAll() - const recordWithToken = genericRecord.find((record) => record?.content?.token !== undefined) - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const token = recordWithToken?.content.token as string return { label: this.agent.config.label, endpoints: this.agent.config.endpoints, isInitialized: this.agent.isInitialized, publicDid: undefined, - // token: details[0].content.token, - // token: token, } } /** * Retrieve agent token */ - @Get('/token') + @Post('/token') @Security('apiKey') public async getAgentToken(@Request() request: Req): Promise { // const details = await this.agent.genericRecords.getAll() console.log(`This is in agent token request.agent::::::`, request.agent) - const genericRecord = await request.agent.genericRecords.getAll() - console.log('genericRecord:::::', genericRecord) + // const genericRecord = await request.agent.genericRecords.getAll() + // console.log('genericRecord:::::', genericRecord) // const recordWithToken = genericRecord.find((record) => record?.content?.token !== undefined) // const token = recordWithToken?.content.token as string // return { // token: token, // } - return 'success' + let token + const genericRecords = await this.agent.genericRecords.getAll() + const secretKeyInfo = genericRecords.find((record) => record?.content?.secretKey !== undefined) + if (!secretKeyInfo) { + throw new Error('secretKeyInfo not found') + } + const secretKey = secretKeyInfo.content.secretKey as string + // const recordsWithToken = genericRecord.some((record) => record?.content?.token) + // const recordWithToken = genericRecords.find((record) => record?.content?.token !== undefined) + // const token = recordWithToken?.content.token as string + // if (!genericRecords.length || !recordWithToken) { + // // Call the async function + + // // Already get the secretKey from the genericRecords + + // // Check if the secretKey already exist in the genericRecords + + // // if already exist - then don't generate the secret key again + // // Check if the JWT token already available in genericRecords - if yes, and also don't generate the JWT token + // // instead use the existin JWT token + // // if JWT token is not found, create/generate a new token and save in genericRecords + // // next time, the same token should be used - instead of creating a new token on every restart event of the agent + + // // if already exist - then don't generate the secret key again + // // Check if the JWT token already available in genericRecords - if yes, and also don't generate the JWT token + // // instead use the existin JWT token + // // if JWT token is not found, create/generate a new token and save in genericRecords + // // next time, the same token should be used - instead of creating a new token on every restart event of the agent + + // // Krish: Should add agent role and tenant id in case of tenants + // // token = jwt.sign({ agentInfo: 'agentInfo' }, secretKeyInfo) + + // // agent role set for dedicated agent and base-wallet respectively + // if (!('tenants' in this.agent.modules)) { + // token = jwt.sign({ role: AgentRole.RestRootAgent }, secretKey) + // } else { + // token = jwt.sign({ role: AgentRole.RestRootAgentWithTenants }, secretKey) + // } + + // // Krish: there should be no need to store the token if it is a refresh token. It's okay to save it for now and return it in the additional endpoint + // console.log('--------------if---------------', token) + // await this.agent.genericRecords.save({ + // content: { + // // apiKey, + // // secretKey: secretKeyInfo, + // token, + // }, + // }) + // } else { + // // const recordWithToken = genericRecords.find((record) => record?.content?.token !== undefined) + // if (!('tenants' in this.agent.modules)) { + // token = jwt.sign({ role: AgentRole.RestRootAgent }, secretKey) + // } else { + // token = jwt.sign({ role: AgentRole.RestRootAgentWithTenants }, secretKey) + // } + // token = recordWithToken?.content.token as string + // console.log('--------------else---------------', token) + // } + if (!('tenants' in this.agent.modules)) { + token = jwt.sign({ role: AgentRole.RestRootAgent }, secretKey) + } else { + token = jwt.sign({ role: AgentRole.RestRootAgentWithTenants }, secretKey) + } + return { + token: token, + } } /** diff --git a/src/routes/routes.ts b/src/routes/routes.ts index 4bbd4a5d..8937bc09 100644 --- a/src/routes/routes.ts +++ b/src/routes/routes.ts @@ -803,7 +803,7 @@ export function RegisterRoutes(app: Router) { } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/agent/token', + app.post('/agent/token', authenticateMiddleware([{"apiKey":[]}]), ...(fetchMiddlewares(AgentController)), ...(fetchMiddlewares(AgentController.prototype.getAgentToken)), diff --git a/src/routes/swagger.json b/src/routes/swagger.json index eedceb0d..8c8e4e31 100644 --- a/src/routes/swagger.json +++ b/src/routes/swagger.json @@ -1793,7 +1793,7 @@ } }, "/agent/token": { - "get": { + "post": { "operationId": "GetAgentToken", "responses": { "200": { From 173df30deb44ebb9478aaf53433dd297efd1ae8f Mon Sep 17 00:00:00 2001 From: Krishna Date: Tue, 23 Apr 2024 13:09:32 +0530 Subject: [PATCH 09/16] fix: session management and appropriate context passing for tenant agent Signed-off-by: Krishna --- src/authentication.ts | 63 +++++-- src/cliAgent.ts | 7 +- .../additional-endpoint/context.Controller.ts | 14 ++ .../multitenant.Controller.ts | 56 ++++++- src/enums/enum.ts | 4 +- src/routes/routes.ts | 67 ++++++++ src/routes/swagger.json | 129 ++++++++++++++ src/securityMiddleware.ts | 157 +++++++++--------- src/server.ts | 29 +++- 9 files changed, 417 insertions(+), 109 deletions(-) diff --git a/src/authentication.ts b/src/authentication.ts index 0c1ea4a1..5378438e 100644 --- a/src/authentication.ts +++ b/src/authentication.ts @@ -1,10 +1,10 @@ import type { RestAgentModules, RestMultiTenantAgentModules } from './cliAgent' -import type { Agent } from '@aries-framework/core' import type { TenantAgent } from '@aries-framework/tenants/build/TenantAgent' import type { Request } from 'express' -import { LogLevel } from '@aries-framework/core' +import { Agent, LogLevel } from '@aries-framework/core' import jwt, { decode } from 'jsonwebtoken' +import { container } from 'tsyringe' import { AgentRole } from './enums/enum' import { TsLogger } from './utils/logger' @@ -17,19 +17,41 @@ export async function expressAuthentication( request: Request, securityName: string, secMethod?: { [key: string]: any }, - scopes?: string, + scopes?: string // eslint-disable-next-line @typescript-eslint/no-unused-vars - agent?: Agent + // agent?: Agent ): Promise | Agent | TenantAgent> { try { console.log('Race: Reached in Authentication') const logger = new TsLogger(LogLevel.info) - // const agent = container.resolve(Agent) + const agent = container.resolve(Agent) logger.info(`secMethod::: ${JSON.stringify(secMethod)}`) logger.info(`scopes::: ${JSON.stringify(scopes)}`) logger.info(`scopes::: ${JSON.stringify(scopes)}`) + const routePath = request.path + const requestMethod = request.method + + // List of paths for which authentication should be skipped + const pathsToSkipAuthentication = [ + { path: '/url/', method: 'GET' }, + { path: '/multi-tenancy/url/', method: 'GET' }, + { path: '/agent', method: 'GET' }, + ] + + const skipAuthentication = pathsToSkipAuthentication.some( + ({ path, method }) => routePath.includes(path) && requestMethod === method + ) + + if (skipAuthentication) { + // Skip authentication for this route or controller + console.log('Skipped authentication') + // for skipped authentication there are two ways to handle + request['agent'] = agent + return true + } + const apiKeyHeader = request.headers['authorization'] if (!apiKeyHeader) { @@ -44,6 +66,7 @@ export async function expressAuthentication( const providedApiKey = apiKeyHeader as string if (providedApiKey === dynamicApiKey) { + request['agent'] = agent return true } } @@ -58,18 +81,19 @@ export async function expressAuthentication( const role: AgentRole = decodedToken.role if (tenancy) { - // const rootAgent = container.resolve(Agent) // it should be a shared agent - if (role !== AgentRole.RestRootAgentWithTenants && role !== AgentRole.TenantAgent) { + if (role !== AgentRole.RestRootAgentWithTenants && role !== AgentRole.RestTenantAgent) { return false //'The agent is a multi-tenant agent' } - if (role === AgentRole.TenantAgent) { + if (role === AgentRole.RestTenantAgent) { // Logic if the token is of tenant agent + console.log('Reached here in [expressAuthentication] in role === AgentRole.RestTenantAgent') if (reqPath.includes('/multi-tenant/')) { return false //'Tenants cannot manage tenants' } else { // Auth: tenant agent + console.log('This is agent in tenantAgent:::::', agent) const tenantId: string = decodedToken.tenantId if (!tenantId) return false const tenantAgent = await getTenantAgent(agent!, tenantId) @@ -81,9 +105,10 @@ export async function expressAuthentication( if (!verified) return false // Only need to registerInstance for TenantAgent. - // req['user'] = { agent: tenantAgent } - // return { req } - return tenantAgent + // return tenantAgent + request['agent'] = tenantAgent + console.log('This is agent in request["agent"]:::::', request['agent']) + return true } } else if (role === AgentRole.RestRootAgentWithTenants) { // Auth: base wallet @@ -98,6 +123,7 @@ export async function expressAuthentication( // req['user'] = { agent: agent } // return { req } console.log('verified in authentication for BW') + request['agent'] = agent return true } else { return false //'Invalid Token' @@ -116,6 +142,7 @@ export async function expressAuthentication( // Can have an enum instead of 'success' string // req['user'] = { agent: agent } // return { req } + request['agent'] = agent return true } } @@ -154,12 +181,14 @@ async function getTenantAgent( tenantId: string ): Promise> { // eslint-disable-next-line @typescript-eslint/no-unused-vars - return new Promise((resolve) => { - agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - // Some logic - resolve(tenantAgent) - }) - }) + // return new Promise((resolve) => { + // agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // // Some logic + // resolve(tenantAgent) + // }) + // }) + const tenantAgent = await agent.modules.tenants.getTenantAgent({ tenantId }) + return tenantAgent } export function setDynamicApiKey(newApiKey: string) { diff --git a/src/cliAgent.ts b/src/cliAgent.ts index ff334f7f..06bdefa0 100644 --- a/src/cliAgent.ts +++ b/src/cliAgent.ts @@ -53,9 +53,9 @@ import { readFile } from 'fs/promises' // eslint-disable-next-line import/no-cycle import { setupServer } from './server' +import { generateSecretKey } from './utils/common.service' import { TsLogger } from './utils/logger' import { BCOVRIN_TEST_GENESIS } from './utils/util' -import { generateSecretKey } from './utils/common.service' export type Transports = 'ws' | 'http' export type InboundTransport = { @@ -114,11 +114,6 @@ export type RestMultiTenantAgentModules = Awaited> -// export type RestMultiTenantAgentModules = Awaited> -// type RestRootAgentWithTenantsModules = Awaited> -// type RestRootAgentModules = Awaited> -// export type RestMultiTenantAgentModules = Agent -// export type RestAgentModules = Agent const getModules = (networkConfig: [IndyVdrPoolConfig, ...IndyVdrPoolConfig[]]) => { const legacyIndyCredentialFormat = new LegacyIndyCredentialFormatService() diff --git a/src/controllers/additional-endpoint/context.Controller.ts b/src/controllers/additional-endpoint/context.Controller.ts index daf6a524..6be1cbd5 100644 --- a/src/controllers/additional-endpoint/context.Controller.ts +++ b/src/controllers/additional-endpoint/context.Controller.ts @@ -165,9 +165,12 @@ export class ContextController extends Controller { @Body() config?: Omit & RecipientKeyOption ) { try { + // const agent = request.agent as TenantAgent console.log('this is request.agent.config in [createLegacyInvitation]::::::::::', request.agent.config) let routing: Routing + console.log('reached here 1') if (config?.recipientKey) { + console.log('reached here 2') routing = { endpoints: request.agent.config.endpoints, routingKeys: [], @@ -175,12 +178,22 @@ export class ContextController extends Controller { mediatorId: undefined, } } else { + console.log('reached here 3') routing = await request.agent.mediationRecipient.getRouting({}) + // routing = await request.agent.mediationRecipient.getRouting({}) + // routing = request.agent.mediationRecipient.getRouting({}).catch((error) => { + // console.error(error) + // }) + console.log('routing ------ ', routing) } + console.log('reached here 4') + const { outOfBandRecord, invitation } = await request.agent.oob.createLegacyInvitation({ ...config, routing, }) + + console.log('reached here 5') return { invitationUrl: invitation.toUrl({ domain: request.agent.config.endpoints[0], @@ -192,6 +205,7 @@ export class ContextController extends Controller { outOfBandRecord: outOfBandRecord.toJSON(), ...(config?.recipientKey ? {} : { recipientKey: routing.recipientKey.publicKeyBase58 }), } + console.log('reached here 6') } catch (error) { return internalServerError(500, { message: `something went wrong: ${error}` }) } diff --git a/src/controllers/additional-endpoint/multitenant.Controller.ts b/src/controllers/additional-endpoint/multitenant.Controller.ts index 2db71e8f..5170b1f6 100644 --- a/src/controllers/additional-endpoint/multitenant.Controller.ts +++ b/src/controllers/additional-endpoint/multitenant.Controller.ts @@ -2,7 +2,7 @@ import type { RestMultiTenantAgentModules } from '../../cliAgent' import type { Agent } from '@aries-framework/core' import type { TenantRecord } from '@aries-framework/tenants' -import { RecordNotFoundError, injectable } from '@aries-framework/core' +import { JsonTransformer, RecordNotFoundError, injectable } from '@aries-framework/core' import { Request as Req } from 'express' import jwt from 'jsonwebtoken' @@ -11,7 +11,7 @@ import { generateSecretKey } from '../../utils/common.service' import { CreateTenantOptions } from '../types' // import { AgentRole } from 'src/enums/enum' -import { Body, Controller, Post, Request, Res, Route, Security, Tags, TsoaResponse } from 'tsoa' +import { Body, Controller, Get, Path, Post, Request, Res, Route, Security, Tags, TsoaResponse } from 'tsoa' @Tags('Multi Tenant') @Security('jwt') @@ -59,12 +59,62 @@ export class MultiTenantController extends Controller { } } + @Security('apiKey') + @Get(':tenantId') + public async getTenantById( + @Request() request: Req, + @Path('tenantId') tenantId: string, + @Res() notFoundError: TsoaResponse<404, { reason: string }>, + @Res() internalServerError: TsoaResponse<500, { message: string }> + ) { + try { + const agent = request.agent as unknown as Agent + const getTenant = await agent.modules.tenants.getTenantById(tenantId) + return JsonTransformer.toJSON(getTenant) + } catch (error) { + if (error instanceof RecordNotFoundError) { + return notFoundError(404, { + reason: `Tenant with id: ${tenantId} not found.`, + }) + } + return internalServerError(500, { message: `Something went wrong: ${error}` }) + } + } + + @Security('jwt') + @Post('/connection-invitation/') + public async createInvitation( + @Request() request: Req, + @Res() notFoundError: TsoaResponse<404, { reason: string }>, + @Res() internalServerError: TsoaResponse<500, { message: string }> + ) { + try { + // let outOfBandRecord: OutOfBandRecord | undefined + // const agent = request.agent as unknown as Agent + // const tenantId = '5f8ba896-15c9-4db0-89a7-7eb2aa709613' + console.log('This is request.agent', request.agent) + console.log('reached here 12') + // await agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // outOfBandRecord = await tenantAgent.oob.createInvitation() + // }) + const outOfBandRecord = await request.agent.oob.createInvitation() + return outOfBandRecord + } catch (error) { + if (error instanceof RecordNotFoundError) { + return notFoundError(404, { + reason: `Tenant not found.`, + }) + } + return internalServerError(500, { message: `Something went wrong: ${error}` }) + } + } + private async createToken(agent: Agent, tenantId: string) { const secretKey = await generateSecretKey() // const genericRecord = await this.agent.genericRecords.getAll() // const records = genericRecord.find((record) => record?.content?.secretKey !== undefined) // const secretKey = records?.content.secretKey as string - const token = jwt.sign({ role: AgentRole.TenantAgent, tenantId }, secretKey) + const token = jwt.sign({ role: AgentRole.RestTenantAgent, tenantId }, secretKey) // Save token to individual tenants generic records await this.saveTokenAndSecretKey(agent, token, secretKey, tenantId) return token diff --git a/src/enums/enum.ts b/src/enums/enum.ts index 8672c946..f09c4d42 100644 --- a/src/enums/enum.ts +++ b/src/enums/enum.ts @@ -23,7 +23,7 @@ export enum Network { } export enum AgentRole { - RestRootAgentWithTenants = 'RestRootAgentWithTenants', // Basewallet // Better name: RestRootRestRootAgentWithTenantss + RestRootAgentWithTenants = 'RestRootAgentWithTenants', // Basewallet // Better name: RestRootRestRootAgentWithTenants RestRootAgent = 'RestRootAgent', // Dedicated // Better name: RestRootAgent - TenantAgent = 'TenantAgent', // Tenant // Better name: RestTenantAgent + RestTenantAgent = 'RestTenantAgent', // Tenant // Better name: RestTenantAgent } diff --git a/src/routes/routes.ts b/src/routes/routes.ts index 8937bc09..2ec33350 100644 --- a/src/routes/routes.ts +++ b/src/routes/routes.ts @@ -3879,6 +3879,73 @@ export function RegisterRoutes(app: Router) { } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + app.get('/test-endpoint/multi-tenant/:tenantId', + authenticateMiddleware([{"apiKey":[]}]), + ...(fetchMiddlewares(MultiTenantController)), + ...(fetchMiddlewares(MultiTenantController.prototype.getTenantById)), + + async function MultiTenantController_getTenantById(request: any, response: any, next: any) { + const args = { + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, + notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, + internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, + }; + + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + + let validatedArgs: any[] = []; + try { + validatedArgs = getValidatedArgs(args, request, response); + + const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; + + const controller: any = await container.get(MultiTenantController); + if (typeof controller['setStatus'] === 'function') { + controller.setStatus(undefined); + } + + + const promise = controller.getTenantById.apply(controller, validatedArgs as any); + promiseHandler(controller, promise, response, undefined, next); + } catch (err) { + return next(err); + } + }); + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + app.post('/test-endpoint/multi-tenant/connection-invitation', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(MultiTenantController)), + ...(fetchMiddlewares(MultiTenantController.prototype.createInvitation)), + + async function MultiTenantController_createInvitation(request: any, response: any, next: any) { + const args = { + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, + internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, + }; + + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + + let validatedArgs: any[] = []; + try { + validatedArgs = getValidatedArgs(args, request, response); + + const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; + + const controller: any = await container.get(MultiTenantController); + if (typeof controller['setStatus'] === 'function') { + controller.setStatus(undefined); + } + + + const promise = controller.createInvitation.apply(controller, validatedArgs as any); + promiseHandler(controller, promise, response, undefined, next); + } catch (err) { + return next(err); + } + }); + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.post('/test-endpoint/create-legacy-invitation', authenticateMiddleware([{"jwt":[]}]), ...(fetchMiddlewares(ContextController)), diff --git a/src/routes/swagger.json b/src/routes/swagger.json index 8c8e4e31..9d69d08d 100644 --- a/src/routes/swagger.json +++ b/src/routes/swagger.json @@ -9231,6 +9231,135 @@ } } }, + "/test-endpoint/multi-tenant/{tenantId}": { + "get": { + "operationId": "GetTenantById", + "responses": { + "200": { + "description": "Ok", + "content": { + "application/json": { + "schema": {} + } + } + }, + "404": { + "description": "", + "content": { + "application/json": { + "schema": { + "properties": { + "reason": { + "type": "string" + } + }, + "required": [ + "reason" + ], + "type": "object" + } + } + } + }, + "500": { + "description": "", + "content": { + "application/json": { + "schema": { + "properties": { + "message": { + "type": "string" + } + }, + "required": [ + "message" + ], + "type": "object" + } + } + } + } + }, + "tags": [ + "Multi Tenant" + ], + "security": [ + { + "apiKey": [] + } + ], + "parameters": [ + { + "in": "path", + "name": "tenantId", + "required": true, + "schema": { + "type": "string" + } + } + ] + } + }, + "/test-endpoint/multi-tenant/connection-invitation": { + "post": { + "operationId": "CreateInvitation", + "responses": { + "200": { + "description": "Ok", + "content": { + "application/json": { + "schema": {} + } + } + }, + "404": { + "description": "", + "content": { + "application/json": { + "schema": { + "properties": { + "reason": { + "type": "string" + } + }, + "required": [ + "reason" + ], + "type": "object" + } + } + } + }, + "500": { + "description": "", + "content": { + "application/json": { + "schema": { + "properties": { + "message": { + "type": "string" + } + }, + "required": [ + "message" + ], + "type": "object" + } + } + } + } + }, + "tags": [ + "Multi Tenant" + ], + "security": [ + { + "jwt": [] + } + ], + "parameters": [] + } + }, "/test-endpoint/create-legacy-invitation": { "post": { "operationId": "CreateLegacyInvitation", diff --git a/src/securityMiddleware.ts b/src/securityMiddleware.ts index e4b9136c..9f3daa9d 100644 --- a/src/securityMiddleware.ts +++ b/src/securityMiddleware.ts @@ -1,97 +1,96 @@ -import type { RestMultiTenantAgentModules } from './cliAgent' import type * as express from 'express' import type { NextFunction } from 'express' // eslint-disable-next-line import/order -import { Agent } from '@aries-framework/core' // eslint-disable-next-line import/order import { Middlewares } from '@tsoa/runtime' // eslint-disable-next-line import/namespace -import { container } from 'tsyringe' - -import { expressAuthentication } from './authentication' // Import your authentication function - @Middlewares() export class SecurityMiddleware { - public async use(request: express.Request, response: express.Response, next: NextFunction) { - console.log('Race: Reached in Middleware') - // public async use(request: express.Request, response: express.Response) { - // try { + // public async use(request: express.Request, response: express.Response, next: NextFunction) { + // console.log('Race: Reached in Middleware') + // // public async use(request: express.Request, response: express.Response) { + // // try { - const agent = container.resolve(Agent) - let securityName = 'jwt' + // const agent = container.resolve(Agent) + // let securityName = 'jwt' - // Extract route path or controller name from the request - const routePath = request.path - const requestMethod = request.method + // // Extract route path or controller name from the request + // const routePath = request.path + // const requestMethod = request.method - // List of paths for which authentication should be skipped - const pathsToSkipAuthentication = [ - { path: '/url/', method: 'GET' }, - { path: '/multi-tenancy/url/', method: 'GET' }, - { path: '/agent', method: 'GET' }, - ] + // // List of paths for which authentication should be skipped + // const pathsToSkipAuthentication = [ + // { path: '/url/', method: 'GET' }, + // { path: '/multi-tenancy/url/', method: 'GET' }, + // { path: '/agent', method: 'GET' }, + // ] - // Check if authentication should be skipped for this route or controller - const skipAuthentication = pathsToSkipAuthentication.some( - ({ path, method }) => routePath.includes(path) && requestMethod === method - ) - // Krish: here test endpoints will be replaced by all enpoints except 'pathsToSkipAuthentication' - if (routePath.includes('/agent/token')) { - securityName = 'apiKey' - console.log('Reached in securityMiddleware::::: /test-endpoint/') - // const result = await expressAuthentication(request, securityName); - } + // // Check if authentication should be skipped for this route or controller + // const skipAuthentication = pathsToSkipAuthentication.some( + // ({ path, method }) => routePath.includes(path) && requestMethod === method + // ) + // // Krish: here test endpoints will be replaced by all enpoints except 'pathsToSkipAuthentication' + // if (routePath.includes('/agent/token')) { + // securityName = 'apiKey' + // console.log('Reached in securityMiddleware::::: /test-endpoint/') + // // const result = await expressAuthentication(request, securityName); + // } - if (skipAuthentication) { - // Skip authentication for this route or controller - console.log('Skipped authentication') - // for skipped authentication there are two ways to handle - request['agent'] = agent - next() - // const agent = container.resolve(Agent) - // return Promise.resolve({ agent: agent }) - } else if (securityName) { - const result = await expressAuthentication(request, securityName, undefined, undefined, agent) - console.log('Result:::::', result) - if (typeof result === 'boolean') { - console.log('Successfully resulted') - if (result) { - // Auth: for BW/Dedicated agent - // Validation for api-key - // request.user = { agent: agent } - request['agent'] = agent - next() - } else response.status(401).json({ message: `Unauthorized` }) - // } else return Promise.reject(new StatusException('Unauthorized', 401)) - } else if (!result) { - response.status(401).json({ message: `Unauthorized` }) - // return Promise.reject(new StatusException('Unauthorized', 401)) - } else if (result.wallet) { - console.log('this is type of result', result) - console.log('From securityMiddleware:::::::::') - // return Promise.resolve({ agent: result }) - // return result - // const temp = request.user - // temp['agent'] = result - // request.user = temp - request['agent'] = result - // request.user['agent'] = result - console.log('verified agent from middleware') - console.log('this is request in middleware::::::', request) - console.log(`this is request.agent`, request.agent) - // console.log(`this is request.user.agent`, request.user) - console.log(`this is request.agent.config`, request.agent.config) - next() - } - } else { - response.status(400).json({ message: 'Bad Request' }) - // return Promise.reject(new StatusException('Bad Request', 400)) - } - // } catch (error) { - // next(error) - // } + // if (skipAuthentication) { + // // Skip authentication for this route or controller + // console.log('Skipped authentication') + // // for skipped authentication there are two ways to handle + // request['agent'] = agent + // next() + // // const agent = container.resolve(Agent) + // // return Promise.resolve({ agent: agent }) + // } else if (securityName) { + // const result = await expressAuthentication(request, securityName, undefined, undefined, agent) + // console.log('Result:::::', result) + // if (typeof result === 'boolean') { + // console.log('Successfully resulted') + // if (result) { + // // Auth: for BW/Dedicated agent + // // Validation for api-key + // // request.user = { agent: agent } + // request['agent'] = agent + // next() + // } else response.status(401).json({ message: `Unauthorized` }) + // // } else return Promise.reject(new StatusException('Unauthorized', 401)) + // } else if (!result) { + // response.status(401).json({ message: `Unauthorized` }) + // // return Promise.reject(new StatusException('Unauthorized', 401)) + // } else if (result.wallet) { + // console.log('this is type of result', result) + // console.log('From securityMiddleware:::::::::') + // // return Promise.resolve({ agent: result }) + // // return result + // // const temp = request.user + // // temp['agent'] = result + // // request.user = temp + // request['agent'] = result + // // request.user['agent'] = result + // console.log('verified agent from middleware') + // console.log('this is request in middleware::::::', request) + // console.log(`this is request.agent`, request.agent) + // // console.log(`this is request.user.agent`, request.user) + // console.log(`this is request.agent.config`, request.agent.config) + // next() + // } + // } else { + // response.status(400).json({ message: 'Bad Request' }) + // // return Promise.reject(new StatusException('Bad Request', 400)) + // } + // // } catch (error) { + // // next(error) + // // } + // } + // eslint-disable-next-line @typescript-eslint/no-unused-vars + public async use(request: express.Request, response: express.Response, next: NextFunction) { + // Do nothing + next() } } diff --git a/src/server.ts b/src/server.ts index 6658ac41..4298adc6 100644 --- a/src/server.ts +++ b/src/server.ts @@ -1,9 +1,10 @@ import 'reflect-metadata' import type { RestAgentModules, RestMultiTenantAgentModules } from './cliAgent' import type { ServerConfig } from './utils/ServerConfig' -import type { Response as ExResponse, Request as ExRequest, NextFunction, Request, Response } from 'express' +import type { Response as ExResponse, Request as ExRequest, NextFunction } from 'express' import { Agent } from '@aries-framework/core' +import { TenantAgent } from '@aries-framework/tenants/build/TenantAgent' import bodyParser from 'body-parser' import cors from 'cors' import express from 'express' @@ -78,6 +79,12 @@ export const setupServer = async ( app.use(securityMiddleware.use) RegisterRoutes(app) + app.use(async (req, _, next) => { + // End tenant session if active + await endTenantSessionIfActive(req) + next() + }) + app.use((req, res, next) => { if (req.url == '/') { res.redirect('/docs') @@ -86,7 +93,15 @@ export const setupServer = async ( next() }) - app.use(function errorHandler(err: unknown, req: ExRequest, res: ExResponse, next: NextFunction): ExResponse | void { + app.use(async function errorHandler( + err: unknown, + req: ExRequest, + res: ExResponse, + next: NextFunction + ): Promise { + // End tenant session if active + await endTenantSessionIfActive(req) + if (err instanceof ValidateError) { agent.config.logger.warn(`Caught Validation Error for ${req.path}:`, err.fields) return res.status(422).json({ @@ -120,3 +135,13 @@ export const setupServer = async ( return app } + +async function endTenantSessionIfActive(request: ExRequest) { + if ('agent' in request) { + const agent = request?.agent + if (agent instanceof TenantAgent) { + agent.config.logger.debug('Ending tenant session') + await agent.endSession() + } + } +} From 48f12b6eda001914ab31d3d5653fed5f282ecc2f Mon Sep 17 00:00:00 2001 From: Krishna Date: Wed, 24 Apr 2024 15:55:18 +0530 Subject: [PATCH 10/16] add: error handling Signed-off-by: Krishna --- src/authentication.ts | 247 ++++++++++++----------- src/controllers/agent/AgentController.ts | 34 ++-- src/enums/enum.ts | 10 +- src/routes/routes.ts | 5 +- src/routes/swagger.json | 17 +- src/server.ts | 41 ++-- 6 files changed, 195 insertions(+), 159 deletions(-) diff --git a/src/authentication.ts b/src/authentication.ts index 5378438e..24b29382 100644 --- a/src/authentication.ts +++ b/src/authentication.ts @@ -6,7 +6,8 @@ import { Agent, LogLevel } from '@aries-framework/core' import jwt, { decode } from 'jsonwebtoken' import { container } from 'tsyringe' -import { AgentRole } from './enums/enum' +import { AgentRole, ErrorMessages } from './enums/enum' +import { StatusException } from './error' import { TsLogger } from './utils/logger' // export type AgentType = Agent | Agent | TenantAgent @@ -20,145 +21,153 @@ export async function expressAuthentication( scopes?: string // eslint-disable-next-line @typescript-eslint/no-unused-vars // agent?: Agent -): Promise | Agent | TenantAgent> { - try { - console.log('Race: Reached in Authentication') - const logger = new TsLogger(LogLevel.info) - const agent = container.resolve(Agent) - - logger.info(`secMethod::: ${JSON.stringify(secMethod)}`) - logger.info(`scopes::: ${JSON.stringify(scopes)}`) - logger.info(`scopes::: ${JSON.stringify(scopes)}`) - - const routePath = request.path - const requestMethod = request.method - - // List of paths for which authentication should be skipped - const pathsToSkipAuthentication = [ - { path: '/url/', method: 'GET' }, - { path: '/multi-tenancy/url/', method: 'GET' }, - { path: '/agent', method: 'GET' }, - ] - - const skipAuthentication = pathsToSkipAuthentication.some( - ({ path, method }) => routePath.includes(path) && requestMethod === method - ) - - if (skipAuthentication) { - // Skip authentication for this route or controller - console.log('Skipped authentication') - // for skipped authentication there are two ways to handle - request['agent'] = agent - return true - } - - const apiKeyHeader = request.headers['authorization'] +) { + const logger = new TsLogger(LogLevel.info) + const agent = container.resolve(Agent) + + logger.info(`secMethod::: ${JSON.stringify(secMethod)}`) + logger.info(`securityName::: ${JSON.stringify(securityName)}`) + logger.info(`scopes::: ${JSON.stringify(scopes)}`) + + const routePath = request.path + const requestMethod = request.method + + // List of paths for which authentication should be skipped + const pathsToSkipAuthentication = [ + // { path: '/url/', method: 'GET' }, + { path: '/multi-tenancy/url/', method: 'GET' }, + // { path: '/agent', method: 'GET' }, + ] + + const skipAuthentication = pathsToSkipAuthentication.some( + ({ path, method }) => routePath.includes(path) && requestMethod === method + ) + + if (skipAuthentication || secMethod?.includes('skip')) { + // Skip authentication for this route or controller + // for skipped authentication there are two ways to handle + request['agent'] = agent + return true + } - if (!apiKeyHeader) { - return false - } + const apiKeyHeader = request.headers['authorization'] - // add additional logic to get the token from wallet for validating the passed + if (!apiKeyHeader) { + // return false + return Promise.reject(new StatusException(ErrorMessages.Unauthorized, 401)) + } - if (securityName === 'apiKey') { - // Auth: For BW/Dedicated agent to GET their token - if (apiKeyHeader) { - const providedApiKey = apiKeyHeader as string + // add additional logic to get the token from wallet for validating the passed - if (providedApiKey === dynamicApiKey) { - request['agent'] = agent - return true - } + if (securityName === 'apiKey') { + // Auth: For BW/Dedicated agent to GET their token + if (apiKeyHeader) { + const providedApiKey = apiKeyHeader as string + if (providedApiKey === dynamicApiKey) { + request['agent'] = agent + return true } } + } - if (securityName === 'jwt') { - const tenancy = agent!.modules.tenants ? true : false - const tokenWithHeader = apiKeyHeader - const token = tokenWithHeader.replace('Bearer ', '') - const reqPath = request.path - const decodedToken: jwt.JwtPayload = decode(token) as jwt.JwtPayload - const role: AgentRole = decodedToken.role - - if (tenancy) { - // it should be a shared agent - if (role !== AgentRole.RestRootAgentWithTenants && role !== AgentRole.RestTenantAgent) { - return false //'The agent is a multi-tenant agent' - } + if (securityName === 'jwt') { + const tenancy = agent!.modules.tenants ? true : false + const tokenWithHeader = apiKeyHeader + const token = tokenWithHeader!.replace('Bearer ', '') + const reqPath = request.path + const decodedToken: jwt.JwtPayload = decode(token) as jwt.JwtPayload + const role: AgentRole = decodedToken.role + + if (tenancy) { + // it should be a shared agent + if (role !== AgentRole.RestRootAgentWithTenants && role !== AgentRole.RestTenantAgent) { + // return false //'The agent is a multi-tenant agent' + logger.debug('Unknown role. The agent is a multi-tenant agent') + return Promise.reject(new StatusException('Unknown role', 401)) + } + if (role === AgentRole.RestTenantAgent) { + // Logic if the token is of tenant agent + if (reqPath.includes('/multi-tenant/')) { + // return false //'Tenants cannot manage tenants' + logger.debug('Tenants cannot manage tenants') + return Promise.reject(new StatusException(ErrorMessages.Unauthorized, 401)) + } else { + // Auth: tenant agent + const tenantId: string = decodedToken.tenantId + if (!tenantId) { + // return false + return Promise.reject(new StatusException(ErrorMessages.Unauthorized, 401)) + } + const tenantAgent = await getTenantAgent(agent!, tenantId) + if (!tenantAgent) { + // return false + return Promise.reject(new StatusException(ErrorMessages.Unauthorized, 401)) + } + + const verified = await verifyToken(tenantAgent, token) - if (role === AgentRole.RestTenantAgent) { - // Logic if the token is of tenant agent - console.log('Reached here in [expressAuthentication] in role === AgentRole.RestTenantAgent') - if (reqPath.includes('/multi-tenant/')) { - return false //'Tenants cannot manage tenants' - } else { - // Auth: tenant agent - console.log('This is agent in tenantAgent:::::', agent) - const tenantId: string = decodedToken.tenantId - if (!tenantId) return false - const tenantAgent = await getTenantAgent(agent!, tenantId) - if (!tenantAgent) return false - - const verified = await verifyToken(tenantAgent, token) - - // Failed to verify token - if (!verified) return false - - // Only need to registerInstance for TenantAgent. - // return tenantAgent - request['agent'] = tenantAgent - console.log('This is agent in request["agent"]:::::', request['agent']) - return true + // Failed to verify token + if (!verified) { + // return false + return Promise.reject(new StatusException(ErrorMessages.Unauthorized, 401)) } - } else if (role === AgentRole.RestRootAgentWithTenants) { - // Auth: base wallet - const verified = await verifyToken(agent!, token) - - // Base wallet cant access any endpoints apart from multi-tenant endpoint - // if (!reqPath.includes('/multi-tenant/') && !reqPath.includes('/multi-tenancy/')) - // return 'Basewallet can only manage tenants and can`t perform other operations' - if (!verified) return false - - // req['user'] = {agent} - // req['user'] = { agent: agent } - // return { req } - console.log('verified in authentication for BW') - request['agent'] = agent + + // Only need to registerInstance for TenantAgent. + // return tenantAgent + request['agent'] = tenantAgent return true - } else { - return false //'Invalid Token' } + } else if (role === AgentRole.RestRootAgentWithTenants) { + // Auth: base wallet + const verified = await verifyToken(agent!, token) + + // Base wallet cant access any endpoints apart from multi-tenant endpoint + // if (!reqPath.includes('/multi-tenant/') && !reqPath.includes('/multi-tenancy/')) + // return 'Basewallet can only manage tenants and can`t perform other operations' + if (!verified) return Promise.reject(new StatusException(ErrorMessages.Unauthorized, 401)) + + request['agent'] = agent + return true } else { - if (role !== AgentRole.RestRootAgent) { - return false //'This is a dedicated agent' - } else { - // Auth: dedicated agent + // return false //'Invalid Token' + logger.debug('Invalid Token') + return Promise.reject(new StatusException(ErrorMessages.Unauthorized, 401)) + } + } else { + if (role !== AgentRole.RestRootAgent) { + logger.debug('This is a dedicated agent') + return Promise.reject(new StatusException(ErrorMessages.Unauthorized, 401)) + // return false //'This is a dedicated agent' + } else { + // Auth: dedicated agent - if (reqPath.includes('/multi-tenant/')) return false + if (reqPath.includes('/multi-tenant/')) return false - const verified = await verifyToken(agent!, token) - if (!verified) return false + const verified = await verifyToken(agent!, token) + if (!verified) return false - // Can have an enum instead of 'success' string - // req['user'] = { agent: agent } - // return { req } - request['agent'] = agent - return true - } + // Can have an enum instead of 'success' string + // req['user'] = { agent: agent } + // return { req } + request['agent'] = agent + return true } } - return false - } catch (error) { - const logger = new TsLogger(LogLevel.error) - if (error instanceof Error) { - logger.error('Error in Authentication', error) - } - return false } + // return false + return Promise.reject(new StatusException(ErrorMessages.Unauthorized, 401)) + // } catch (error) { + // const logger = new TsLogger(LogLevel.error) + // if (error instanceof Error) { + // console.log('log 8.0') + // logger.error('Error in Authentication', error) + // response?.status(401) + // } + // return false + // } } async function verifyToken(agent: Agent | TenantAgent, token: string): Promise { - // try { const secretKey = await getSecretKey(agent) const verified = jwt.verify(token, secretKey) diff --git a/src/controllers/agent/AgentController.ts b/src/controllers/agent/AgentController.ts index 6df02a28..5d118be7 100644 --- a/src/controllers/agent/AgentController.ts +++ b/src/controllers/agent/AgentController.ts @@ -1,6 +1,5 @@ import type { AgentInfo, AgentToken } from '../types' -import { Agent } from '@aries-framework/core' import { Request as Req } from 'express' import jwt from 'jsonwebtoken' import { injectable } from 'tsyringe' @@ -13,23 +12,25 @@ import { Controller, Delete, Get, Post, Route, Tags, Security, Request } from 't @Tags('Agent') @Route('/agent') @injectable() +// @Security('jwt') export class AgentController extends Controller { - private agent: Agent + // private agent: Agent - public constructor(agent: Agent) { - super() - this.agent = agent - } + // public constructor(agent: Agent) { + // super() + // this.agent = agent + // } /** * Retrieve basic agent information */ + @Security('jwt') @Get('/info') - public async getAgentInfo(): Promise { + public async getAgentInfo(@Request() request: Req): Promise { return { - label: this.agent.config.label, - endpoints: this.agent.config.endpoints, - isInitialized: this.agent.isInitialized, + label: request.agent.config.label, + endpoints: request.agent.config.endpoints, + isInitialized: request.agent.isInitialized, publicDid: undefined, } } @@ -40,8 +41,7 @@ export class AgentController extends Controller { @Post('/token') @Security('apiKey') public async getAgentToken(@Request() request: Req): Promise { - // const details = await this.agent.genericRecords.getAll() - console.log(`This is in agent token request.agent::::::`, request.agent) + // const details = await request.agent.genericRecords.getAll() // const genericRecord = await request.agent.genericRecords.getAll() // console.log('genericRecord:::::', genericRecord) // const recordWithToken = genericRecord.find((record) => record?.content?.token !== undefined) @@ -50,7 +50,7 @@ export class AgentController extends Controller { // token: token, // } let token - const genericRecords = await this.agent.genericRecords.getAll() + const genericRecords = await request.agent.genericRecords.getAll() const secretKeyInfo = genericRecords.find((record) => record?.content?.secretKey !== undefined) if (!secretKeyInfo) { throw new Error('secretKeyInfo not found') @@ -107,7 +107,7 @@ export class AgentController extends Controller { // token = recordWithToken?.content.token as string // console.log('--------------else---------------', token) // } - if (!('tenants' in this.agent.modules)) { + if (!('tenants' in request.agent.modules)) { token = jwt.sign({ role: AgentRole.RestRootAgent }, secretKey) } else { token = jwt.sign({ role: AgentRole.RestRootAgentWithTenants }, secretKey) @@ -120,10 +120,10 @@ export class AgentController extends Controller { /** * Delete wallet */ - @Security('apiKey') @Delete('/wallet') - public async deleteWallet() { - const deleteWallet = await this.agent.wallet.delete() + @Security('jwt') + public async deleteWallet(@Request() request: Req) { + const deleteWallet = await request.agent.wallet.delete() return deleteWallet } } diff --git a/src/enums/enum.ts b/src/enums/enum.ts index f09c4d42..9ca19fdc 100644 --- a/src/enums/enum.ts +++ b/src/enums/enum.ts @@ -23,7 +23,11 @@ export enum Network { } export enum AgentRole { - RestRootAgentWithTenants = 'RestRootAgentWithTenants', // Basewallet // Better name: RestRootRestRootAgentWithTenants - RestRootAgent = 'RestRootAgent', // Dedicated // Better name: RestRootAgent - RestTenantAgent = 'RestTenantAgent', // Tenant // Better name: RestTenantAgent + RestRootAgentWithTenants = 'RestRootAgentWithTenants', + RestRootAgent = 'RestRootAgent', + RestTenantAgent = 'RestTenantAgent', +} + +export enum ErrorMessages { + Unauthorized = 'Unauthorized', } diff --git a/src/routes/routes.ts b/src/routes/routes.ts index 2ec33350..4831b8e2 100644 --- a/src/routes/routes.ts +++ b/src/routes/routes.ts @@ -775,11 +775,13 @@ export function RegisterRoutes(app: Router) { // Please look into the "controllerPathGlobs" config option described in the readme: https://github.com/lukeautry/tsoa // ########################################################################################################### app.get('/agent/info', + authenticateMiddleware([{"jwt":[]}]), ...(fetchMiddlewares(AgentController)), ...(fetchMiddlewares(AgentController.prototype.getAgentInfo)), async function AgentController_getAgentInfo(request: any, response: any, next: any) { const args = { + request: {"in":"request","name":"request","required":true,"dataType":"object"}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -835,12 +837,13 @@ export function RegisterRoutes(app: Router) { }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.delete('/agent/wallet', - authenticateMiddleware([{"apiKey":[]}]), + authenticateMiddleware([{"jwt":[]}]), ...(fetchMiddlewares(AgentController)), ...(fetchMiddlewares(AgentController.prototype.deleteWallet)), async function AgentController_deleteWallet(request: any, response: any, next: any) { const args = { + request: {"in":"request","name":"request","required":true,"dataType":"object"}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa diff --git a/src/routes/swagger.json b/src/routes/swagger.json index 9d69d08d..e54bdcac 100644 --- a/src/routes/swagger.json +++ b/src/routes/swagger.json @@ -1788,7 +1788,11 @@ "tags": [ "Agent" ], - "security": [], + "security": [ + { + "jwt": [] + } + ], "parameters": [] } }, @@ -1830,8 +1834,13 @@ "delete": { "operationId": "DeleteWallet", "responses": { - "204": { - "description": "No content" + "200": { + "description": "Ok", + "content": { + "application/json": { + "schema": {} + } + } } }, "description": "Delete wallet", @@ -1840,7 +1849,7 @@ ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [] diff --git a/src/server.ts b/src/server.ts index 4298adc6..87958f19 100644 --- a/src/server.ts +++ b/src/server.ts @@ -1,5 +1,6 @@ import 'reflect-metadata' import type { RestAgentModules, RestMultiTenantAgentModules } from './cliAgent' +import type { ApiError } from './error' import type { ServerConfig } from './utils/ServerConfig' import type { Response as ExResponse, Request as ExRequest, NextFunction } from 'express' @@ -14,6 +15,7 @@ import { container } from 'tsyringe' // eslint-disable-next-line import/namespace import { setDynamicApiKey } from './authentication' +import { ErrorMessages } from './enums/enum' import { basicMessageEvents } from './events/BasicMessageEvents' import { connectionEvents } from './events/ConnectionEvents' import { credentialEvents } from './events/CredentialEvents' @@ -79,11 +81,12 @@ export const setupServer = async ( app.use(securityMiddleware.use) RegisterRoutes(app) - app.use(async (req, _, next) => { - // End tenant session if active - await endTenantSessionIfActive(req) - next() - }) + // app.use(async (req, _, next) => { + // // End tenant session if active + // console.log('Ended tenant session using app.use') + // await endTenantSessionIfActive(req) + // next() + // }) app.use((req, res, next) => { if (req.url == '/') { @@ -100,7 +103,8 @@ export const setupServer = async ( next: NextFunction ): Promise { // End tenant session if active - await endTenantSessionIfActive(req) + // console.log('Ended tenant session in [errorHandler]') + // await endTenantSessionIfActive(req) if (err instanceof ValidateError) { agent.config.logger.warn(`Caught Validation Error for ${req.path}:`, err.fields) @@ -119,6 +123,13 @@ export const setupServer = async ( }) } + if (exceptionError.status === 401) { + return res.status(401).json({ + message: `Unauthorized`, + details: err.message !== ErrorMessages.Unauthorized ? err.message : undefined, + } satisfies ApiError) + } + agent.config.logger.error('Internal Server Error.', err) return res.status(500).json({ message: 'Internal Server Error. Check server logging.', @@ -136,12 +147,12 @@ export const setupServer = async ( return app } -async function endTenantSessionIfActive(request: ExRequest) { - if ('agent' in request) { - const agent = request?.agent - if (agent instanceof TenantAgent) { - agent.config.logger.debug('Ending tenant session') - await agent.endSession() - } - } -} +// async function endTenantSessionIfActive(request: ExRequest) { +// if ('agent' in request) { +// const agent = request?.agent +// if (agent instanceof TenantAgent) { +// agent.config.logger.debug('Ending tenant session') +// await agent.endSession() +// } +// } +// } From 4c74684d8f3f4184c6b870d37ebc560465b0daab Mon Sep 17 00:00:00 2001 From: Krishna Date: Mon, 6 May 2024 12:42:03 +0530 Subject: [PATCH 11/16] fix: sync changes with dedicated agent endpoints Signed-off-by: Krishna --- src/controllers/types.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/controllers/types.ts b/src/controllers/types.ts index b43cf4ab..dbabd23e 100644 --- a/src/controllers/types.ts +++ b/src/controllers/types.ts @@ -12,7 +12,6 @@ import type { DidResolutionMetadata, DidDocumentMetadata, ProofExchangeRecord, - ProofFormat, DidRegistrationExtraOptions, DidDocument, DidRegistrationSecretOptions, @@ -267,10 +266,7 @@ export interface RequestProofOptions { // TODO: added type in protocolVersion export interface RequestProofProposalOptions { connectionId: string - proofFormats: { - formats: ProofFormat[] - action: 'createProposal' - } + proofFormats: any goalCode?: string parentThreadId?: string autoAcceptProof?: AutoAcceptProof @@ -279,10 +275,7 @@ export interface RequestProofProposalOptions { export interface AcceptProofProposal { proofRecordId: string - proofFormats: { - formats: ProofFormat[] - action: 'acceptProposal' - } + proofFormats: any comment?: string autoAcceptProof?: AutoAcceptProof goalCode?: string From a2048b373774f2608a6e2cf478e140a0003ec568 Mon Sep 17 00:00:00 2001 From: Krishna Date: Mon, 6 May 2024 15:01:27 +0530 Subject: [PATCH 12/16] add: agent context from request for all endpoints Signed-off-by: Krishna --- src/authentication.ts | 38 +- src/cliAgent.ts | 1 - .../additional-endpoint/context.Controller.ts | 14 - .../multitenant.Controller.ts | 88 +- .../basic-messages/BasicMessageController.ts | 28 +- .../connections/ConnectionController.ts | 71 +- .../credentials/CredentialController.ts | 90 +- .../CredentialDefinitionController.ts | 28 +- .../credentials/SchemaController.ts | 30 +- src/controllers/did/DidController.ts | 102 +- .../EndorserTransactionController.ts | 42 +- .../multi-tenancy/MultiTenancyController.ts | 3659 ++++---- .../outofband/OutOfBandController.ts | 65 +- src/controllers/polygon/PolygonController.ts | 29 +- src/controllers/proofs/ProofController.ts | 74 +- .../QuestionAnswerController.ts | 32 +- src/routes/routes.ts | 2595 ++---- src/routes/swagger.json | 7503 +++++------------ src/server.ts | 36 +- 19 files changed, 5327 insertions(+), 9198 deletions(-) diff --git a/src/authentication.ts b/src/authentication.ts index 24b29382..3e10109c 100644 --- a/src/authentication.ts +++ b/src/authentication.ts @@ -98,7 +98,7 @@ export async function expressAuthentication( // return false return Promise.reject(new StatusException(ErrorMessages.Unauthorized, 401)) } - const tenantAgent = await getTenantAgent(agent!, tenantId) + const tenantAgent = await agent.modules.tenants.getTenantAgent({ tenantId }) if (!tenantAgent) { // return false return Promise.reject(new StatusException(ErrorMessages.Unauthorized, 401)) @@ -122,8 +122,16 @@ export async function expressAuthentication( const verified = await verifyToken(agent!, token) // Base wallet cant access any endpoints apart from multi-tenant endpoint - // if (!reqPath.includes('/multi-tenant/') && !reqPath.includes('/multi-tenancy/')) - // return 'Basewallet can only manage tenants and can`t perform other operations' + if (!reqPath.includes('/multi-tenant/') && !reqPath.includes('/multi-tenancy/')) { + logger.error('Basewallet can only manage tenants and can`t perform other operations') + return Promise.reject(new StatusException(ErrorMessages.Unauthorized, 401)) + } + + // if (!scopes?.includes('multi-tenant')) { + // logger.error('Basewallet can only manage tenants') + // return Promise.reject(new StatusException(ErrorMessages.Unauthorized, 401)) + // } + if (!verified) return Promise.reject(new StatusException(ErrorMessages.Unauthorized, 401)) request['agent'] = agent @@ -146,9 +154,6 @@ export async function expressAuthentication( const verified = await verifyToken(agent!, token) if (!verified) return false - // Can have an enum instead of 'success' string - // req['user'] = { agent: agent } - // return { req } request['agent'] = agent return true } @@ -185,20 +190,13 @@ async function getSecretKey( return secretKey } -async function getTenantAgent( - agent: Agent, - tenantId: string -): Promise> { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - // return new Promise((resolve) => { - // agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - // // Some logic - // resolve(tenantAgent) - // }) - // }) - const tenantAgent = await agent.modules.tenants.getTenantAgent({ tenantId }) - return tenantAgent -} +// async function getTenantAgent( +// agent: Agent, +// tenantId: string +// ): Promise> { +// const tenantAgent = await agent.modules.tenants.getTenantAgent({ tenantId }) +// return tenantAgent +// } export function setDynamicApiKey(newApiKey: string) { dynamicApiKey = newApiKey diff --git a/src/cliAgent.ts b/src/cliAgent.ts index 06bdefa0..0f7495ef 100644 --- a/src/cliAgent.ts +++ b/src/cliAgent.ts @@ -114,7 +114,6 @@ export type RestMultiTenantAgentModules = Awaited> - const getModules = (networkConfig: [IndyVdrPoolConfig, ...IndyVdrPoolConfig[]]) => { const legacyIndyCredentialFormat = new LegacyIndyCredentialFormatService() const legacyIndyProofFormat = new LegacyIndyProofFormatService() diff --git a/src/controllers/additional-endpoint/context.Controller.ts b/src/controllers/additional-endpoint/context.Controller.ts index 6be1cbd5..bcf67cf2 100644 --- a/src/controllers/additional-endpoint/context.Controller.ts +++ b/src/controllers/additional-endpoint/context.Controller.ts @@ -165,12 +165,8 @@ export class ContextController extends Controller { @Body() config?: Omit & RecipientKeyOption ) { try { - // const agent = request.agent as TenantAgent - console.log('this is request.agent.config in [createLegacyInvitation]::::::::::', request.agent.config) let routing: Routing - console.log('reached here 1') if (config?.recipientKey) { - console.log('reached here 2') routing = { endpoints: request.agent.config.endpoints, routingKeys: [], @@ -178,22 +174,14 @@ export class ContextController extends Controller { mediatorId: undefined, } } else { - console.log('reached here 3') routing = await request.agent.mediationRecipient.getRouting({}) - // routing = await request.agent.mediationRecipient.getRouting({}) - // routing = request.agent.mediationRecipient.getRouting({}).catch((error) => { - // console.error(error) - // }) - console.log('routing ------ ', routing) } - console.log('reached here 4') const { outOfBandRecord, invitation } = await request.agent.oob.createLegacyInvitation({ ...config, routing, }) - console.log('reached here 5') return { invitationUrl: invitation.toUrl({ domain: request.agent.config.endpoints[0], @@ -205,7 +193,6 @@ export class ContextController extends Controller { outOfBandRecord: outOfBandRecord.toJSON(), ...(config?.recipientKey ? {} : { recipientKey: routing.recipientKey.publicKeyBase58 }), } - console.log('reached here 6') } catch (error) { return internalServerError(500, { message: `something went wrong: ${error}` }) } @@ -233,7 +220,6 @@ export class ContextController extends Controller { const { invitationUrl, ...config } = invitationRequest try { - console.log('Reached in receive invitation') const linkSecretIds = await request.agent.modules.anoncreds.getLinkSecretIds() if (linkSecretIds.length === 0) { await request.agent.modules.anoncreds.createLinkSecret() diff --git a/src/controllers/additional-endpoint/multitenant.Controller.ts b/src/controllers/additional-endpoint/multitenant.Controller.ts index 5170b1f6..ceca8acc 100644 --- a/src/controllers/additional-endpoint/multitenant.Controller.ts +++ b/src/controllers/additional-endpoint/multitenant.Controller.ts @@ -19,15 +19,8 @@ import { Body, Controller, Get, Path, Post, Request, Res, Route, Security, Tags, // @Security('NewAuth') @injectable() export class MultiTenantController extends Controller { - // private readonly agent: Agent - - // Krish: can simply add 'private readonly' in constructor - // public constructor(private readonly agent: Agent) { - // super() - // this.agent = agent - // } - // @Security('RootAuthorization') + @Security('jwt', ['multi-tenant']) @Post('/create-tenant') public async createTenant( @Request() request: Req, @@ -37,17 +30,11 @@ export class MultiTenantController extends Controller { ) { const { config } = createTenantOptions try { - console.log('reached in create tenant') - console.log('this is request in controller::::::', request) - console.log('this is request.user::::::', request.agent) - console.log('this is request.agent.config::::::', request.agent.config) const agent = request.agent as unknown as Agent const tenantRecord: TenantRecord = await agent.modules.tenants?.createTenant({ config }) - const token = await this.getToken(agent, tenantRecord.id) + const token = await this.createToken(agent, tenantRecord.id) const withToken = { token, ...tenantRecord } return withToken - // return typeof request['user'].agent - // return 'success' } catch (error) { if (error instanceof RecordNotFoundError) { return notFoundError(404, { @@ -59,6 +46,41 @@ export class MultiTenantController extends Controller { } } + @Security('jwt', ['multi-tenant']) + @Post('/get-token/:tenantId') + public async getTenantToken( + @Request() request: Req, + @Path('tenantId') tenantId: string, + @Res() notFoundError: TsoaResponse<404, { reason: string }>, + @Res() internalServerError: TsoaResponse<500, { message: string }> + ) { + try { + const agent = request.agent as unknown as Agent + let secretKey + await agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + const genericRecord = await tenantAgent.genericRecords.getAll() + const records = genericRecord.find((record) => record?.content?.secretKey !== undefined) + secretKey = records?.content.secretKey as string + }) + + if (!secretKey) { + throw new RecordNotFoundError('secretKey does not exist in wallet', { recordType: 'debug', cause: undefined }) + } + + const token = await this.createToken(agent, tenantId, secretKey) + + return { token: token } + } catch (error) { + if (error instanceof RecordNotFoundError) { + return notFoundError(404, { + reason: `SecretKey not found`, + }) + } + + return internalServerError(500, { message: `Something went wrong: ${error}` }) + } + } + @Security('apiKey') @Get(':tenantId') public async getTenantById( @@ -89,14 +111,6 @@ export class MultiTenantController extends Controller { @Res() internalServerError: TsoaResponse<500, { message: string }> ) { try { - // let outOfBandRecord: OutOfBandRecord | undefined - // const agent = request.agent as unknown as Agent - // const tenantId = '5f8ba896-15c9-4db0-89a7-7eb2aa709613' - console.log('This is request.agent', request.agent) - console.log('reached here 12') - // await agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - // outOfBandRecord = await tenantAgent.oob.createInvitation() - // }) const outOfBandRecord = await request.agent.oob.createInvitation() return outOfBandRecord } catch (error) { @@ -109,14 +123,21 @@ export class MultiTenantController extends Controller { } } - private async createToken(agent: Agent, tenantId: string) { - const secretKey = await generateSecretKey() - // const genericRecord = await this.agent.genericRecords.getAll() - // const records = genericRecord.find((record) => record?.content?.secretKey !== undefined) - // const secretKey = records?.content.secretKey as string - const token = jwt.sign({ role: AgentRole.RestTenantAgent, tenantId }, secretKey) - // Save token to individual tenants generic records - await this.saveTokenAndSecretKey(agent, token, secretKey, tenantId) + private async createToken(agent: Agent, tenantId: string, secretKey?: string) { + let key: string + if (!secretKey) { + key = await generateSecretKey() + await agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + tenantAgent.genericRecords.save({ + content: { + secretKey: key, + }, + }) + }) + } else { + key = secretKey + } + const token = jwt.sign({ role: AgentRole.RestTenantAgent, tenantId }, key) return token } @@ -135,9 +156,4 @@ export class MultiTenantController extends Controller { }) }) } - - private async getToken(agent: Agent, tenantId: string) { - const token: string = await this.createToken(agent, tenantId) - return token - } } diff --git a/src/controllers/basic-messages/BasicMessageController.ts b/src/controllers/basic-messages/BasicMessageController.ts index 78c0d595..63df3f59 100644 --- a/src/controllers/basic-messages/BasicMessageController.ts +++ b/src/controllers/basic-messages/BasicMessageController.ts @@ -1,24 +1,20 @@ import type { BasicMessageRecord, BasicMessageStorageProps } from '@aries-framework/core' -import { Agent, RecordNotFoundError } from '@aries-framework/core' +// eslint-disable-next-line import/no-extraneous-dependencies +import { RecordNotFoundError } from '@aries-framework/core' +import { Request as Req } from 'express' import { injectable } from 'tsyringe' import { BasicMessageRecordExample, RecordId } from '../examples' -import { Body, Controller, Example, Get, Path, Post, Res, Route, Tags, TsoaResponse, Security } from 'tsoa' +import { Body, Controller, Example, Get, Path, Post, Res, Route, Tags, TsoaResponse, Security, Request } from 'tsoa' @Tags('Basic Messages') @Route('/basic-messages') -@Security('apiKey') +// @Security('apiKey') +@Security('jwt') @injectable() export class BasicMessageController extends Controller { - private agent: Agent - - public constructor(agent: Agent) { - super() - this.agent = agent - } - /** * Retrieve basic messages by connection id * @@ -27,8 +23,11 @@ export class BasicMessageController extends Controller { */ @Example([BasicMessageRecordExample]) @Get('/:connectionId') - public async getBasicMessages(@Path('connectionId') connectionId: RecordId): Promise { - return await this.agent.basicMessages.findAllByQuery({ connectionId }) + public async getBasicMessages( + @Path('connectionId') connectionId: RecordId, + @Request() request: Req + ): Promise { + return await request.agent.basicMessages.findAllByQuery({ connectionId }) } /** @@ -40,13 +39,14 @@ export class BasicMessageController extends Controller { @Post('/:connectionId') public async sendMessage( @Path('connectionId') connectionId: RecordId, - @Body() request: Record<'content', string>, + @Body() requestBody: Record<'content', string>, + @Request() request: Req, @Res() notFoundError: TsoaResponse<404, { reason: string }>, @Res() internalServerError: TsoaResponse<500, { message: string }> ) { try { this.setStatus(204) - await this.agent.basicMessages.sendMessage(connectionId, request.content) + await request.agent.basicMessages.sendMessage(connectionId, requestBody.content) } catch (error) { if (error instanceof RecordNotFoundError) { return notFoundError(404, { reason: `connection with connection id "${connectionId}" not found.` }) diff --git a/src/controllers/connections/ConnectionController.ts b/src/controllers/connections/ConnectionController.ts index ba093db9..15f154e6 100644 --- a/src/controllers/connections/ConnectionController.ts +++ b/src/controllers/connections/ConnectionController.ts @@ -1,29 +1,33 @@ import type { ConnectionRecordProps } from '@aries-framework/core' -import { - ConnectionRepository, - DidExchangeState, - Agent, - AriesFrameworkError, - RecordNotFoundError, -} from '@aries-framework/core' +// eslint-disable-next-line import/no-extraneous-dependencies +import { ConnectionRepository, DidExchangeState, AriesFrameworkError, RecordNotFoundError } from '@aries-framework/core' +import { Request as Req } from 'express' +// eslint-disable-next-line import/no-extraneous-dependencies import { injectable } from 'tsyringe' import { ConnectionRecordExample, RecordId } from '../examples' -import { Controller, Delete, Example, Get, Path, Post, Query, Res, Route, Tags, TsoaResponse, Security } from 'tsoa' +import { + Controller, + Delete, + Example, + Get, + Path, + Post, + Query, + Res, + Route, + Tags, + TsoaResponse, + Security, + Request, +} from 'tsoa' @Tags('Connections') @Route() @injectable() export class ConnectionController extends Controller { - private agent: Agent - - public constructor(agent: Agent) { - super() - this.agent = agent - } - /** * Retrieve all connections records * @param alias Alias @@ -34,9 +38,11 @@ export class ConnectionController extends Controller { * @returns ConnectionRecord[] */ @Example([ConnectionRecordExample]) - @Security('apiKey') + // @Security('apiKey') + @Security('jwt') @Get('/connections') public async getAllConnections( + @Request() request: Req, @Query('outOfBandId') outOfBandId?: string, @Query('alias') alias?: string, @Query('state') state?: DidExchangeState, @@ -47,11 +53,11 @@ export class ConnectionController extends Controller { let connections if (outOfBandId) { - connections = await this.agent.connections.findAllByOutOfBandId(outOfBandId) + connections = await request.agent.connections.findAllByOutOfBandId(outOfBandId) } else { - const connectionRepository = this.agent.dependencyManager.resolve(ConnectionRepository) + const connectionRepository = request.agent.dependencyManager.resolve(ConnectionRepository) - const connections = await connectionRepository.findByQuery(this.agent.context, { + const connections = await connectionRepository.findByQuery(request.agent.context, { alias, myDid, theirDid, @@ -77,13 +83,15 @@ export class ConnectionController extends Controller { * @returns ConnectionRecord */ @Example(ConnectionRecordExample) - @Security('apiKey') + // @Security('apiKey') + @Security('jwt') @Get('/connections/:connectionId') public async getConnectionById( + @Request() request: Req, @Path('connectionId') connectionId: RecordId, @Res() notFoundError: TsoaResponse<404, { reason: string }> ) { - const connection = await this.agent.connections.findById(connectionId) + const connection = await request.agent.connections.findById(connectionId) if (!connection) return notFoundError(404, { reason: `connection with connection id "${connectionId}" not found.` }) @@ -96,15 +104,17 @@ export class ConnectionController extends Controller { * @param connectionId Connection identifier */ @Delete('/connections/:connectionId') - @Security('apiKey') + // @Security('apiKey') + @Security('jwt') public async deleteConnection( + @Request() request: Req, @Path('connectionId') connectionId: RecordId, @Res() notFoundError: TsoaResponse<404, { reason: string }>, @Res() internalServerError: TsoaResponse<500, { message: string }> ) { try { this.setStatus(204) - await this.agent.connections.deleteById(connectionId) + await request.agent.connections.deleteById(connectionId) } catch (error) { if (error instanceof RecordNotFoundError) { return notFoundError(404, { reason: `connection with connection id "${connectionId}" not found.` }) @@ -123,15 +133,17 @@ export class ConnectionController extends Controller { * @returns ConnectionRecord */ @Example(ConnectionRecordExample) - @Security('apiKey') + // @Security('apiKey') + @Security('jwt') @Post('/connections/:connectionId/accept-request') public async acceptRequest( + @Request() request: Req, @Path('connectionId') connectionId: RecordId, @Res() notFoundError: TsoaResponse<404, { reason: string }>, @Res() internalServerError: TsoaResponse<500, { message: string }> ) { try { - const connection = await this.agent.connections.acceptRequest(connectionId) + const connection = await request.agent.connections.acceptRequest(connectionId) return connection.toJSON() } catch (error) { if (error instanceof AriesFrameworkError) { @@ -151,15 +163,17 @@ export class ConnectionController extends Controller { * @returns ConnectionRecord */ @Example(ConnectionRecordExample) - @Security('apiKey') + // @Security('apiKey') + @Security('jwt') @Post('/connections/:connectionId/accept-response') public async acceptResponse( + @Request() request: Req, @Path('connectionId') connectionId: RecordId, @Res() notFoundError: TsoaResponse<404, { reason: string }>, @Res() internalServerError: TsoaResponse<500, { message: string }> ) { try { - const connection = await this.agent.connections.acceptResponse(connectionId) + const connection = await request.agent.connections.acceptResponse(connectionId) return connection.toJSON() } catch (error) { if (error instanceof RecordNotFoundError) { @@ -171,12 +185,13 @@ export class ConnectionController extends Controller { @Get('/url/:invitationId') public async getInvitation( + @Request() request: Req, @Path('invitationId') invitationId: string, @Res() notFoundError: TsoaResponse<404, { reason: string }>, // eslint-disable-next-line @typescript-eslint/no-unused-vars @Res() internalServerError: TsoaResponse<500, { message: string }> ) { - const outOfBandRecord = await this.agent.oob.findByCreatedInvitationId(invitationId) + const outOfBandRecord = await request.agent.oob.findByCreatedInvitationId(invitationId) if (!outOfBandRecord || outOfBandRecord.state !== 'await-response') return notFoundError(404, { reason: `connection with invitationId "${invitationId}" not found.` }) diff --git a/src/controllers/credentials/CredentialController.ts b/src/controllers/credentials/CredentialController.ts index e1ae9af7..edc1b97f 100644 --- a/src/controllers/credentials/CredentialController.ts +++ b/src/controllers/credentials/CredentialController.ts @@ -1,17 +1,18 @@ -import type { RestAgentModules } from '../../cliAgent' import type { CredentialExchangeRecordProps, CredentialProtocolVersionType, Routing } from '@aries-framework/core' +// eslint-disable-next-line import/no-extraneous-dependencies import { LegacyIndyCredentialFormatService, V1CredentialProtocol } from '@aries-framework/anoncreds' +// eslint-disable-next-line import/no-extraneous-dependencies import { CredentialRepository, CredentialState, - Agent, RecordNotFoundError, HandshakeProtocol, W3cCredentialService, Key, KeyType, } from '@aries-framework/core' +import { Request as Req } from 'express' import { injectable } from 'tsyringe' import { CredentialExchangeRecordExample, RecordId } from '../examples' @@ -26,23 +27,33 @@ import { CreateOfferOobOptions, } from '../types' -import { Body, Controller, Get, Path, Post, Res, Route, Tags, TsoaResponse, Example, Query, Security } from 'tsoa' +import { + Body, + Controller, + Get, + Path, + Post, + Res, + Route, + Tags, + TsoaResponse, + Example, + Query, + Security, + Request, +} from 'tsoa' @Tags('Credentials') -@Security('apiKey') +// @Security('apiKey') +@Security('jwt') @Route('/credentials') @injectable() export class CredentialController extends Controller { - private agent: Agent private outOfBandController: OutOfBandController - // private v1CredentialProtocol: V1CredentialProtocol - - public constructor(agent: Agent, outOfBandController: OutOfBandController) { + public constructor(outOfBandController: OutOfBandController) { super() - this.agent = agent this.outOfBandController = outOfBandController - // this.v1CredentialProtocol = v1CredentialProtocol } /** @@ -53,13 +64,14 @@ export class CredentialController extends Controller { @Example([CredentialExchangeRecordExample]) @Get('/') public async getAllCredentials( + @Request() request: Req, @Query('threadId') threadId?: string, @Query('connectionId') connectionId?: string, @Query('state') state?: CredentialState ) { - const credentialRepository = this.agent.dependencyManager.resolve(CredentialRepository) + const credentialRepository = request.agent.dependencyManager.resolve(CredentialRepository) - const credentials = await credentialRepository.findByQuery(this.agent.context, { + const credentials = await credentialRepository.findByQuery(request.agent.context, { connectionId, threadId, state, @@ -69,15 +81,15 @@ export class CredentialController extends Controller { } @Get('/w3c') - public async getAllW3c() { - const w3cCredentialService = await this.agent.dependencyManager.resolve(W3cCredentialService) - return await w3cCredentialService.getAllCredentialRecords(this.agent.context) + public async getAllW3c(@Request() request: Req) { + const w3cCredentialService = await request.agent.dependencyManager.resolve(W3cCredentialService) + return await w3cCredentialService.getAllCredentialRecords(request.agent.context) } @Get('/w3c/:id') - public async getW3cById(@Path('id') id: string) { - const w3cCredentialService = await this.agent.dependencyManager.resolve(W3cCredentialService) - return await w3cCredentialService.getCredentialRecordById(this.agent.context, id) + public async getW3cById(@Path('id') id: string, @Request() request: Req) { + const w3cCredentialService = await request.agent.dependencyManager.resolve(W3cCredentialService) + return await w3cCredentialService.getCredentialRecordById(request.agent.context, id) } /** @@ -89,12 +101,13 @@ export class CredentialController extends Controller { @Example(CredentialExchangeRecordExample) @Get('/:credentialRecordId') public async getCredentialById( + @Request() request: Req, @Path('credentialRecordId') credentialRecordId: RecordId, @Res() notFoundError: TsoaResponse<404, { reason: string }>, @Res() internalServerError: TsoaResponse<500, { message: string }> ) { try { - const credential = await this.agent.credentials.getById(credentialRecordId) + const credential = await request.agent.credentials.getById(credentialRecordId) return credential.toJSON() } catch (error) { if (error instanceof RecordNotFoundError) { @@ -116,12 +129,13 @@ export class CredentialController extends Controller { @Example(CredentialExchangeRecordExample) @Post('/propose-credential') public async proposeCredential( + @Request() request: Req, @Body() proposeCredentialOptions: ProposeCredentialOptions, @Res() notFoundError: TsoaResponse<404, { reason: string }>, @Res() internalServerError: TsoaResponse<500, { message: string }> ) { try { - const credential = await this.agent.credentials.proposeCredential({ + const credential = await request.agent.credentials.proposeCredential({ connectionId: proposeCredentialOptions.connectionId, protocolVersion: 'v1' as CredentialProtocolVersionType<[]>, credentialFormats: proposeCredentialOptions.credentialFormats, @@ -150,13 +164,14 @@ export class CredentialController extends Controller { @Example(CredentialExchangeRecordExample) @Post('/accept-proposal') public async acceptProposal( + @Request() request: Req, // @Path('credentialRecordId') credentialRecordId: RecordId, @Res() notFoundError: TsoaResponse<404, { reason: string }>, @Res() internalServerError: TsoaResponse<500, { message: string }>, @Body() acceptCredentialProposal: AcceptCredentialProposalOptions ) { try { - const credential = await this.agent.credentials.acceptProposal({ + const credential = await request.agent.credentials.acceptProposal({ credentialRecordId: acceptCredentialProposal.credentialRecordId, credentialFormats: acceptCredentialProposal.credentialFormats, autoAcceptCredential: acceptCredentialProposal.autoAcceptCredential, @@ -184,11 +199,12 @@ export class CredentialController extends Controller { @Example(CredentialExchangeRecordExample) @Post('/create-offer') public async createOffer( + @Request() request: Req, @Body() createOfferOptions: CreateOfferOptions, @Res() internalServerError: TsoaResponse<500, { message: string }> ) { try { - const offer = await this.agent.credentials.offerCredential({ + const offer = await request.agent.credentials.offerCredential({ connectionId: createOfferOptions.connectionId, protocolVersion: createOfferOptions.protocolVersion as CredentialProtocolVersionType<[]>, credentialFormats: createOfferOptions.credentialFormats, @@ -202,26 +218,27 @@ export class CredentialController extends Controller { @Post('/create-offer-oob') public async createOfferOob( + @Request() request: Req, @Body() outOfBandOption: CreateOfferOobOptions, @Res() internalServerError: TsoaResponse<500, { message: string }> ) { try { let routing: Routing - const linkSecretIds = await this.agent.modules.anoncreds.getLinkSecretIds() + const linkSecretIds = await request.agent.modules.anoncreds.getLinkSecretIds() if (linkSecretIds.length === 0) { - await this.agent.modules.anoncreds.createLinkSecret() + await request.agent.modules.anoncreds.createLinkSecret() } if (outOfBandOption?.recipientKey) { routing = { - endpoints: this.agent.config.endpoints, + endpoints: request.agent.config.endpoints, routingKeys: [], recipientKey: Key.fromPublicKeyBase58(outOfBandOption.recipientKey, KeyType.Ed25519), mediatorId: undefined, } } else { - routing = await this.agent.mediationRecipient.getRouting({}) + routing = await request.agent.mediationRecipient.getRouting({}) } - const offerOob = await this.agent.credentials.createOffer({ + const offerOob = await request.agent.credentials.createOffer({ protocolVersion: outOfBandOption.protocolVersion as CredentialProtocolVersionType<[]>, credentialFormats: outOfBandOption.credentialFormats, autoAcceptCredential: outOfBandOption.autoAcceptCredential, @@ -229,7 +246,7 @@ export class CredentialController extends Controller { }) const credentialMessage = offerOob.message - const outOfBandRecord = await this.agent.oob.createInvitation({ + const outOfBandRecord = await request.agent.oob.createInvitation({ label: outOfBandOption.label, handshakeProtocols: [HandshakeProtocol.Connections], messages: [credentialMessage], @@ -239,10 +256,10 @@ export class CredentialController extends Controller { }) return { invitationUrl: outOfBandRecord.outOfBandInvitation.toUrl({ - domain: this.agent.config.endpoints[0], + domain: request.agent.config.endpoints[0], }), invitation: outOfBandRecord.outOfBandInvitation.toJSON({ - useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, + useDidSovPrefixWhereAllowed: request.agent.config.useDidSovPrefixWhereAllowed, }), outOfBandRecord: outOfBandRecord.toJSON(), recipientKey: outOfBandOption?.recipientKey ? {} : { recipientKey: routing.recipientKey.publicKeyBase58 }, @@ -263,16 +280,17 @@ export class CredentialController extends Controller { @Example(CredentialExchangeRecordExample) @Post('/accept-offer') public async acceptOffer( + @Request() request: Req, @Res() notFoundError: TsoaResponse<404, { reason: string }>, @Res() internalServerError: TsoaResponse<500, { message: string }>, @Body() acceptCredentialOfferOptions: CredentialOfferOptions ) { try { - const linkSecretIds = await this.agent.modules.anoncreds.getLinkSecretIds() + const linkSecretIds = await request.agent.modules.anoncreds.getLinkSecretIds() if (linkSecretIds.length === 0) { - await this.agent.modules.anoncreds.createLinkSecret() + await request.agent.modules.anoncreds.createLinkSecret() } - const acceptOffer = await this.agent.credentials.acceptOffer({ + const acceptOffer = await request.agent.credentials.acceptOffer({ credentialRecordId: acceptCredentialOfferOptions.credentialRecordId, credentialFormats: acceptCredentialOfferOptions.credentialFormats, autoAcceptCredential: acceptCredentialOfferOptions.autoAcceptCredential, @@ -300,6 +318,7 @@ export class CredentialController extends Controller { @Example(CredentialExchangeRecordExample) @Post('/accept-request') public async acceptRequest( + @Request() request: Req, @Res() notFoundError: TsoaResponse<404, { reason: string }>, @Res() internalServerError: TsoaResponse<500, { message: string }>, @Body() acceptCredentialRequestOptions: AcceptCredentialRequestOptions @@ -308,7 +327,7 @@ export class CredentialController extends Controller { const indyCredentialFormat = new LegacyIndyCredentialFormatService() const v1CredentialProtocol = new V1CredentialProtocol({ indyCredentialFormat }) - const credential = await v1CredentialProtocol.acceptRequest(this.agent.context, acceptCredentialRequestOptions) + const credential = await v1CredentialProtocol.acceptRequest(request.agent.context, acceptCredentialRequestOptions) return credential } catch (error) { if (error instanceof RecordNotFoundError) { @@ -330,6 +349,7 @@ export class CredentialController extends Controller { @Example(CredentialExchangeRecordExample) @Post('/accept-credential') public async acceptCredential( + @Request() request: Req, @Res() notFoundError: TsoaResponse<404, { reason: string }>, @Res() internalServerError: TsoaResponse<500, { message: string }>, @Body() acceptCredential: AcceptCredential @@ -338,7 +358,7 @@ export class CredentialController extends Controller { const indyCredentialFormat = new LegacyIndyCredentialFormatService() const v1CredentialProtocol = new V1CredentialProtocol({ indyCredentialFormat }) - const credential = await v1CredentialProtocol.acceptCredential(this.agent.context, acceptCredential) + const credential = await v1CredentialProtocol.acceptCredential(request.agent.context, acceptCredential) return credential } catch (error) { if (error instanceof RecordNotFoundError) { diff --git a/src/controllers/credentials/CredentialDefinitionController.ts b/src/controllers/credentials/CredentialDefinitionController.ts index 582cb41b..8b99941a 100644 --- a/src/controllers/credentials/CredentialDefinitionController.ts +++ b/src/controllers/credentials/CredentialDefinitionController.ts @@ -1,29 +1,27 @@ import type { SchemaId } from '../examples' +// eslint-disable-next-line import/no-extraneous-dependencies import { AnonCredsError, getUnqualifiedCredentialDefinitionId, parseIndyCredentialDefinitionId, } from '@aries-framework/anoncreds' -import { Agent, AriesFrameworkError } from '@aries-framework/core' +// eslint-disable-next-line import/no-extraneous-dependencies +import { AriesFrameworkError } from '@aries-framework/core' +import { Request as Req } from 'express' import { injectable } from 'tsyringe' import { CredentialEnum } from '../../enums/enum' import { CredentialDefinitionExample, CredentialDefinitionId } from '../examples' -import { Body, Controller, Example, Get, Path, Post, Res, Route, Tags, TsoaResponse, Security } from 'tsoa' +import { Body, Controller, Example, Get, Path, Post, Res, Route, Tags, TsoaResponse, Security, Request } from 'tsoa' @Tags('Credential Definitions') @Route('/credential-definitions') -@Security('apiKey') +// @Security('apiKey') +@Security('jwt') @injectable() export class CredentialDefinitionController extends Controller { - private agent: Agent - public constructor(agent: Agent) { - super() - this.agent = agent - } - /** * Retrieve credential definition by credential definition id * @@ -33,13 +31,14 @@ export class CredentialDefinitionController extends Controller { @Example(CredentialDefinitionExample) @Get('/:credentialDefinitionId') public async getCredentialDefinitionById( + @Request() request: Req, @Path('credentialDefinitionId') credentialDefinitionId: CredentialDefinitionId, @Res() badRequestError: TsoaResponse<400, { reason: string }>, @Res() notFoundError: TsoaResponse<404, { reason: string }>, @Res() internalServerError: TsoaResponse<500, { message: string }> ) { try { - return await this.agent.modules.anoncreds.getCredentialDefinition(credentialDefinitionId) + return await request.agent.modules.anoncreds.getCredentialDefinition(credentialDefinitionId) } catch (error) { if (error instanceof AriesFrameworkError && error.message === 'IndyError(LedgerNotFound): LedgerNotFound') { return notFoundError(404, { @@ -65,6 +64,7 @@ export class CredentialDefinitionController extends Controller { @Example(CredentialDefinitionExample) @Post('/') public async createCredentialDefinition( + @Request() request: Req, @Body() credentialDefinitionRequest: { issuerId: string @@ -85,11 +85,15 @@ export class CredentialDefinitionController extends Controller { type: 'CL', } if (!endorse) { - const { credentialDefinitionState } = await this.agent.modules.anoncreds.registerCredentialDefinition({ + const { credentialDefinitionState } = await request.agent.modules.anoncreds.registerCredentialDefinition({ credentialDefinition: credentialDefinitionPyload, options: {}, }) + if (!credentialDefinitionState?.credentialDefinitionId) { + throw new Error('Credential Definition Id not found') + } + const indyCredDefId = parseIndyCredentialDefinitionId(credentialDefinitionState.credentialDefinitionId) const getCredentialDefinitionId = await getUnqualifiedCredentialDefinitionId( indyCredDefId.namespaceIdentifier, @@ -106,7 +110,7 @@ export class CredentialDefinitionController extends Controller { throw new Error('Please provide the endorser DID') } - const createCredDefTxResult = await this.agent.modules.anoncreds.registerCredentialDefinition({ + const createCredDefTxResult = await request.agent.modules.anoncreds.registerCredentialDefinition({ credentialDefinition: credentialDefinitionPyload, options: { endorserMode: 'external', diff --git a/src/controllers/credentials/SchemaController.ts b/src/controllers/credentials/SchemaController.ts index aea82383..708c76ba 100644 --- a/src/controllers/credentials/SchemaController.ts +++ b/src/controllers/credentials/SchemaController.ts @@ -1,27 +1,23 @@ import type { Version } from '../examples' +// eslint-disable-next-line import/no-extraneous-dependencies import { AnonCredsError, getUnqualifiedSchemaId, parseIndySchemaId } from '@aries-framework/anoncreds' -import { Agent, AriesFrameworkError } from '@aries-framework/core' +// eslint-disable-next-line import/no-extraneous-dependencies +import { AriesFrameworkError } from '@aries-framework/core' +import { Request as Req } from 'express' import { injectable } from 'tsyringe' import { CredentialEnum } from '../../enums/enum' import { SchemaId, SchemaExample } from '../examples' -import { Body, Example, Get, Path, Post, Res, Route, Tags, TsoaResponse, Security } from 'tsoa' +import { Body, Example, Get, Path, Post, Res, Route, Tags, TsoaResponse, Security, Request } from 'tsoa' @Tags('Schemas') @Route('/schemas') -@Security('apiKey') +// @Security('apiKey') +@Security('jwt') @injectable() export class SchemaController { - private agent: Agent - // private anonCredsSchema: AnonCredsApi - - public constructor(agent: Agent) { - this.agent = agent - // this.anonCredsSchema = anonCredsSchema - } - /** * Retrieve schema by schema id * @@ -31,6 +27,7 @@ export class SchemaController { @Example(SchemaExample) @Get('/:schemaId') public async getSchemaById( + @Request() request: Req, @Path('schemaId') schemaId: SchemaId, @Res() notFoundError: TsoaResponse<404, { reason: string }>, @Res() forbiddenError: TsoaResponse<403, { reason: string }>, @@ -38,7 +35,7 @@ export class SchemaController { @Res() internalServerError: TsoaResponse<500, { message: string }> ) { try { - return await this.agent.modules.anoncreds.getSchema(schemaId) + return await request.agent.modules.anoncreds.getSchema(schemaId) } catch (errorMessage) { if ( errorMessage instanceof AnonCredsError && @@ -73,6 +70,7 @@ export class SchemaController { @Example(SchemaExample) @Post('/') public async createSchema( + @Request() request: Req, @Body() schema: { issuerId: string @@ -96,7 +94,7 @@ export class SchemaController { } if (!schema.endorse) { - const { schemaState } = await this.agent.modules.anoncreds.registerSchema({ + const { schemaState } = await request.agent.modules.anoncreds.registerSchema({ schema: schemaPayload, options: { endorserMode: 'internal', @@ -104,6 +102,10 @@ export class SchemaController { }, }) + if (!schemaState.schemaId) { + throw Error('SchemaId not found') + } + const indySchemaId = parseIndySchemaId(schemaState.schemaId) const getSchemaUnqualifiedId = await getUnqualifiedSchemaId( indySchemaId.namespaceIdentifier, @@ -119,7 +121,7 @@ export class SchemaController { throw new Error('Please provide the endorser DID') } - const createSchemaTxResult = await this.agent.modules.anoncreds.registerSchema({ + const createSchemaTxResult = await request.agent.modules.anoncreds.registerSchema({ options: { endorserMode: 'external', endorserDid: schema.endorserDid ? schema.endorserDid : '', diff --git a/src/controllers/did/DidController.ts b/src/controllers/did/DidController.ts index 140dd3c7..5cfb2d38 100644 --- a/src/controllers/did/DidController.ts +++ b/src/controllers/did/DidController.ts @@ -1,16 +1,19 @@ +import type { AgentType } from '../../types/request' import type { DidResolutionResultProps } from '../types' import type { KeyDidCreateOptions } from '@aries-framework/core' +// eslint-disable-next-line import/order import type { PolygonDidCreateOptions } from '@ayanworks/credo-polygon-w3c-module/build/dids' +// eslint-disable-next-line import/no-extraneous-dependencies import { KeyType, TypedArrayEncoder, DidDocumentBuilder, getEd25519VerificationKey2018, - Agent, getBls12381G2Key2020, } from '@aries-framework/core' import axios from 'axios' +import { Request as Req } from 'express' import { injectable } from 'tsyringe' import { DidMethod, Network, Role } from '../../enums/enum' @@ -18,20 +21,14 @@ import { BCOVRIN_REGISTER_URL, INDICIO_NYM_URL } from '../../utils/util' import { Did, DidRecordExample } from '../examples' import { DidCreate } from '../types' -import { Body, Controller, Example, Get, Path, Post, Res, Route, Tags, TsoaResponse, Security } from 'tsoa' +import { Body, Controller, Example, Get, Path, Post, Res, Route, Tags, TsoaResponse, Security, Request } from 'tsoa' @Tags('Dids') @Route('/dids') -@Security('apiKey') +// @Security('apiKey') +@Security('jwt') @injectable() export class DidController extends Controller { - private agent: Agent - - public constructor(agent: Agent) { - super() - this.agent = agent - } - /** * Resolves did and returns did resolution result * @param did Decentralized Identifier @@ -39,9 +36,9 @@ export class DidController extends Controller { */ @Example(DidRecordExample) @Get('/:did') - public async getDidRecordByDid(@Path('did') did: Did) { - const resolveResult = await this.agent.dids.resolve(did) - const importDid = await this.agent.dids.import({ + public async getDidRecordByDid(@Request() request: Req, @Path('did') did: Did) { + const resolveResult = await request.agent.dids.resolve(did) + const importDid = await request.agent.dids.import({ did, overwrite: true, }) @@ -62,6 +59,7 @@ export class DidController extends Controller { @Post('/write') public async writeDid( + @Request() request: Req, @Body() createDidOptions: DidCreate, @Res() internalServerError: TsoaResponse<500, { message: string }> ) { @@ -75,19 +73,19 @@ export class DidController extends Controller { let result switch (createDidOptions.method) { case DidMethod.Indy: - result = await this.handleIndy(createDidOptions) + result = await this.handleIndy(createDidOptions, request.agent) break case DidMethod.Key: - result = await this.handleKey(createDidOptions) + result = await this.handleKey(createDidOptions, request.agent) break case DidMethod.Web: - result = await this.handleWeb(createDidOptions) + result = await this.handleWeb(createDidOptions, request.agent) break case DidMethod.Polygon: - result = await this.handlePolygon(createDidOptions) + result = await this.handlePolygon(createDidOptions, request.agent) break default: @@ -102,7 +100,7 @@ export class DidController extends Controller { } } - private async handleIndy(createDidOptions: DidCreate) { + private async handleIndy(createDidOptions: DidCreate, agent: AgentType) { let result if (!createDidOptions.keyType) { throw Error('keyType is required') @@ -124,7 +122,8 @@ export class DidController extends Controller { case Network.Bcovrin_Testnet: result = await this.handleBcovrin( createDidOptions, - `did:${createDidOptions.method}:${createDidOptions.network}` + `did:${createDidOptions.method}:${createDidOptions.network}`, + agent ) break @@ -132,7 +131,8 @@ export class DidController extends Controller { case Network.Indicio_Testnet: result = await this.handleIndicio( createDidOptions, - `did:${createDidOptions.method}:${createDidOptions.network}` + `did:${createDidOptions.method}:${createDidOptions.network}`, + agent ) break @@ -142,15 +142,15 @@ export class DidController extends Controller { return result } - private async handleBcovrin(createDidOptions: DidCreate, didMethod: string) { + private async handleBcovrin(createDidOptions: DidCreate, didMethod: string, agent: AgentType) { let didDocument if (!createDidOptions.seed) { throw Error('Seed is required') } if (createDidOptions?.role?.toLowerCase() === Role.Endorser) { if (createDidOptions.did) { - await this.importDid(didMethod, createDidOptions.did, createDidOptions.seed) - const getDid = await this.agent.dids.getCreatedDids({ + await this.importDid(didMethod, createDidOptions.did, createDidOptions.seed, agent) + const getDid = await agent.dids.getCreatedDids({ method: createDidOptions.method, did: `did:${createDidOptions.method}:${createDidOptions.network}:${createDidOptions.did}`, }) @@ -169,8 +169,8 @@ export class DidController extends Controller { seed: createDidOptions.seed, }) const { did } = res?.data || {} - await this.importDid(didMethod, did, createDidOptions.seed) - const didRecord = await this.agent.dids.getCreatedDids({ + await this.importDid(didMethod, did, createDidOptions.seed, agent) + const didRecord = await agent.dids.getCreatedDids({ method: DidMethod.Indy, did: `did:${DidMethod.Indy}:${Network.Bcovrin_Testnet}:${res.data.did}`, }) @@ -188,20 +188,20 @@ export class DidController extends Controller { if (!createDidOptions.endorserDid) { throw new Error('Please provide the endorser DID or role') } - const didCreateTxResult = await this.createEndorserDid(createDidOptions.endorserDid) + const didCreateTxResult = await this.createEndorserDid(createDidOptions.endorserDid, agent) return { did: didCreateTxResult.didState.did, didDocument: didCreateTxResult.didState.didDocument } } } - private async handleIndicio(createDidOptions: DidCreate, didMethod: string) { + private async handleIndicio(createDidOptions: DidCreate, didMethod: string, agent: AgentType) { let didDocument if (!createDidOptions.seed) { throw Error('Seed is required') } if (createDidOptions?.role?.toLowerCase() === Role.Endorser) { if (createDidOptions.did) { - await this.importDid(didMethod, createDidOptions.did, createDidOptions.seed) - const didRecord = await this.agent.dids.getCreatedDids({ + await this.importDid(didMethod, createDidOptions.did, createDidOptions.seed, agent) + const didRecord = await agent.dids.getCreatedDids({ method: createDidOptions.method, did: `did:${createDidOptions.method}:${createDidOptions.network}:${createDidOptions.did}`, }) @@ -215,11 +215,11 @@ export class DidController extends Controller { didDocument: didDocument, } } else { - const key = await this.createIndicioKey(createDidOptions) + const key = await this.createIndicioKey(createDidOptions, agent) const res = await axios.post(INDICIO_NYM_URL, key) if (res.data.statusCode === 200) { - await this.importDid(didMethod, key.did, createDidOptions.seed) - const didRecord = await this.agent.dids.getCreatedDids({ + await this.importDid(didMethod, key.did, createDidOptions.seed, agent) + const didRecord = await agent.dids.getCreatedDids({ method: DidMethod.Indy, did: `${didMethod}:${key.did}`, }) @@ -238,13 +238,13 @@ export class DidController extends Controller { if (!createDidOptions.endorserDid) { throw new Error('Please provide the endorser DID or role') } - const didCreateTxResult = await this.createEndorserDid(createDidOptions.endorserDid) + const didCreateTxResult = await this.createEndorserDid(createDidOptions.endorserDid, agent) return didCreateTxResult } } - private async createEndorserDid(endorserDid: string) { - return this.agent.dids.create({ + private async createEndorserDid(endorserDid: string, agent: AgentType) { + return agent.dids.create({ method: 'indy', options: { endorserMode: 'external', @@ -253,11 +253,11 @@ export class DidController extends Controller { }) } - private async createIndicioKey(createDidOptions: DidCreate) { + private async createIndicioKey(createDidOptions: DidCreate, agent: AgentType) { if (!createDidOptions.seed) { throw Error('Seed is required') } - const key = await this.agent.wallet.createKey({ + const key = await agent.wallet.createKey({ privateKey: TypedArrayEncoder.fromString(createDidOptions.seed), keyType: KeyType.Ed25519, }) @@ -284,8 +284,8 @@ export class DidController extends Controller { return body } - private async importDid(didMethod: string, did: string, seed: string) { - await this.agent.dids.import({ + private async importDid(didMethod: string, did: string, seed: string, agent: AgentType) { + await agent.dids.import({ did: `${didMethod}:${did}`, overwrite: true, privateKeys: [ @@ -297,7 +297,7 @@ export class DidController extends Controller { }) } - public async handleKey(didOptions: DidCreate) { + public async handleKey(didOptions: DidCreate, agent: AgentType) { let did let didResponse let didDocument @@ -313,12 +313,12 @@ export class DidController extends Controller { } if (!didOptions.did) { - await this.agent.wallet.createKey({ + await agent.wallet.createKey({ keyType: didOptions.keyType, seed: TypedArrayEncoder.fromString(didOptions.seed), }) - didResponse = await this.agent.dids.create({ + didResponse = await agent.dids.create({ method: DidMethod.Key, options: { keyType: KeyType.Ed25519, @@ -331,14 +331,14 @@ export class DidController extends Controller { didDocument = didResponse.didState.didDocument } else { did = didOptions.did - const createdDid = await this.agent.dids.getCreatedDids({ + const createdDid = await agent.dids.getCreatedDids({ method: DidMethod.Key, did: didOptions.did, }) didDocument = createdDid[0]?.didDocument } - await this.agent.dids.import({ + await agent.dids.import({ did, overwrite: true, didDocument, @@ -346,7 +346,7 @@ export class DidController extends Controller { return { did: did, didDocument: didDocument } } - public async handleWeb(didOptions: DidCreate) { + public async handleWeb(didOptions: DidCreate, agent: AgentType) { let didDocument: any if (!didOptions.domain) { throw Error('domain is required') @@ -368,7 +368,7 @@ export class DidController extends Controller { const did = `did:${didOptions.method}:${domain}` const keyId = `${did}#key-1` - const key = await this.agent.wallet.createKey({ + const key = await agent.wallet.createKey({ keyType: KeyType.Ed25519, privateKey: TypedArrayEncoder.fromString(didOptions.seed), }) @@ -388,7 +388,7 @@ export class DidController extends Controller { .build() } - await this.agent.dids.import({ + await agent.dids.import({ did, overwrite: true, didDocument, @@ -396,7 +396,7 @@ export class DidController extends Controller { return { did, didDocument } } - public async handlePolygon(createDidOptions: DidCreate) { + public async handlePolygon(createDidOptions: DidCreate, agent: AgentType) { // need to discuss try catch logic const { endpoint, network, privatekey } = createDidOptions if (network !== 'mainnet' && network !== 'testnet') { @@ -406,7 +406,7 @@ export class DidController extends Controller { throw Error('Invalid private key or not supported') } - return this.agent.dids.create({ + return agent.dids.create({ method: 'polygon', options: { network, @@ -419,9 +419,9 @@ export class DidController extends Controller { } @Get('/') - public async getDids(@Res() internalServerError: TsoaResponse<500, { message: string }>) { + public async getDids(@Request() request: Req, @Res() internalServerError: TsoaResponse<500, { message: string }>) { try { - const createdDids = await this.agent.dids.getCreatedDids() + const createdDids = await request.agent.dids.getCreatedDids() return createdDids } catch (error) { return internalServerError(500, { message: `something went wrong: ${error}` }) diff --git a/src/controllers/endorser-transaction/EndorserTransactionController.ts b/src/controllers/endorser-transaction/EndorserTransactionController.ts index aa7a2ebb..c43a287a 100644 --- a/src/controllers/endorser-transaction/EndorserTransactionController.ts +++ b/src/controllers/endorser-transaction/EndorserTransactionController.ts @@ -1,40 +1,40 @@ +import type { AgentType } from '../../types/request' import type { Version } from '../examples' +// eslint-disable-next-line import/order import type { IndyVdrDidCreateOptions } from '@aries-framework/indy-vdr' +// eslint-disable-next-line import/no-extraneous-dependencies import { getUnqualifiedCredentialDefinitionId, getUnqualifiedSchemaId, parseIndyCredentialDefinitionId, parseIndySchemaId, } from '@aries-framework/anoncreds' -import { Agent, AriesFrameworkError } from '@aries-framework/core' +// eslint-disable-next-line import/no-extraneous-dependencies +import { AriesFrameworkError } from '@aries-framework/core' +import { Request as Req } from 'express' import { injectable } from 'tsyringe' import { CredentialEnum } from '../../enums/enum' import { DidNymTransaction, EndorserTransaction, WriteTransaction } from '../types' -import { Body, Controller, Post, Res, Route, Tags, TsoaResponse, Security } from 'tsoa' +import { Body, Controller, Post, Res, Route, Tags, TsoaResponse, Security, Request } from 'tsoa' @Tags('EndorserTransaction') @Route('/transactions') -@Security('apiKey') +// @Security('apiKey') +@Security('jwt') @injectable() export class EndorserTransactionController extends Controller { - private agent: Agent - - public constructor(agent: Agent) { - super() - this.agent = agent - } - @Post('/endorse') public async endorserTransaction( + @Request() request: Req, @Body() endorserTransaction: EndorserTransaction, @Res() internalServerError: TsoaResponse<500, { message: string }>, @Res() forbiddenError: TsoaResponse<400, { reason: string }> ) { try { - const signedTransaction = await this.agent.modules.indyVdr.endorseTransaction( + const signedTransaction = await request.agent.modules.indyVdr.endorseTransaction( endorserTransaction.transaction, endorserTransaction.endorserDid ) @@ -54,11 +54,12 @@ export class EndorserTransactionController extends Controller { @Post('/set-endorser-role') public async didNymTransaction( + @Request() request: Req, @Body() didNymTransaction: DidNymTransaction, @Res() internalServerError: TsoaResponse<500, { message: string }> ) { try { - const didCreateSubmitResult = await this.agent.dids.create({ + const didCreateSubmitResult = await request.agent.dids.create({ did: didNymTransaction.did, options: { endorserMode: 'external', @@ -76,6 +77,7 @@ export class EndorserTransactionController extends Controller { @Post('/write') public async writeSchemaAndCredDefOnLedger( + @Request() request: Req, @Res() forbiddenError: TsoaResponse<400, { reason: string }>, @Res() internalServerError: TsoaResponse<500, { message: string }>, @Body() @@ -85,12 +87,14 @@ export class EndorserTransactionController extends Controller { if (writeTransaction.schema) { const writeSchema = await this.submitSchemaOnLedger( writeTransaction.schema, + request.agent, writeTransaction.endorsedTransaction ) return writeSchema } else if (writeTransaction.credentialDefinition) { const writeCredDef = await this.submitCredDefOnLedger( writeTransaction.credentialDefinition, + request.agent, writeTransaction.endorsedTransaction ) return writeCredDef @@ -116,11 +120,12 @@ export class EndorserTransactionController extends Controller { version: Version attributes: string[] }, + agent: AgentType, endorsedTransaction?: string ) { try { const { issuerId, name, version, attributes } = schema - const { schemaState } = await this.agent.modules.anoncreds.registerSchema({ + const { schemaState } = await agent.modules.anoncreds.registerSchema({ options: { endorserMode: 'external', endorsedTransaction, @@ -133,6 +138,10 @@ export class EndorserTransactionController extends Controller { }, }) + if (!schemaState.schemaId) { + throw Error('SchemaId not found') + } + const indySchemaId = parseIndySchemaId(schemaState.schemaId) const getSchemaUnqualifiedId = await getUnqualifiedSchemaId( indySchemaId.namespaceIdentifier, @@ -156,10 +165,11 @@ export class EndorserTransactionController extends Controller { value: unknown type: string }, + agent: AgentType, endorsedTransaction?: string ) { try { - const { credentialDefinitionState } = await this.agent.modules.anoncreds.registerCredentialDefinition({ + const { credentialDefinitionState } = await agent.modules.anoncreds.registerCredentialDefinition({ credentialDefinition, options: { endorserMode: 'external', @@ -167,6 +177,10 @@ export class EndorserTransactionController extends Controller { }, }) + if (!credentialDefinitionState.credentialDefinitionId) { + throw Error('Credential Definition Id not found') + } + const indyCredDefId = parseIndyCredentialDefinitionId(credentialDefinitionState.credentialDefinitionId) const getCredentialDefinitionId = await getUnqualifiedCredentialDefinitionId( indyCredDefId.namespaceIdentifier, diff --git a/src/controllers/multi-tenancy/MultiTenancyController.ts b/src/controllers/multi-tenancy/MultiTenancyController.ts index 152bf6b0..3aec4d7c 100644 --- a/src/controllers/multi-tenancy/MultiTenancyController.ts +++ b/src/controllers/multi-tenancy/MultiTenancyController.ts @@ -1,1676 +1,1663 @@ -import type { RestAgentModules, RestMultiTenantAgentModules } from '../../cliAgent' -import type { Version } from '../examples' -import type { RecipientKeyOption } from '../types' -import type { - AcceptProofRequestOptions, - ConnectionRecordProps, - CreateOutOfBandInvitationConfig, - CredentialProtocolVersionType, - KeyDidCreateOptions, - OutOfBandRecord, - ProofExchangeRecordProps, - ProofsProtocolVersionType, - Routing, -} from '@aries-framework/core' -import type { IndyVdrDidCreateOptions, IndyVdrDidCreateResult } from '@aries-framework/indy-vdr' -import type { QuestionAnswerRecord, ValidResponse } from '@aries-framework/question-answer' +import type { RestMultiTenantAgentModules } from '../../cliAgent' +import type { Agent } from '@aries-framework/core' import type { TenantRecord } from '@aries-framework/tenants' -import type { TenantAgent } from '@aries-framework/tenants/build/TenantAgent' -import type { PolygonDidCreateOptions } from '@ayanworks/credo-polygon-w3c-module/build/dids' - -import { - getUnqualifiedSchemaId, - getUnqualifiedCredentialDefinitionId, - parseIndyCredentialDefinitionId, - parseIndySchemaId, - AnonCredsError, -} from '@aries-framework/anoncreds' -import { - AcceptCredentialOfferOptions, - Agent, - AriesFrameworkError, - ConnectionRepository, - CredentialRepository, - CredentialState, - DidDocumentBuilder, - DidExchangeState, - HandshakeProtocol, - JsonTransformer, - Key, - KeyType, - OutOfBandInvitation, - RecordNotFoundError, - TypedArrayEncoder, - getBls12381G2Key2020, - getEd25519VerificationKey2018, - injectable, -} from '@aries-framework/core' -import { QuestionAnswerRole, QuestionAnswerState } from '@aries-framework/question-answer' -import axios from 'axios' - -import { CredentialEnum, DidMethod, Network, Role } from '../../enums/enum' -import { BCOVRIN_REGISTER_URL, INDICIO_NYM_URL } from '../../utils/util' -import { SchemaId, CredentialDefinitionId, RecordId, ProofRecordExample, ConnectionRecordExample } from '../examples' -import { - RequestProofOptions, - CreateOfferOptions, - CreateTenantOptions, - DidCreate, - DidNymTransaction, - EndorserTransaction, - ReceiveInvitationByUrlProps, - ReceiveInvitationProps, - WriteTransaction, - CreateProofRequestOobOptions, - CreateOfferOobOptions, -} from '../types' - -import { - Body, - Controller, - Delete, - Get, - Post, - Query, - Res, - Route, - Tags, - TsoaResponse, - Path, - Example, - Security, -} from 'tsoa' -@Tags('MultiTenancy') -@Route('/multi-tenancy') -@injectable() -export class MultiTenancyController extends Controller { - private readonly agent: Agent - - // Krish: can simply add 'private readonly' in constructor - public constructor(agent: Agent) { - super() - this.agent = agent - } - - //create wallet - @Security('apiKey') - @Post('/create-tenant') - public async createTenant( - @Body() createTenantOptions: CreateTenantOptions, - @Res() notFoundError: TsoaResponse<404, { reason: string }>, - @Res() internalServerError: TsoaResponse<500, { message: string }> - ) { - const { config } = createTenantOptions - try { - const tenantRecord: TenantRecord = await this.agent.modules.tenants.createTenant({ config }) - return tenantRecord - } catch (error) { - if (error instanceof RecordNotFoundError) { - return notFoundError(404, { - reason: `Tenant not created`, - }) - } - - return internalServerError(500, { message: `Something went wrong: ${error}` }) - } - } - - @Security('apiKey') - @Post('/create-did/:tenantId') - public async createDid( - @Body() createDidOptions: DidCreate, - @Path('tenantId') tenantId: string, - @Res() notFoundError: TsoaResponse<404, { reason: string }>, - @Res() internalServerError: TsoaResponse<500, { message: string }> - ) { - let didRes - - try { - if (!createDidOptions.method) { - throw Error('Method is required') - } - - let result - switch (createDidOptions.method) { - case DidMethod.Indy: - result = await this.handleIndy(createDidOptions, tenantId) - break - - case DidMethod.Key: - result = await this.handleKey(createDidOptions, tenantId) - break - - case DidMethod.Web: - result = await this.handleWeb(createDidOptions, tenantId) - break - - case DidMethod.Polygon: - result = await this.handlePolygon(createDidOptions, tenantId) - break - - default: - return internalServerError(500, { message: `Invalid method: ${createDidOptions.method}` }) - } - - didRes = { ...result } - - return didRes - } catch (error) { - if (error instanceof RecordNotFoundError) { - return notFoundError(404, { - reason: `Did not created`, - }) - } - - return internalServerError(500, { message: `Something went wrong: ${error}` }) - } - } - - private async handleIndy(createDidOptions: DidCreate, tenantId: string) { - let result - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - if (!createDidOptions.keyType) { - throw Error('keyType is required') - } - - if (!createDidOptions.seed) { - throw Error('Seed is required') - } - - if (!createDidOptions.network) { - throw Error('For indy method network is required') - } - - if (createDidOptions.keyType !== KeyType.Ed25519) { - throw Error('Only ed25519 key type supported') - } - - if (!Network.Bcovrin_Testnet && !Network.Indicio_Demonet && !Network.Indicio_Testnet) { - throw Error(`Invalid network for 'indy' method: ${createDidOptions.network}`) - } - switch (createDidOptions?.network?.toLowerCase()) { - case Network.Bcovrin_Testnet: - result = await this.handleBcovrin( - createDidOptions, - tenantAgent, - `did:${createDidOptions.method}:${createDidOptions.network}` - ) - break - - case Network.Indicio_Demonet: - case Network.Indicio_Testnet: - result = await this.handleIndicio( - createDidOptions, - tenantAgent, - `did:${createDidOptions.method}:${createDidOptions.network}` - ) - break - - default: - throw new Error(`Invalid network for 'indy' method: ${createDidOptions.network}`) - } - }) - return result - } - - private async handleBcovrin( - createDidOptions: DidCreate, - tenantAgent: TenantAgent, - didMethod: string - ) { - let didDocument - if (!createDidOptions.seed) { - throw Error('Seed is required') - } - if (createDidOptions.did) { - await this.importDid(didMethod, createDidOptions.did, createDidOptions.seed, tenantAgent) - const getDid = await tenantAgent.dids.getCreatedDids({ - method: createDidOptions.method, - did: `did:${createDidOptions.method}:${createDidOptions.network}:${createDidOptions.did}`, - }) - if (getDid.length > 0) { - didDocument = getDid[0].didDocument - } - return { - did: `${didMethod}:${createDidOptions.did}`, - didDocument: didDocument, - } - } else { - if (createDidOptions?.role?.toLowerCase() === Role.Endorser) { - await tenantAgent.wallet.createKey({ - privateKey: TypedArrayEncoder.fromString(createDidOptions.seed), - keyType: KeyType.Ed25519, - }) - - const body = { - role: 'ENDORSER', - alias: 'Alias', - seed: createDidOptions.seed, - } - - const res = await axios.post(BCOVRIN_REGISTER_URL, body) - if (res) { - const { did } = res?.data || {} - await this.importDid(didMethod, did, createDidOptions.seed, tenantAgent) - const didRecord = await tenantAgent.dids.getCreatedDids({ - method: DidMethod.Indy, - did: `did:${DidMethod.Indy}:${Network.Bcovrin_Testnet}:${res.data.did}`, - }) - - if (didRecord.length > 0) { - didDocument = didRecord[0].didDocument - } - - return { - did: `${didMethod}:${res.data.did}`, - didDocument: didDocument, - } - } - } else { - if (!createDidOptions.endorserDid) { - throw Error('endorserDid or role is required') - } - - const didCreateTxResult = (await this.agent.dids.create({ - method: DidMethod.Indy, - options: { - endorserMode: 'external', - endorserDid: createDidOptions.endorserDid ? createDidOptions.endorserDid : '', - }, - })) as IndyVdrDidCreateResult - return { did: didCreateTxResult.didState.did, didDocument: didCreateTxResult.didState.didDocument } - } - } - } - - private async handleIndicio( - createDidOptions: DidCreate, - tenantAgent: TenantAgent, - didMethod: string - ) { - let didDocument - if (!createDidOptions.seed) { - throw Error('Seed is required') - } - - if (createDidOptions.did) { - await this.importDid(didMethod, createDidOptions?.did, createDidOptions.seed, tenantAgent) - const getDid = await tenantAgent.dids.getCreatedDids({ - method: createDidOptions.method, - did: `did:${createDidOptions.method}:${createDidOptions.network}:${createDidOptions.did}`, - }) - if (getDid.length > 0) { - didDocument = getDid[0].didDocument - } - - return { - did: `${didMethod}:${createDidOptions.did}`, - didDocument: didDocument, - } - } else { - if (createDidOptions?.role?.toLowerCase() === Role.Endorser) { - return await this.handleEndorserCreation(createDidOptions, tenantAgent, didMethod) - } else { - return await this.handleIndyDidCreation(createDidOptions, tenantAgent) - } - } - } - - private async handleEndorserCreation( - createDidOptions: DidCreate, - tenantAgent: TenantAgent, - didMethod: string - ) { - let didDocument - if (!createDidOptions.seed) { - throw Error('Seed is required') - } - const key = await tenantAgent.wallet.createKey({ - privateKey: TypedArrayEncoder.fromString(createDidOptions.seed), - keyType: KeyType.Ed25519, - }) - const buffer = TypedArrayEncoder.fromBase58(key.publicKeyBase58) - - const did = TypedArrayEncoder.toBase58(buffer.slice(0, 16)) - - let body - if (createDidOptions.network === Network.Indicio_Testnet) { - body = { - network: 'testnet', - did, - verkey: TypedArrayEncoder.toBase58(buffer), - } - } else if (createDidOptions.network === Network.Indicio_Demonet) { - body = { - network: 'demonet', - did, - verkey: TypedArrayEncoder.toBase58(buffer), - } - } - const res = await axios.post(INDICIO_NYM_URL, body) - if (res.data.statusCode === 200) { - await this.importDid(didMethod, did, createDidOptions.seed, tenantAgent) - const didRecord = await tenantAgent.dids.getCreatedDids({ - method: DidMethod.Indy, - did: `${didMethod}:${body?.did}`, - }) - if (didRecord.length > 0) { - didDocument = didRecord[0].didDocument - } - - return { - did: `${didMethod}:${body?.did}`, - didDocument: didDocument, - } - } - } - - private async handleIndyDidCreation(createDidOptions: DidCreate, tenantAgent: TenantAgent) { - if (!createDidOptions.endorserDid) { - throw Error('endorserDid or role is required') - } - - const didCreateTxResult = await tenantAgent.dids.create({ - method: DidMethod.Indy, - options: { - endorserMode: 'external', - endorserDid: createDidOptions.endorserDid ? createDidOptions.endorserDid : '', - }, - }) - return { didTx: didCreateTxResult.didState.did } - } - - private async handleKey(createDidOptions: DidCreate, tenantId: string) { - let didResponse - let did: string - let didDocument: any - - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - if (!createDidOptions.seed) { - throw Error('Seed is required') - } - if (!createDidOptions.keyType) { - throw Error('keyType is required') - } - - if (createDidOptions.keyType !== KeyType.Ed25519 && createDidOptions.keyType !== KeyType.Bls12381g2) { - throw Error('Only ed25519 and bls12381g2 key type supported') - } - - if (!createDidOptions.did) { - await tenantAgent.wallet.createKey({ - keyType: createDidOptions.keyType, - seed: TypedArrayEncoder.fromString(createDidOptions.seed), - }) - const didKeyResponse = await tenantAgent.dids.create({ - method: DidMethod.Key, - options: { - keyType: KeyType.Ed25519, - }, - secret: { - privateKey: TypedArrayEncoder.fromString(createDidOptions.seed), - }, - }) - did = `${didKeyResponse.didState.did}` - didDocument = didKeyResponse.didState.didDocument - } else { - did = createDidOptions.did - const createdDid = await tenantAgent.dids.getCreatedDids({ - did: createDidOptions.did, - method: DidMethod.Key, - }) - didDocument = createdDid[0]?.didDocument - } - - await tenantAgent.dids.import({ - did, - overwrite: true, - didDocument, - }) - - didResponse = { - did, - didDocument, - } - }) - return didResponse - } - - private async handleWeb(createDidOptions: DidCreate, tenantId: string) { - let did - let didDocument: any - - if (!createDidOptions.domain) { - throw Error('For web method domain is required') - } - - if (!createDidOptions.keyType) { - throw Error('keyType is required') - } - - if (createDidOptions.keyType !== KeyType.Ed25519 && createDidOptions.keyType !== KeyType.Bls12381g2) { - throw Error('Only ed25519 and bls12381g2 key type supported') - } - - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - if (!createDidOptions.seed) { - throw Error('Seed is required') - } - - did = `did:${createDidOptions.method}:${createDidOptions.domain}` - const keyId = `${did}#key-1` - const key = await tenantAgent.wallet.createKey({ - keyType: createDidOptions.keyType, - seed: TypedArrayEncoder.fromString(createDidOptions.seed), - }) - if (createDidOptions.keyType === KeyType.Ed25519) { - didDocument = new DidDocumentBuilder(did) - .addContext('https://w3id.org/security/suites/ed25519-2018/v1') - .addVerificationMethod(getEd25519VerificationKey2018({ key, id: keyId, controller: did })) - .addAuthentication(keyId) - .build() - } - if (createDidOptions.keyType === KeyType.Bls12381g2) { - didDocument = new DidDocumentBuilder(did) - .addContext('https://w3id.org/security/bbs/v1') - .addVerificationMethod(getBls12381G2Key2020({ key, id: keyId, controller: did })) - .addAuthentication(keyId) - .build() - } - - await tenantAgent.dids.import({ - did, - overwrite: true, - didDocument, - }) - }) - return { did, didDocument } - } - - public async handlePolygon(createDidOptions: DidCreate, tenantId: string) { - let createDidResponse - let didResponse - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - // need to discuss try catch logic - - const networkDetails = createDidOptions.network - const networkName = networkDetails?.split(':')[1] - - const { endpoint, privatekey } = createDidOptions - if (networkName !== 'mainnet' && networkName !== 'testnet') { - throw Error('Invalid network type') - } - if (!privatekey || typeof privatekey !== 'string' || !privatekey.trim() || privatekey.length !== 64) { - throw Error('Invalid private key or not supported') - } - - createDidResponse = await tenantAgent.dids.create({ - method: DidMethod.Polygon, - options: { - network: networkName, - endpoint, - }, - secret: { - privateKey: TypedArrayEncoder.fromHex(`${privatekey}`), - }, - }) - didResponse = { - did: createDidResponse?.didState?.did, - didDoc: createDidResponse?.didState?.didDocument, - } - }) - return didResponse - } - - private async importDid(didMethod: string, did: string, seed: string, tenantAgent: TenantAgent) { - await tenantAgent.dids.import({ - did: `${didMethod}:${did}`, - overwrite: true, - privateKeys: [ - { - keyType: KeyType.Ed25519, - privateKey: TypedArrayEncoder.fromString(seed), - }, - ], - }) - } - - @Security('apiKey') - @Get('/dids/:tenantId') - public async getDids( - @Path('tenantId') tenantId: string, - @Res() internalServerError: TsoaResponse<500, { message: string }> - ) { - try { - let getDids - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - getDids = await tenantAgent.dids.getCreatedDids() - }) - return getDids - } catch (error) { - return internalServerError(500, { message: `something went wrong: ${error}` }) - } - } - - @Security('apiKey') - @Post('/transactions/set-endorser-role/:tenantId') - public async didNymTransaction( - @Path('tenantId') tenantId: string, - @Body() didNymTransaction: DidNymTransaction, - @Res() internalServerError: TsoaResponse<500, { message: string }> - ) { - let didCreateSubmitResult - try { - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - didCreateSubmitResult = await tenantAgent.dids.create({ - did: didNymTransaction.did, - options: { - endorserMode: 'external', - endorsedTransaction: { - nymRequest: didNymTransaction.nymRequest, - }, - }, - }) - await tenantAgent.dids.import({ - did: didNymTransaction.did, - overwrite: true, - }) - }) - - return didCreateSubmitResult - } catch (error) { - return internalServerError(500, { message: `something went wrong: ${error}` }) - } - } - - @Security('apiKey') - @Post('/transactions/endorse/:tenantId') - public async endorserTransaction( - @Path('tenantId') tenantId: string, - @Body() endorserTransaction: EndorserTransaction, - @Res() internalServerError: TsoaResponse<500, { message: string }>, - @Res() forbiddenError: TsoaResponse<400, { reason: string }> - ) { - let signedTransaction - try { - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - signedTransaction = await tenantAgent.modules.indyVdr.endorseTransaction( - endorserTransaction.transaction, - endorserTransaction.endorserDid - ) - }) - - return { signedTransaction } - } catch (error) { - if (error instanceof AriesFrameworkError) { - if (error.message.includes('UnauthorizedClientRequest')) { - return forbiddenError(400, { - reason: 'this action is not allowed.', - }) - } - } - - return internalServerError(500, { message: `something went wrong: ${error}` }) - } - } - - @Example(ConnectionRecordExample) - @Security('apiKey') - @Get('/connections/:connectionId/:tenantId') - public async getConnectionById( - @Path('tenantId') tenantId: string, - @Path('connectionId') connectionId: RecordId, - @Res() notFoundError: TsoaResponse<404, { reason: string }> - ) { - let connectionRecord - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - const connection = await tenantAgent.connections.findById(connectionId) - - if (!connection) - return notFoundError(404, { reason: `connection with connection id "${connectionId}" not found.` }) - connectionRecord = connection.toJSON() - }) - - return connectionRecord - } - - @Security('apiKey') - @Post('/create-invitation/:tenantId') - public async createInvitation( - @Res() internalServerError: TsoaResponse<500, { message: string }>, - @Path('tenantId') tenantId: string, - @Body() config?: Omit // props removed because of issues with serialization - ) { - let outOfBandRecord: OutOfBandRecord | undefined - try { - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - outOfBandRecord = await tenantAgent.oob.createInvitation(config) - }) - - return { - invitationUrl: outOfBandRecord?.outOfBandInvitation.toUrl({ - domain: this.agent.config.endpoints[0], - }), - invitation: outOfBandRecord?.outOfBandInvitation.toJSON({ - useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, - }), - outOfBandRecord: outOfBandRecord?.toJSON(), - } - } catch (error) { - return internalServerError(500, { message: `something went wrong: ${error}` }) - } - } - - @Security('apiKey') - @Post('/create-legacy-invitation/:tenantId') - public async createLegacyInvitation( - @Res() internalServerError: TsoaResponse<500, { message: string }>, - @Path('tenantId') tenantId: string, - @Body() - config?: Omit & RecipientKeyOption // props removed because of issues with serialization - ) { - let getInvitation - try { - let routing: Routing - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - if (config?.recipientKey) { - routing = { - endpoints: tenantAgent.config.endpoints, - routingKeys: [], - recipientKey: Key.fromPublicKeyBase58(config.recipientKey, KeyType.Ed25519), - mediatorId: undefined, - } - } else { - routing = await tenantAgent.mediationRecipient.getRouting({}) - } - const { outOfBandRecord, invitation } = await tenantAgent.oob.createLegacyInvitation({ ...config, routing }) - getInvitation = { - invitationUrl: invitation.toUrl({ - domain: this.agent.config.endpoints[0], - useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, - }), - invitation: invitation.toJSON({ - useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, - }), - outOfBandRecord: outOfBandRecord.toJSON(), - ...(config?.recipientKey ? {} : { recipientKey: routing.recipientKey.publicKeyBase58 }), - } - }) - - return getInvitation - } catch (error) { - return internalServerError(500, { message: `something went wrong: ${error}` }) - } - } - - @Security('apiKey') - @Post('/receive-invitation/:tenantId') - public async receiveInvitation( - @Body() invitationRequest: ReceiveInvitationProps, - @Path('tenantId') tenantId: string, - @Res() internalServerError: TsoaResponse<500, { message: string }> - ) { - let receiveInvitationRes - try { - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - const { invitation, ...config } = invitationRequest - const invite = new OutOfBandInvitation({ ...invitation, handshakeProtocols: invitation.handshake_protocols }) - const { outOfBandRecord, connectionRecord } = await tenantAgent.oob.receiveInvitation(invite, config) - receiveInvitationRes = { - outOfBandRecord: outOfBandRecord.toJSON(), - connectionRecord: connectionRecord?.toJSON(), - } - }) - - return receiveInvitationRes - } catch (error) { - return internalServerError(500, { message: `something went wrong: ${error}` }) - } - } - - @Security('apiKey') - @Post('/receive-invitation-url/:tenantId') - public async receiveInvitationFromUrl( - @Body() invitationRequest: ReceiveInvitationByUrlProps, - @Path('tenantId') tenantId: string, - @Res() internalServerError: TsoaResponse<500, { message: string }> - ) { - let receiveInvitationUrl - try { - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - const { invitationUrl, ...config } = invitationRequest - const { outOfBandRecord, connectionRecord } = await tenantAgent.oob.receiveInvitationFromUrl( - invitationUrl, - config - ) - receiveInvitationUrl = { - outOfBandRecord: outOfBandRecord.toJSON(), - connectionRecord: connectionRecord?.toJSON(), - } - }) - - return receiveInvitationUrl - } catch (error) { - return internalServerError(500, { message: `something went wrong: ${error}` }) - } - } - - @Security('apiKey') - @Get('/oob/:invitationId/:tenantId') - public async getAllOutOfBandRecords( - @Path('tenantId') tenantId: string, - @Res() internalServerError: TsoaResponse<500, { message: string }>, - @Path('invitationId') invitationId?: string - ) { - let outOfBandRecordsRes - try { - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - let outOfBandRecords - outOfBandRecords = await tenantAgent.oob.getAll() - - if (invitationId) - outOfBandRecords = outOfBandRecords.filter((o: any) => o.outOfBandInvitation.id === invitationId) - outOfBandRecordsRes = outOfBandRecords.map((c: any) => c.toJSON()) - }) - - return outOfBandRecordsRes - } catch (error) { - return internalServerError(500, { message: `something went wrong: ${error}` }) - } - } - - @Security('apiKey') - @Get('/connections/:tenantId') - public async getAllConnections( - @Path('tenantId') tenantId: string, - @Res() internalServerError: TsoaResponse<500, { message: string }>, - @Query('outOfBandId') outOfBandId?: string, - @Query('alias') alias?: string, - @Query('state') state?: DidExchangeState, - @Query('myDid') myDid?: string, - @Query('theirDid') theirDid?: string, - @Query('theirLabel') theirLabel?: string - ) { - let connectionRecord - try { - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - if (outOfBandId) { - connectionRecord = await tenantAgent.connections.findAllByOutOfBandId(outOfBandId) - } else { - const connectionRepository = tenantAgent.dependencyManager.resolve(ConnectionRepository) - - const connections = await connectionRepository.findByQuery(tenantAgent.context, { - alias, - myDid, - theirDid, - theirLabel, - state, - }) - - connectionRecord = connections.map((c: any) => c.toJSON()) - } - }) - return connectionRecord - } catch (error) { - return internalServerError(500, { message: `something went wrong: ${error}` }) - } - } - - @Get('/url/:tenantId/:invitationId') - public async getInvitation( - @Path('invitationId') invitationId: string, - @Path('tenantId') tenantId: string, - @Res() notFoundError: TsoaResponse<404, { reason: string }> - ) { - let invitationJson - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - const outOfBandRecord = await tenantAgent.oob.findByCreatedInvitationId(invitationId) - - if (!outOfBandRecord || outOfBandRecord.state !== 'await-response') - return notFoundError(404, { reason: `connection with invitationId "${invitationId}" not found.` }) - - invitationJson = outOfBandRecord.outOfBandInvitation.toJSON({ useDidSovPrefixWhereAllowed: true }) - }) - return invitationJson - } - - @Security('apiKey') - @Post('/schema/:tenantId') - public async createSchema( - @Body() - schema: { - issuerId: string - name: string - version: Version - attributes: string[] - endorse?: boolean - endorserDid?: string - }, - @Path('tenantId') tenantId: string, - @Res() forbiddenError: TsoaResponse<400, { reason: string }>, - @Res() internalServerError: TsoaResponse<500, { message: string }> - ) { - let schemaRecord - try { - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - if (!schema.endorse) { - const { schemaState } = await tenantAgent.modules.anoncreds.registerSchema({ - schema: { - issuerId: schema.issuerId, - name: schema.name, - version: schema.version, - attrNames: schema.attributes, - }, - options: { - endorserMode: 'internal', - endorserDid: schema.issuerId, - }, - }) - - if (!schemaState.schemaId) { - throw Error('SchemaId not found') - } - - const indySchemaId = parseIndySchemaId(schemaState.schemaId) - const getSchemaId = await getUnqualifiedSchemaId( - indySchemaId.namespaceIdentifier, - indySchemaId.schemaName, - indySchemaId.schemaVersion - ) - if (schemaState.state === CredentialEnum.Finished) { - schemaState.schemaId = getSchemaId - } - - schemaRecord = schemaState - } else { - if (!schema.endorserDid) { - throw new Error('Please provide the endorser DID') - } - - const createSchemaTxResult = await tenantAgent.modules.anoncreds.registerSchema({ - options: { - endorserMode: 'external', - endorserDid: schema.endorserDid ? schema.endorserDid : '', - }, - schema: { - attrNames: schema.attributes, - issuerId: schema.issuerId, - name: schema.name, - version: schema.version, - }, - }) - - schemaRecord = createSchemaTxResult - } - }) - - return schemaRecord - } catch (error) { - if (error instanceof AriesFrameworkError) { - if (error.message.includes('UnauthorizedClientRequest')) { - return forbiddenError(400, { - reason: 'this action is not allowed.', - }) - } - } - - return internalServerError(500, { message: `something went wrong: ${error}` }) - } - } - - @Security('apiKey') - @Post('/polygon-wc3/schema/:tenantId') - public async createPolygonW3CSchema( - @Body() - createSchemaRequest: { - did: string - schemaName: string - schema: object - }, - @Path('tenantId') tenantId: string, - @Res() internalServerError: TsoaResponse<500, { message: string }> - ): Promise { - try { - let schemaResponse - const { did, schemaName, schema } = createSchemaRequest - if (!did || !schemaName || !schema) { - throw Error('One or more parameters are empty or undefined.') - } - - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - //need to add the return type after adding the scham URL - schemaResponse = await tenantAgent.modules.polygon.createSchema({ - did, - schemaName, - schema, - }) - }) - return schemaResponse - } catch (error) { - return internalServerError(500, { message: `something went wrong: ${error}` }) - } - } - - @Security('apiKey') - @Get('polygon-wc3/schema/:did/:schemaId/:tenantId') - public async getPolygonW3CSchemaById( - @Path('tenantId') tenantId: string, - @Path('did') did: string, - @Path('schemaId') schemaId: string, - @Res() internalServerError: TsoaResponse<500, { message: string }>, - @Res() badRequestError: TsoaResponse<400, { reason: string }>, - @Res() forbiddenError: TsoaResponse<401, { reason: string }> - ): Promise { - if (!tenantId || !did || !schemaId) { - return badRequestError(400, { reason: 'Missing or invalid parameters.' }) - } - - try { - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - return tenantAgent.modules.polygon.getSchemaById(did, schemaId) - }) - } catch (error) { - if (error instanceof AriesFrameworkError) { - if (error.message.includes('UnauthorizedClientRequest')) { - return forbiddenError(401, { - reason: 'this action is not allowed.', - }) - } - } - return internalServerError(500, { message: `something went wrong: ${error}` }) - } - } - - @Security('apiKey') - @Post('/transactions/write/:tenantId') - public async writeSchemaAndCredDefOnLedger( - @Path('tenantId') tenantId: string, - @Res() forbiddenError: TsoaResponse<400, { reason: string }>, - @Res() internalServerError: TsoaResponse<500, { message: string }>, - @Body() - writeTransaction: WriteTransaction - ) { - try { - if (writeTransaction.schema) { - const writeSchema = await this.submitSchemaOnLedger( - writeTransaction.schema, - writeTransaction.endorsedTransaction, - tenantId - ) - return writeSchema - } else if (writeTransaction.credentialDefinition) { - const writeCredDef = await this.submitCredDefOnLedger( - writeTransaction.credentialDefinition, - writeTransaction.endorsedTransaction, - tenantId - ) - return writeCredDef - } else { - throw new Error('Please provide valid schema or credential-def!') - } - } catch (error) { - if (error instanceof AriesFrameworkError) { - if (error.message.includes('UnauthorizedClientRequest')) { - return forbiddenError(400, { - reason: 'this action is not allowed.', - }) - } - } - return internalServerError(500, { message: `something went wrong: ${error}` }) - } - } - - public async submitSchemaOnLedger( - schema: { - issuerId: string - name: string - version: Version - attributes: string[] - }, - endorsedTransaction: string, - tenantId: string - ) { - let schemaRecord - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - const { issuerId, name, version, attributes } = schema - const { schemaState } = await tenantAgent.modules.anoncreds.registerSchema({ - options: { - endorserMode: 'external', - endorsedTransaction, - }, - schema: { - attrNames: attributes, - issuerId: issuerId, - name: name, - version: version, - }, - }) - - if (!schemaState.schemaId) { - throw Error('SchemaId not found') - } - - const indySchemaId = parseIndySchemaId(schemaState.schemaId) - const getSchemaUnqualifiedId = await getUnqualifiedSchemaId( - indySchemaId.namespaceIdentifier, - indySchemaId.schemaName, - indySchemaId.schemaVersion - ) - if (schemaState.state === CredentialEnum.Finished || schemaState.state === CredentialEnum.Action) { - schemaState.schemaId = getSchemaUnqualifiedId - } - schemaRecord = schemaState - }) - return schemaRecord - } - - public async submitCredDefOnLedger( - credentialDefinition: { - schemaId: string - issuerId: string - tag: string - value: unknown - type: string - }, - endorsedTransaction: string, - tenantId: string - ) { - let credentialDefinitionRecord - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - const { credentialDefinitionState } = await tenantAgent.modules.anoncreds.registerCredentialDefinition({ - credentialDefinition, - options: { - endorserMode: 'external', - endorsedTransaction: endorsedTransaction, - }, - }) - - if (!credentialDefinitionState.credentialDefinitionId) { - throw Error('Credential Definition Id not found') - } - - const indyCredDefId = parseIndyCredentialDefinitionId(credentialDefinitionState.credentialDefinitionId) - const getCredentialDefinitionId = await getUnqualifiedCredentialDefinitionId( - indyCredDefId.namespaceIdentifier, - indyCredDefId.schemaSeqNo, - indyCredDefId.tag - ) - if ( - credentialDefinitionState.state === CredentialEnum.Finished || - credentialDefinitionState.state === CredentialEnum.Action - ) { - credentialDefinitionState.credentialDefinitionId = getCredentialDefinitionId - } - - credentialDefinitionRecord = credentialDefinitionState - }) - return credentialDefinitionRecord - } - - @Security('apiKey') - @Get('/schema/:schemaId/:tenantId') - public async getSchemaById( - @Path('schemaId') schemaId: SchemaId, - @Path('tenantId') tenantId: string, - @Res() notFoundError: TsoaResponse<404, { reason: string }>, - @Res() forbiddenError: TsoaResponse<403, { reason: string }>, - @Res() badRequestError: TsoaResponse<400, { reason: string }>, - @Res() internalServerError: TsoaResponse<500, { message: string }> - ) { - let getSchema - try { - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - getSchema = await tenantAgent.modules.anoncreds.getSchema(schemaId) - }) - - return getSchema - } catch (error) { - if (error instanceof AnonCredsError && error.message === 'IndyError(LedgerNotFound): LedgerNotFound') { - return notFoundError(404, { - reason: `schema definition with schemaId "${schemaId}" not found.`, - }) - } else if (error instanceof AnonCredsError && error.cause instanceof AnonCredsError) { - if ((error.cause.cause, 'LedgerInvalidTransaction')) { - return forbiddenError(403, { - reason: `schema definition with schemaId "${schemaId}" can not be returned.`, - }) - } - if ((error.cause.cause, 'CommonInvalidStructure')) { - return badRequestError(400, { - reason: `schemaId "${schemaId}" has invalid structure.`, - }) - } - } - - return internalServerError(500, { message: `something went wrong: ${error}` }) - } - } - - @Security('apiKey') - @Post('/credential-definition/:tenantId') - public async createCredentialDefinition( - @Body() - credentialDefinitionRequest: { - issuerId: string - schemaId: string - tag: string - endorse?: boolean - endorserDid?: string - }, - @Path('tenantId') tenantId: string, - @Res() notFoundError: TsoaResponse<404, { reason: string }>, - @Res() internalServerError: TsoaResponse<500, { message: string }> - ) { - let credentialDefinitionRecord - try { - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - credentialDefinitionRequest.endorse = credentialDefinitionRequest.endorse - ? credentialDefinitionRequest.endorse - : false - - if (!credentialDefinitionRequest.endorse) { - const { credentialDefinitionState } = await tenantAgent.modules.anoncreds.registerCredentialDefinition({ - credentialDefinition: { - issuerId: credentialDefinitionRequest.issuerId, - schemaId: credentialDefinitionRequest.schemaId, - tag: credentialDefinitionRequest.tag, - }, - options: {}, - }) - - if (!credentialDefinitionState?.credentialDefinitionId) { - throw new Error('Credential Definition Id not found') - } - const indyCredDefId = parseIndyCredentialDefinitionId(credentialDefinitionState.credentialDefinitionId) - const getCredentialDefinitionId = await getUnqualifiedCredentialDefinitionId( - indyCredDefId.namespaceIdentifier, - indyCredDefId.schemaSeqNo, - indyCredDefId.tag - ) - if (credentialDefinitionState.state === CredentialEnum.Finished) { - credentialDefinitionState.credentialDefinitionId = getCredentialDefinitionId - } - - credentialDefinitionRecord = credentialDefinitionState - } else { - const createCredDefTxResult = await tenantAgent.modules.anoncreds.registerCredentialDefinition({ - credentialDefinition: { - issuerId: credentialDefinitionRequest.issuerId, - tag: credentialDefinitionRequest.tag, - schemaId: credentialDefinitionRequest.schemaId, - type: 'CL', - }, - options: { - endorserMode: 'external', - endorserDid: credentialDefinitionRequest.endorserDid ? credentialDefinitionRequest.endorserDid : '', - }, - }) - - credentialDefinitionRecord = createCredDefTxResult - } - }) - - return credentialDefinitionRecord - } catch (error) { - if (error instanceof notFoundError) { - return notFoundError(404, { - reason: `schema with schemaId "${credentialDefinitionRequest.schemaId}" not found.`, - }) - } - - return internalServerError(500, { message: `something went wrong: ${error}` }) - } - } - - @Security('apiKey') - @Get('/credential-definition/:credentialDefinitionId/:tenantId') - public async getCredentialDefinitionById( - @Path('credentialDefinitionId') credentialDefinitionId: CredentialDefinitionId, - @Path('tenantId') tenantId: string, - @Res() badRequestError: TsoaResponse<400, { reason: string }>, - @Res() notFoundError: TsoaResponse<404, { reason: string }>, - @Res() internalServerError: TsoaResponse<500, { message: string }> - ) { - let getCredDef - try { - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - getCredDef = await tenantAgent.modules.anoncreds.getCredentialDefinition(credentialDefinitionId) - }) - - return getCredDef - } catch (error) { - if (error instanceof AriesFrameworkError && error.message === 'IndyError(LedgerNotFound): LedgerNotFound') { - return notFoundError(404, { - reason: `credential definition with credentialDefinitionId "${credentialDefinitionId}" not found.`, - }) - } else if (error instanceof AnonCredsError && error.cause instanceof AriesFrameworkError) { - if ((error.cause.cause, 'CommonInvalidStructure')) { - return badRequestError(400, { - reason: `credentialDefinitionId "${credentialDefinitionId}" has invalid structure.`, - }) - } - } - - return internalServerError(500, { message: `something went wrong: ${error}` }) - } - } - - @Security('apiKey') - @Post('/credentials/create-offer/:tenantId') - public async createOffer( - @Body() createOfferOptions: CreateOfferOptions, - @Path('tenantId') tenantId: string, - @Res() internalServerError: TsoaResponse<500, { message: string }> - ) { - let offer - try { - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - offer = await tenantAgent.credentials.offerCredential({ - connectionId: createOfferOptions.connectionId, - protocolVersion: createOfferOptions.protocolVersion as CredentialProtocolVersionType<[]>, - credentialFormats: createOfferOptions.credentialFormats, - autoAcceptCredential: createOfferOptions.autoAcceptCredential, - }) - }) - - return offer - } catch (error) { - return internalServerError(500, { message: `something went wrong: ${error}` }) - } - } - - @Security('apiKey') - @Post('/credentials/create-offer-oob/:tenantId') - public async createOfferOob( - @Path('tenantId') tenantId: string, - @Body() createOfferOptions: CreateOfferOobOptions, - @Res() internalServerError: TsoaResponse<500, { message: string }> - ) { - let createOfferOobRecord - - try { - let routing: Routing - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - const linkSecretIds = await tenantAgent.modules.anoncreds.getLinkSecretIds() - if (linkSecretIds.length === 0) { - await tenantAgent.modules.anoncreds.createLinkSecret() - } - - if (createOfferOptions?.recipientKey) { - routing = { - endpoints: tenantAgent.config.endpoints, - routingKeys: [], - recipientKey: Key.fromPublicKeyBase58(createOfferOptions.recipientKey, KeyType.Ed25519), - mediatorId: undefined, - } - } else { - routing = await tenantAgent.mediationRecipient.getRouting({}) - } - - const offerOob = await tenantAgent.credentials.createOffer({ - protocolVersion: createOfferOptions.protocolVersion as CredentialProtocolVersionType<[]>, - credentialFormats: createOfferOptions.credentialFormats, - autoAcceptCredential: createOfferOptions.autoAcceptCredential, - comment: createOfferOptions.comment, - }) - - const credentialMessage = offerOob.message - const outOfBandRecord = await tenantAgent.oob.createInvitation({ - label: createOfferOptions.label, - handshakeProtocols: [HandshakeProtocol.Connections], - messages: [credentialMessage], - autoAcceptConnection: true, - imageUrl: createOfferOptions?.imageUrl, - goalCode: createOfferOptions?.goalCode, - routing, - }) - - createOfferOobRecord = { - invitationUrl: outOfBandRecord.outOfBandInvitation.toUrl({ - domain: this.agent.config.endpoints[0], - }), - invitation: outOfBandRecord.outOfBandInvitation.toJSON({ - useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, - }), - outOfBandRecord: outOfBandRecord.toJSON(), - outOfBandRecordId: outOfBandRecord.id, - recipientKey: createOfferOptions?.recipientKey ? {} : { recipientKey: routing.recipientKey.publicKeyBase58 }, - } - }) - return createOfferOobRecord - } catch (error) { - return internalServerError(500, { message: `something went wrong: ${error}` }) - } - } - - @Security('apiKey') - @Post('/credentials/accept-offer/:tenantId') - public async acceptOffer( - @Res() notFoundError: TsoaResponse<404, { reason: string }>, - @Res() internalServerError: TsoaResponse<500, { message: string }>, - @Path('tenantId') tenantId: string, - @Body() acceptCredentialOfferOptions: AcceptCredentialOfferOptions - ) { - let acceptOffer - try { - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - const linkSecretIds = await tenantAgent.modules.anoncreds.getLinkSecretIds() - if (linkSecretIds.length === 0) { - await tenantAgent.modules.anoncreds.createLinkSecret() - } - acceptOffer = await tenantAgent.credentials.acceptOffer({ - credentialRecordId: acceptCredentialOfferOptions.credentialRecordId, - credentialFormats: acceptCredentialOfferOptions.credentialFormats, - autoAcceptCredential: acceptCredentialOfferOptions.autoAcceptCredential, - comment: acceptCredentialOfferOptions.comment, - }) - }) - - return acceptOffer - } catch (error) { - if (error instanceof RecordNotFoundError) { - return notFoundError(404, { - reason: `credential with credential record id "${acceptCredentialOfferOptions.credentialRecordId}" not found.`, - }) - } - - return internalServerError(500, { message: `something went wrong: ${error}` }) - } - } - - @Security('apiKey') - @Get('/credentials/:credentialRecordId/:tenantId') - public async getCredentialById( - @Path('credentialRecordId') credentialRecordId: RecordId, - @Path('tenantId') tenantId: string, - @Res() notFoundError: TsoaResponse<404, { reason: string }>, - @Res() internalServerError: TsoaResponse<500, { message: string }> - ) { - let credentialRecord - try { - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - const credential = await tenantAgent.credentials.getById(credentialRecordId) - credentialRecord = credential.toJSON() - }) - - return credentialRecord - } catch (error) { - if (error instanceof RecordNotFoundError) { - return notFoundError(404, { - reason: `credential with credential record id "${credentialRecordId}" not found.`, - }) - } - - return internalServerError(500, { message: `something went wrong: ${error}` }) - } - } +// eslint-disable-next-line import/no-extraneous-dependencies +import { JsonTransformer, RecordNotFoundError, injectable } from '@aries-framework/core' +import { Request as Req } from 'express' +import jwt from 'jsonwebtoken' - @Security('apiKey') - @Get('/credentials/:tenantId') - public async getAllCredentials( - @Path('tenantId') tenantId: string, - @Query('threadId') threadId?: string, - @Query('connectionId') connectionId?: string, - @Query('state') state?: CredentialState - ) { - let credentialRecord - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - const credentialRepository = tenantAgent.dependencyManager.resolve(CredentialRepository) - const credentials = await credentialRepository.findByQuery(tenantAgent.context, { - connectionId, - threadId, - state, - }) - credentialRecord = credentials.map((c: any) => c.toJSON()) - }) - return credentialRecord - } +import { AgentRole } from '../../enums/enum' +import { generateSecretKey } from '../../utils/common.service' +import { CreateTenantOptions } from '../types' - @Security('apiKey') - @Get('/proofs/:tenantId') - public async getAllProofs(@Path('tenantId') tenantId: string, @Query('threadId') threadId?: string) { - let proofRecord - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - let proofs = await tenantAgent.proofs.getAll() - if (threadId) proofs = proofs.filter((p: any) => p.threadId === threadId) - proofRecord = proofs.map((proof: any) => proof.toJSON()) - }) - return proofRecord - } +import { Body, Controller, Delete, Post, Res, Route, Tags, TsoaResponse, Path, Security, Request, Get } from 'tsoa' - @Security('apiKey') - @Get('/form-data/:tenantId/:proofRecordId') - @Example(ProofRecordExample) - public async proofFormData( - @Path('proofRecordId') proofRecordId: string, - @Path('tenantId') tenantId: string, +@Tags('MultiTenancy') +@Route('/multi-tenancy') +@injectable() +export class MultiTenancyController extends Controller { + //create wallet + // @Security('apiKey') + @Security('jwt') + @Post('/create-tenant') + public async createTenant( + @Request() request: Req, + @Body() createTenantOptions: CreateTenantOptions, @Res() notFoundError: TsoaResponse<404, { reason: string }>, @Res() internalServerError: TsoaResponse<500, { message: string }> ) { - let proof + const { config } = createTenantOptions try { - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - proof = await tenantAgent.proofs.getFormatData(proofRecordId) - }) - return proof + const agent = request.agent as Agent + const tenantRecord: TenantRecord = await agent.modules.tenants.createTenant({ config }) + return tenantRecord } catch (error) { if (error instanceof RecordNotFoundError) { return notFoundError(404, { - reason: `proof with proofRecordId "${proofRecordId}" not found.`, + reason: `Tenant not created`, }) } - return internalServerError(500, { message: `something went wrong: ${error}` }) - } - } - - @Security('apiKey') - @Post('/proofs/request-proof/:tenantId') - @Example(ProofRecordExample) - public async requestProof( - @Body() requestProofOptions: RequestProofOptions, - @Path('tenantId') tenantId: string, - @Res() notFoundError: TsoaResponse<404, { reason: string }>, - @Res() internalServerError: TsoaResponse<500, { message: string }> - ) { - let proof - try { - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - const requestProofPayload = { - connectionId: requestProofOptions.connectionId, - protocolVersion: requestProofOptions.protocolVersion as ProofsProtocolVersionType<[]>, - comment: requestProofOptions.comment, - proofFormats: requestProofOptions.proofFormats, - autoAcceptProof: requestProofOptions.autoAcceptProof, - goalCode: requestProofOptions.goalCode, - parentThreadId: requestProofOptions.parentThreadId, - willConfirm: requestProofOptions.willConfirm, - } - proof = await tenantAgent.proofs.requestProof(requestProofPayload) - }) - - return proof - } catch (error) { - return internalServerError(500, { message: `something went wrong: ${error}` }) - } - } - - @Security('apiKey') - @Post('/proofs/create-request-oob/:tenantId') - public async createRequest( - @Path('tenantId') tenantId: string, - @Body() createRequestOptions: CreateProofRequestOobOptions, - @Res() internalServerError: TsoaResponse<500, { message: string }> - ) { - let oobProofRecord - try { - let routing: Routing - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - if (createRequestOptions?.recipientKey) { - routing = { - endpoints: tenantAgent.config.endpoints, - routingKeys: [], - recipientKey: Key.fromPublicKeyBase58(createRequestOptions.recipientKey, KeyType.Ed25519), - mediatorId: undefined, - } - } else { - routing = await tenantAgent.mediationRecipient.getRouting({}) - } - const proof = await tenantAgent.proofs.createRequest({ - protocolVersion: createRequestOptions.protocolVersion as ProofsProtocolVersionType<[]>, - proofFormats: createRequestOptions.proofFormats, - goalCode: createRequestOptions.goalCode, - willConfirm: createRequestOptions.willConfirm, - parentThreadId: createRequestOptions.parentThreadId, - autoAcceptProof: createRequestOptions.autoAcceptProof, - comment: createRequestOptions.comment, - }) - - const proofMessage = proof.message - const outOfBandRecord = await tenantAgent.oob.createInvitation({ - label: createRequestOptions.label, - handshakeProtocols: [HandshakeProtocol.Connections], - messages: [proofMessage], - autoAcceptConnection: true, - imageUrl: createRequestOptions?.imageUrl, - routing, - goalCode: createRequestOptions?.goalCode, - }) - - oobProofRecord = { - invitationUrl: outOfBandRecord.outOfBandInvitation.toUrl({ - domain: this.agent.config.endpoints[0], - }), - invitation: outOfBandRecord.outOfBandInvitation.toJSON({ - useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, - }), - outOfBandRecord: outOfBandRecord.toJSON(), - proofRecordThId: proof.proofRecord.threadId, - proofMessageId: proof.message.thread?.threadId - ? proof.message.thread?.threadId - : proof.message.threadId - ? proof.message.thread - : proof.message.id, - recipientKey: createRequestOptions?.recipientKey - ? {} - : { recipientKey: routing.recipientKey.publicKeyBase58 }, - } - }) - - return oobProofRecord - } catch (error) { - return internalServerError(500, { message: `something went wrong: ${error}` }) + return internalServerError(500, { message: `Something went wrong: ${error}` }) } } @Security('apiKey') - @Post('/proofs/:proofRecordId/accept-request/:tenantId') - @Example(ProofRecordExample) - public async acceptRequest( + @Get(':tenantId') + public async getTenantById( + @Request() request: Req, @Path('tenantId') tenantId: string, - @Path('proofRecordId') proofRecordId: string, - @Body() - request: { - filterByPresentationPreview?: boolean - filterByNonRevocationRequirements?: boolean - comment?: string - }, @Res() notFoundError: TsoaResponse<404, { reason: string }>, @Res() internalServerError: TsoaResponse<500, { message: string }> ) { - let proofRecord try { - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - const requestedCredentials = await tenantAgent.proofs.selectCredentialsForRequest({ - proofRecordId, - }) - - const acceptProofRequest: AcceptProofRequestOptions = { - proofRecordId, - comment: request.comment, - proofFormats: requestedCredentials.proofFormats, - } - - const proof = await tenantAgent.proofs.acceptRequest(acceptProofRequest) - - proofRecord = proof.toJSON() - }) - return proofRecord + const agent = request.agent as Agent + const getTenant = await agent.modules.tenants.getTenantById(tenantId) + return JsonTransformer.toJSON(getTenant) } catch (error) { if (error instanceof RecordNotFoundError) { return notFoundError(404, { - reason: `proof with proofRecordId "${proofRecordId}" not found.`, + reason: `Tenant with id: ${tenantId} not found.`, }) } - - return internalServerError(500, { message: `something went wrong: ${error}` }) + return internalServerError(500, { message: `Something went wrong: ${error}` }) } } - @Security('apiKey') - @Post('/proofs/:proofRecordId/accept-presentation/:tenantId') - @Example(ProofRecordExample) - public async acceptPresentation( + @Security('jwt', ['multi-tenant']) + @Post('/get-token/:tenantId') + public async getTenantToken( + @Request() request: Req, @Path('tenantId') tenantId: string, - @Path('proofRecordId') proofRecordId: string, @Res() notFoundError: TsoaResponse<404, { reason: string }>, @Res() internalServerError: TsoaResponse<500, { message: string }> ) { - let proof try { - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - proof = await tenantAgent.proofs.acceptPresentation({ proofRecordId }) + const agent = request.agent as unknown as Agent + let secretKey + await agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + const genericRecord = await tenantAgent.genericRecords.getAll() + const records = genericRecord.find((record) => record?.content?.secretKey !== undefined) + secretKey = records?.content.secretKey as string }) - return proof - } catch (error) { - if (error instanceof RecordNotFoundError) { - return notFoundError(404, { - reason: `proof with proofRecordId "${proofRecordId}" not found.`, - }) + if (!secretKey) { + throw new RecordNotFoundError('secretKey does not exist in wallet', { recordType: 'debug', cause: undefined }) } - return internalServerError(500, { message: `something went wrong: ${error}` }) - } - } + const token = await this.createToken(agent, tenantId, secretKey) - @Security('apiKey') - @Get('/proofs/:proofRecordId/:tenantId') - @Example(ProofRecordExample) - public async getProofById( - @Path('tenantId') tenantId: string, - @Path('proofRecordId') proofRecordId: RecordId, - @Res() notFoundError: TsoaResponse<404, { reason: string }>, - @Res() internalServerError: TsoaResponse<500, { message: string }> - ) { - let proofRecord - try { - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - const proof = await tenantAgent.proofs.getById(proofRecordId) - proofRecord = proof.toJSON() - }) - return proofRecord + return { token: token } } catch (error) { if (error instanceof RecordNotFoundError) { return notFoundError(404, { - reason: `proof with proofRecordId "${proofRecordId}" not found.`, + reason: `SecretKey not found`, }) } - return internalServerError(500, { message: `something went wrong: ${error}` }) + return internalServerError(500, { message: `Something went wrong: ${error}` }) } } - @Security('apiKey') + // @Security('apiKey') + // @Post('/create-did/:tenantId') + // public async createDid( + // @Body() createDidOptions: DidCreate, + // @Path('tenantId') tenantId: string, + // @Res() notFoundError: TsoaResponse<404, { reason: string }>, + // @Res() internalServerError: TsoaResponse<500, { message: string }> + // ) { + // let didRes + + // try { + // if (!createDidOptions.method) { + // throw Error('Method is required') + // } + + // let result + // switch (createDidOptions.method) { + // case DidMethod.Indy: + // result = await this.handleIndy(createDidOptions, tenantId) + // break + + // case DidMethod.Key: + // result = await this.handleKey(createDidOptions, tenantId) + // break + + // case DidMethod.Web: + // result = await this.handleWeb(createDidOptions, tenantId) + // break + + // case DidMethod.Polygon: + // result = await this.handlePolygon(createDidOptions, tenantId) + // break + + // default: + // return internalServerError(500, { message: `Invalid method: ${createDidOptions.method}` }) + // } + + // didRes = { ...result } + + // return didRes + // } catch (error) { + // if (error instanceof RecordNotFoundError) { + // return notFoundError(404, { + // reason: `Did not created`, + // }) + // } + + // return internalServerError(500, { message: `Something went wrong: ${error}` }) + // } + // } + + // private async handleIndy(createDidOptions: DidCreate, tenantId: string) { + // let result + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // if (!createDidOptions.keyType) { + // throw Error('keyType is required') + // } + + // if (!createDidOptions.seed) { + // throw Error('Seed is required') + // } + + // if (!createDidOptions.network) { + // throw Error('For indy method network is required') + // } + + // if (createDidOptions.keyType !== KeyType.Ed25519) { + // throw Error('Only ed25519 key type supported') + // } + + // if (!Network.Bcovrin_Testnet && !Network.Indicio_Demonet && !Network.Indicio_Testnet) { + // throw Error(`Invalid network for 'indy' method: ${createDidOptions.network}`) + // } + // switch (createDidOptions?.network?.toLowerCase()) { + // case Network.Bcovrin_Testnet: + // result = await this.handleBcovrin( + // createDidOptions, + // tenantAgent, + // `did:${createDidOptions.method}:${createDidOptions.network}` + // ) + // break + + // case Network.Indicio_Demonet: + // case Network.Indicio_Testnet: + // result = await this.handleIndicio( + // createDidOptions, + // tenantAgent, + // `did:${createDidOptions.method}:${createDidOptions.network}` + // ) + // break + + // default: + // throw new Error(`Invalid network for 'indy' method: ${createDidOptions.network}`) + // } + // }) + // return result + // } + + // private async handleBcovrin( + // createDidOptions: DidCreate, + // tenantAgent: TenantAgent, + // didMethod: string + // ) { + // let didDocument + // if (!createDidOptions.seed) { + // throw Error('Seed is required') + // } + // if (createDidOptions.did) { + // await this.importDid(didMethod, createDidOptions.did, createDidOptions.seed, tenantAgent) + // const getDid = await tenantAgent.dids.getCreatedDids({ + // method: createDidOptions.method, + // did: `did:${createDidOptions.method}:${createDidOptions.network}:${createDidOptions.did}`, + // }) + // if (getDid.length > 0) { + // didDocument = getDid[0].didDocument + // } + // return { + // did: `${didMethod}:${createDidOptions.did}`, + // didDocument: didDocument, + // } + // } else { + // if (createDidOptions?.role?.toLowerCase() === Role.Endorser) { + // await tenantAgent.wallet.createKey({ + // privateKey: TypedArrayEncoder.fromString(createDidOptions.seed), + // keyType: KeyType.Ed25519, + // }) + + // const body = { + // role: 'ENDORSER', + // alias: 'Alias', + // seed: createDidOptions.seed, + // } + + // const res = await axios.post(BCOVRIN_REGISTER_URL, body) + // if (res) { + // const { did } = res?.data || {} + // await this.importDid(didMethod, did, createDidOptions.seed, tenantAgent) + // const didRecord = await tenantAgent.dids.getCreatedDids({ + // method: DidMethod.Indy, + // did: `did:${DidMethod.Indy}:${Network.Bcovrin_Testnet}:${res.data.did}`, + // }) + + // if (didRecord.length > 0) { + // didDocument = didRecord[0].didDocument + // } + + // return { + // did: `${didMethod}:${res.data.did}`, + // didDocument: didDocument, + // } + // } + // } else { + // if (!createDidOptions.endorserDid) { + // throw Error('endorserDid or role is required') + // } + + // const didCreateTxResult = (await this.agent.dids.create({ + // method: DidMethod.Indy, + // options: { + // endorserMode: 'external', + // endorserDid: createDidOptions.endorserDid ? createDidOptions.endorserDid : '', + // }, + // })) as IndyVdrDidCreateResult + // return { did: didCreateTxResult.didState.did, didDocument: didCreateTxResult.didState.didDocument } + // } + // } + // } + + // private async handleIndicio( + // createDidOptions: DidCreate, + // tenantAgent: TenantAgent, + // didMethod: string + // ) { + // let didDocument + // if (!createDidOptions.seed) { + // throw Error('Seed is required') + // } + + // if (createDidOptions.did) { + // await this.importDid(didMethod, createDidOptions?.did, createDidOptions.seed, tenantAgent) + // const getDid = await tenantAgent.dids.getCreatedDids({ + // method: createDidOptions.method, + // did: `did:${createDidOptions.method}:${createDidOptions.network}:${createDidOptions.did}`, + // }) + // if (getDid.length > 0) { + // didDocument = getDid[0].didDocument + // } + + // return { + // did: `${didMethod}:${createDidOptions.did}`, + // didDocument: didDocument, + // } + // } else { + // if (createDidOptions?.role?.toLowerCase() === Role.Endorser) { + // return await this.handleEndorserCreation(createDidOptions, tenantAgent, didMethod) + // } else { + // return await this.handleIndyDidCreation(createDidOptions, tenantAgent) + // } + // } + // } + + // private async handleEndorserCreation( + // createDidOptions: DidCreate, + // tenantAgent: TenantAgent, + // didMethod: string + // ) { + // let didDocument + // if (!createDidOptions.seed) { + // throw Error('Seed is required') + // } + // const key = await tenantAgent.wallet.createKey({ + // privateKey: TypedArrayEncoder.fromString(createDidOptions.seed), + // keyType: KeyType.Ed25519, + // }) + // const buffer = TypedArrayEncoder.fromBase58(key.publicKeyBase58) + + // const did = TypedArrayEncoder.toBase58(buffer.slice(0, 16)) + + // let body + // if (createDidOptions.network === Network.Indicio_Testnet) { + // body = { + // network: 'testnet', + // did, + // verkey: TypedArrayEncoder.toBase58(buffer), + // } + // } else if (createDidOptions.network === Network.Indicio_Demonet) { + // body = { + // network: 'demonet', + // did, + // verkey: TypedArrayEncoder.toBase58(buffer), + // } + // } + // const res = await axios.post(INDICIO_NYM_URL, body) + // if (res.data.statusCode === 200) { + // await this.importDid(didMethod, did, createDidOptions.seed, tenantAgent) + // const didRecord = await tenantAgent.dids.getCreatedDids({ + // method: DidMethod.Indy, + // did: `${didMethod}:${body?.did}`, + // }) + // if (didRecord.length > 0) { + // didDocument = didRecord[0].didDocument + // } + + // return { + // did: `${didMethod}:${body?.did}`, + // didDocument: didDocument, + // } + // } + // } + + // private async handleIndyDidCreation(createDidOptions: DidCreate, tenantAgent: TenantAgent) { + // if (!createDidOptions.endorserDid) { + // throw Error('endorserDid or role is required') + // } + + // const didCreateTxResult = await tenantAgent.dids.create({ + // method: DidMethod.Indy, + // options: { + // endorserMode: 'external', + // endorserDid: createDidOptions.endorserDid ? createDidOptions.endorserDid : '', + // }, + // }) + // return { didTx: didCreateTxResult.didState.did } + // } + + // private async handleKey(createDidOptions: DidCreate, tenantId: string) { + // let didResponse + // let did: string + // let didDocument: any + + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // if (!createDidOptions.seed) { + // throw Error('Seed is required') + // } + // if (!createDidOptions.keyType) { + // throw Error('keyType is required') + // } + + // if (createDidOptions.keyType !== KeyType.Ed25519 && createDidOptions.keyType !== KeyType.Bls12381g2) { + // throw Error('Only ed25519 and bls12381g2 key type supported') + // } + + // if (!createDidOptions.did) { + // await tenantAgent.wallet.createKey({ + // keyType: createDidOptions.keyType, + // seed: TypedArrayEncoder.fromString(createDidOptions.seed), + // }) + // const didKeyResponse = await tenantAgent.dids.create({ + // method: DidMethod.Key, + // options: { + // keyType: KeyType.Ed25519, + // }, + // secret: { + // privateKey: TypedArrayEncoder.fromString(createDidOptions.seed), + // }, + // }) + // did = `${didKeyResponse.didState.did}` + // didDocument = didKeyResponse.didState.didDocument + // } else { + // did = createDidOptions.did + // const createdDid = await tenantAgent.dids.getCreatedDids({ + // did: createDidOptions.did, + // method: DidMethod.Key, + // }) + // didDocument = createdDid[0]?.didDocument + // } + + // await tenantAgent.dids.import({ + // did, + // overwrite: true, + // didDocument, + // }) + + // didResponse = { + // did, + // didDocument, + // } + // }) + // return didResponse + // } + + // private async handleWeb(createDidOptions: DidCreate, tenantId: string) { + // let did + // let didDocument: any + + // if (!createDidOptions.domain) { + // throw Error('For web method domain is required') + // } + + // if (!createDidOptions.keyType) { + // throw Error('keyType is required') + // } + + // if (createDidOptions.keyType !== KeyType.Ed25519 && createDidOptions.keyType !== KeyType.Bls12381g2) { + // throw Error('Only ed25519 and bls12381g2 key type supported') + // } + + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // if (!createDidOptions.seed) { + // throw Error('Seed is required') + // } + + // did = `did:${createDidOptions.method}:${createDidOptions.domain}` + // const keyId = `${did}#key-1` + // const key = await tenantAgent.wallet.createKey({ + // keyType: createDidOptions.keyType, + // seed: TypedArrayEncoder.fromString(createDidOptions.seed), + // }) + // if (createDidOptions.keyType === KeyType.Ed25519) { + // didDocument = new DidDocumentBuilder(did) + // .addContext('https://w3id.org/security/suites/ed25519-2018/v1') + // .addVerificationMethod(getEd25519VerificationKey2018({ key, id: keyId, controller: did })) + // .addAuthentication(keyId) + // .build() + // } + // if (createDidOptions.keyType === KeyType.Bls12381g2) { + // didDocument = new DidDocumentBuilder(did) + // .addContext('https://w3id.org/security/bbs/v1') + // .addVerificationMethod(getBls12381G2Key2020({ key, id: keyId, controller: did })) + // .addAuthentication(keyId) + // .build() + // } + + // await tenantAgent.dids.import({ + // did, + // overwrite: true, + // didDocument, + // }) + // }) + // return { did, didDocument } + // } + + // public async handlePolygon(createDidOptions: DidCreate, tenantId: string) { + // let createDidResponse + // let didResponse + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // // need to discuss try catch logic + + // const networkDetails = createDidOptions.network + // const networkName = networkDetails?.split(':')[1] + + // const { endpoint, privatekey } = createDidOptions + // if (networkName !== 'mainnet' && networkName !== 'testnet') { + // throw Error('Invalid network type') + // } + // if (!privatekey || typeof privatekey !== 'string' || !privatekey.trim() || privatekey.length !== 64) { + // throw Error('Invalid private key or not supported') + // } + + // createDidResponse = await tenantAgent.dids.create({ + // method: DidMethod.Polygon, + // options: { + // network: networkName, + // endpoint, + // }, + // secret: { + // privateKey: TypedArrayEncoder.fromHex(`${privatekey}`), + // }, + // }) + // didResponse = { + // did: createDidResponse?.didState?.did, + // didDoc: createDidResponse?.didState?.didDocument, + // } + // }) + // return didResponse + // } + + // private async importDid(didMethod: string, did: string, seed: string, tenantAgent: TenantAgent) { + // await tenantAgent.dids.import({ + // did: `${didMethod}:${did}`, + // overwrite: true, + // privateKeys: [ + // { + // keyType: KeyType.Ed25519, + // privateKey: TypedArrayEncoder.fromString(seed), + // }, + // ], + // }) + // } + + // @Security('apiKey') + // @Get('/dids/:tenantId') + // public async getDids( + // @Path('tenantId') tenantId: string, + // @Res() internalServerError: TsoaResponse<500, { message: string }> + // ) { + // try { + // let getDids + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // getDids = await tenantAgent.dids.getCreatedDids() + // }) + // return getDids + // } catch (error) { + // return internalServerError(500, { message: `something went wrong: ${error}` }) + // } + // } + + // @Security('apiKey') + // @Post('/transactions/set-endorser-role/:tenantId') + // public async didNymTransaction( + // @Path('tenantId') tenantId: string, + // @Body() didNymTransaction: DidNymTransaction, + // @Res() internalServerError: TsoaResponse<500, { message: string }> + // ) { + // let didCreateSubmitResult + // try { + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // didCreateSubmitResult = await tenantAgent.dids.create({ + // did: didNymTransaction.did, + // options: { + // endorserMode: 'external', + // endorsedTransaction: { + // nymRequest: didNymTransaction.nymRequest, + // }, + // }, + // }) + // await tenantAgent.dids.import({ + // did: didNymTransaction.did, + // overwrite: true, + // }) + // }) + + // return didCreateSubmitResult + // } catch (error) { + // return internalServerError(500, { message: `something went wrong: ${error}` }) + // } + // } + + // @Security('apiKey') + // @Post('/transactions/endorse/:tenantId') + // public async endorserTransaction( + // @Path('tenantId') tenantId: string, + // @Body() endorserTransaction: EndorserTransaction, + // @Res() internalServerError: TsoaResponse<500, { message: string }>, + // @Res() forbiddenError: TsoaResponse<400, { reason: string }> + // ) { + // let signedTransaction + // try { + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // signedTransaction = await tenantAgent.modules.indyVdr.endorseTransaction( + // endorserTransaction.transaction, + // endorserTransaction.endorserDid + // ) + // }) + + // return { signedTransaction } + // } catch (error) { + // if (error instanceof AriesFrameworkError) { + // if (error.message.includes('UnauthorizedClientRequest')) { + // return forbiddenError(400, { + // reason: 'this action is not allowed.', + // }) + // } + // } + + // return internalServerError(500, { message: `something went wrong: ${error}` }) + // } + // } + + // @Example(ConnectionRecordExample) + // @Security('apiKey') + // @Get('/connections/:connectionId/:tenantId') + // public async getConnectionById( + // @Path('tenantId') tenantId: string, + // @Path('connectionId') connectionId: RecordId, + // @Res() notFoundError: TsoaResponse<404, { reason: string }> + // ) { + // let connectionRecord + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // const connection = await tenantAgent.connections.findById(connectionId) + + // if (!connection) + // return notFoundError(404, { reason: `connection with connection id "${connectionId}" not found.` }) + // connectionRecord = connection.toJSON() + // }) + + // return connectionRecord + // } + + // @Security('apiKey') + // @Post('/create-invitation/:tenantId') + // public async createInvitation( + // @Res() internalServerError: TsoaResponse<500, { message: string }>, + // @Path('tenantId') tenantId: string, + // @Body() config?: Omit // props removed because of issues with serialization + // ) { + // let outOfBandRecord: OutOfBandRecord | undefined + // try { + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // outOfBandRecord = await tenantAgent.oob.createInvitation(config) + // }) + + // return { + // invitationUrl: outOfBandRecord?.outOfBandInvitation.toUrl({ + // domain: this.agent.config.endpoints[0], + // }), + // invitation: outOfBandRecord?.outOfBandInvitation.toJSON({ + // useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, + // }), + // outOfBandRecord: outOfBandRecord?.toJSON(), + // } + // } catch (error) { + // return internalServerError(500, { message: `something went wrong: ${error}` }) + // } + // } + + // @Security('apiKey') + // @Post('/create-legacy-invitation/:tenantId') + // public async createLegacyInvitation( + // @Res() internalServerError: TsoaResponse<500, { message: string }>, + // @Path('tenantId') tenantId: string, + // @Body() + // config?: Omit & RecipientKeyOption // props removed because of issues with serialization + // ) { + // let getInvitation + // try { + // let routing: Routing + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // if (config?.recipientKey) { + // routing = { + // endpoints: tenantAgent.config.endpoints, + // routingKeys: [], + // recipientKey: Key.fromPublicKeyBase58(config.recipientKey, KeyType.Ed25519), + // mediatorId: undefined, + // } + // } else { + // routing = await tenantAgent.mediationRecipient.getRouting({}) + // } + // const { outOfBandRecord, invitation } = await tenantAgent.oob.createLegacyInvitation({ ...config, routing }) + // getInvitation = { + // invitationUrl: invitation.toUrl({ + // domain: this.agent.config.endpoints[0], + // useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, + // }), + // invitation: invitation.toJSON({ + // useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, + // }), + // outOfBandRecord: outOfBandRecord.toJSON(), + // ...(config?.recipientKey ? {} : { recipientKey: routing.recipientKey.publicKeyBase58 }), + // } + // }) + + // return getInvitation + // } catch (error) { + // return internalServerError(500, { message: `something went wrong: ${error}` }) + // } + // } + + // @Security('apiKey') + // @Post('/receive-invitation/:tenantId') + // public async receiveInvitation( + // @Body() invitationRequest: ReceiveInvitationProps, + // @Path('tenantId') tenantId: string, + // @Res() internalServerError: TsoaResponse<500, { message: string }> + // ) { + // let receiveInvitationRes + // try { + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // const { invitation, ...config } = invitationRequest + // const invite = new OutOfBandInvitation({ ...invitation, handshakeProtocols: invitation.handshake_protocols }) + // const { outOfBandRecord, connectionRecord } = await tenantAgent.oob.receiveInvitation(invite, config) + // receiveInvitationRes = { + // outOfBandRecord: outOfBandRecord.toJSON(), + // connectionRecord: connectionRecord?.toJSON(), + // } + // }) + + // return receiveInvitationRes + // } catch (error) { + // return internalServerError(500, { message: `something went wrong: ${error}` }) + // } + // } + + // @Security('apiKey') + // @Post('/receive-invitation-url/:tenantId') + // public async receiveInvitationFromUrl( + // @Body() invitationRequest: ReceiveInvitationByUrlProps, + // @Path('tenantId') tenantId: string, + // @Res() internalServerError: TsoaResponse<500, { message: string }> + // ) { + // let receiveInvitationUrl + // try { + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // const { invitationUrl, ...config } = invitationRequest + // const { outOfBandRecord, connectionRecord } = await tenantAgent.oob.receiveInvitationFromUrl( + // invitationUrl, + // config + // ) + // receiveInvitationUrl = { + // outOfBandRecord: outOfBandRecord.toJSON(), + // connectionRecord: connectionRecord?.toJSON(), + // } + // }) + + // return receiveInvitationUrl + // } catch (error) { + // return internalServerError(500, { message: `something went wrong: ${error}` }) + // } + // } + + // @Security('apiKey') + // @Get('/oob/:invitationId/:tenantId') + // public async getAllOutOfBandRecords( + // @Path('tenantId') tenantId: string, + // @Res() internalServerError: TsoaResponse<500, { message: string }>, + // @Path('invitationId') invitationId?: string + // ) { + // let outOfBandRecordsRes + // try { + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // let outOfBandRecords + // outOfBandRecords = await tenantAgent.oob.getAll() + + // if (invitationId) + // outOfBandRecords = outOfBandRecords.filter((o: any) => o.outOfBandInvitation.id === invitationId) + // outOfBandRecordsRes = outOfBandRecords.map((c: any) => c.toJSON()) + // }) + + // return outOfBandRecordsRes + // } catch (error) { + // return internalServerError(500, { message: `something went wrong: ${error}` }) + // } + // } + + // @Security('apiKey') + // @Get('/connections/:tenantId') + // public async getAllConnections( + // @Path('tenantId') tenantId: string, + // @Res() internalServerError: TsoaResponse<500, { message: string }>, + // @Query('outOfBandId') outOfBandId?: string, + // @Query('alias') alias?: string, + // @Query('state') state?: DidExchangeState, + // @Query('myDid') myDid?: string, + // @Query('theirDid') theirDid?: string, + // @Query('theirLabel') theirLabel?: string + // ) { + // let connectionRecord + // try { + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // if (outOfBandId) { + // connectionRecord = await tenantAgent.connections.findAllByOutOfBandId(outOfBandId) + // } else { + // const connectionRepository = tenantAgent.dependencyManager.resolve(ConnectionRepository) + + // const connections = await connectionRepository.findByQuery(tenantAgent.context, { + // alias, + // myDid, + // theirDid, + // theirLabel, + // state, + // }) + + // connectionRecord = connections.map((c: any) => c.toJSON()) + // } + // }) + // return connectionRecord + // } catch (error) { + // return internalServerError(500, { message: `something went wrong: ${error}` }) + // } + // } + + // @Get('/url/:tenantId/:invitationId') + // public async getInvitation( + // @Path('invitationId') invitationId: string, + // @Path('tenantId') tenantId: string, + // @Res() notFoundError: TsoaResponse<404, { reason: string }> + // ) { + // let invitationJson + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // const outOfBandRecord = await tenantAgent.oob.findByCreatedInvitationId(invitationId) + + // if (!outOfBandRecord || outOfBandRecord.state !== 'await-response') + // return notFoundError(404, { reason: `connection with invitationId "${invitationId}" not found.` }) + + // invitationJson = outOfBandRecord.outOfBandInvitation.toJSON({ useDidSovPrefixWhereAllowed: true }) + // }) + // return invitationJson + // } + + // @Security('apiKey') + // @Post('/schema/:tenantId') + // public async createSchema( + // @Body() + // schema: { + // issuerId: string + // name: string + // version: Version + // attributes: string[] + // endorse?: boolean + // endorserDid?: string + // }, + // @Path('tenantId') tenantId: string, + // @Res() forbiddenError: TsoaResponse<400, { reason: string }>, + // @Res() internalServerError: TsoaResponse<500, { message: string }> + // ) { + // let schemaRecord + // try { + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // if (!schema.endorse) { + // const { schemaState } = await tenantAgent.modules.anoncreds.registerSchema({ + // schema: { + // issuerId: schema.issuerId, + // name: schema.name, + // version: schema.version, + // attrNames: schema.attributes, + // }, + // options: { + // endorserMode: 'internal', + // endorserDid: schema.issuerId, + // }, + // }) + + // if (!schemaState.schemaId) { + // throw Error('SchemaId not found') + // } + + // const indySchemaId = parseIndySchemaId(schemaState.schemaId) + // const getSchemaId = await getUnqualifiedSchemaId( + // indySchemaId.namespaceIdentifier, + // indySchemaId.schemaName, + // indySchemaId.schemaVersion + // ) + // if (schemaState.state === CredentialEnum.Finished) { + // schemaState.schemaId = getSchemaId + // } + + // schemaRecord = schemaState + // } else { + // if (!schema.endorserDid) { + // throw new Error('Please provide the endorser DID') + // } + + // const createSchemaTxResult = await tenantAgent.modules.anoncreds.registerSchema({ + // options: { + // endorserMode: 'external', + // endorserDid: schema.endorserDid ? schema.endorserDid : '', + // }, + // schema: { + // attrNames: schema.attributes, + // issuerId: schema.issuerId, + // name: schema.name, + // version: schema.version, + // }, + // }) + + // schemaRecord = createSchemaTxResult + // } + // }) + + // return schemaRecord + // } catch (error) { + // if (error instanceof AriesFrameworkError) { + // if (error.message.includes('UnauthorizedClientRequest')) { + // return forbiddenError(400, { + // reason: 'this action is not allowed.', + // }) + // } + // } + + // return internalServerError(500, { message: `something went wrong: ${error}` }) + // } + // } + + // @Security('apiKey') + // @Post('/polygon-wc3/schema/:tenantId') + // public async createPolygonW3CSchema( + // @Body() + // createSchemaRequest: { + // did: string + // schemaName: string + // schema: object + // }, + // @Path('tenantId') tenantId: string, + // @Res() internalServerError: TsoaResponse<500, { message: string }> + // ): Promise { + // try { + // let schemaResponse + // const { did, schemaName, schema } = createSchemaRequest + // if (!did || !schemaName || !schema) { + // throw Error('One or more parameters are empty or undefined.') + // } + + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // //need to add the return type after adding the scham URL + // schemaResponse = await tenantAgent.modules.polygon.createSchema({ + // did, + // schemaName, + // schema, + // }) + // }) + // return schemaResponse + // } catch (error) { + // return internalServerError(500, { message: `something went wrong: ${error}` }) + // } + // } + + // @Security('apiKey') + // @Get('polygon-wc3/schema/:did/:schemaId/:tenantId') + // public async getPolygonW3CSchemaById( + // @Path('tenantId') tenantId: string, + // @Path('did') did: string, + // @Path('schemaId') schemaId: string, + // @Res() internalServerError: TsoaResponse<500, { message: string }>, + // @Res() badRequestError: TsoaResponse<400, { reason: string }>, + // @Res() forbiddenError: TsoaResponse<401, { reason: string }> + // ): Promise { + // if (!tenantId || !did || !schemaId) { + // return badRequestError(400, { reason: 'Missing or invalid parameters.' }) + // } + + // try { + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // return tenantAgent.modules.polygon.getSchemaById(did, schemaId) + // }) + // } catch (error) { + // if (error instanceof AriesFrameworkError) { + // if (error.message.includes('UnauthorizedClientRequest')) { + // return forbiddenError(401, { + // reason: 'this action is not allowed.', + // }) + // } + // } + // return internalServerError(500, { message: `something went wrong: ${error}` }) + // } + // } + + // @Security('apiKey') + // @Post('/transactions/write/:tenantId') + // public async writeSchemaAndCredDefOnLedger( + // @Path('tenantId') tenantId: string, + // @Res() forbiddenError: TsoaResponse<400, { reason: string }>, + // @Res() internalServerError: TsoaResponse<500, { message: string }>, + // @Body() + // writeTransaction: WriteTransaction + // ) { + // try { + // if (writeTransaction.schema) { + // const writeSchema = await this.submitSchemaOnLedger( + // writeTransaction.schema, + // writeTransaction.endorsedTransaction, + // tenantId + // ) + // return writeSchema + // } else if (writeTransaction.credentialDefinition) { + // const writeCredDef = await this.submitCredDefOnLedger( + // writeTransaction.credentialDefinition, + // writeTransaction.endorsedTransaction, + // tenantId + // ) + // return writeCredDef + // } else { + // throw new Error('Please provide valid schema or credential-def!') + // } + // } catch (error) { + // if (error instanceof AriesFrameworkError) { + // if (error.message.includes('UnauthorizedClientRequest')) { + // return forbiddenError(400, { + // reason: 'this action is not allowed.', + // }) + // } + // } + // return internalServerError(500, { message: `something went wrong: ${error}` }) + // } + // } + + // public async submitSchemaOnLedger( + // schema: { + // issuerId: string + // name: string + // version: Version + // attributes: string[] + // }, + // endorsedTransaction: string, + // tenantId: string + // ) { + // let schemaRecord + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // const { issuerId, name, version, attributes } = schema + // const { schemaState } = await tenantAgent.modules.anoncreds.registerSchema({ + // options: { + // endorserMode: 'external', + // endorsedTransaction, + // }, + // schema: { + // attrNames: attributes, + // issuerId: issuerId, + // name: name, + // version: version, + // }, + // }) + + // if (!schemaState.schemaId) { + // throw Error('SchemaId not found') + // } + + // const indySchemaId = parseIndySchemaId(schemaState.schemaId) + // const getSchemaUnqualifiedId = await getUnqualifiedSchemaId( + // indySchemaId.namespaceIdentifier, + // indySchemaId.schemaName, + // indySchemaId.schemaVersion + // ) + // if (schemaState.state === CredentialEnum.Finished || schemaState.state === CredentialEnum.Action) { + // schemaState.schemaId = getSchemaUnqualifiedId + // } + // schemaRecord = schemaState + // }) + // return schemaRecord + // } + + // public async submitCredDefOnLedger( + // credentialDefinition: { + // schemaId: string + // issuerId: string + // tag: string + // value: unknown + // type: string + // }, + // endorsedTransaction: string, + // tenantId: string + // ) { + // let credentialDefinitionRecord + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // const { credentialDefinitionState } = await tenantAgent.modules.anoncreds.registerCredentialDefinition({ + // credentialDefinition, + // options: { + // endorserMode: 'external', + // endorsedTransaction: endorsedTransaction, + // }, + // }) + + // if (!credentialDefinitionState.credentialDefinitionId) { + // throw Error('Credential Definition Id not found') + // } + + // const indyCredDefId = parseIndyCredentialDefinitionId(credentialDefinitionState.credentialDefinitionId) + // const getCredentialDefinitionId = await getUnqualifiedCredentialDefinitionId( + // indyCredDefId.namespaceIdentifier, + // indyCredDefId.schemaSeqNo, + // indyCredDefId.tag + // ) + // if ( + // credentialDefinitionState.state === CredentialEnum.Finished || + // credentialDefinitionState.state === CredentialEnum.Action + // ) { + // credentialDefinitionState.credentialDefinitionId = getCredentialDefinitionId + // } + + // credentialDefinitionRecord = credentialDefinitionState + // }) + // return credentialDefinitionRecord + // } + + // @Security('apiKey') + // @Get('/schema/:schemaId/:tenantId') + // public async getSchemaById( + // @Path('schemaId') schemaId: SchemaId, + // @Path('tenantId') tenantId: string, + // @Res() notFoundError: TsoaResponse<404, { reason: string }>, + // @Res() forbiddenError: TsoaResponse<403, { reason: string }>, + // @Res() badRequestError: TsoaResponse<400, { reason: string }>, + // @Res() internalServerError: TsoaResponse<500, { message: string }> + // ) { + // let getSchema + // try { + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // getSchema = await tenantAgent.modules.anoncreds.getSchema(schemaId) + // }) + + // return getSchema + // } catch (error) { + // if (error instanceof AnonCredsError && error.message === 'IndyError(LedgerNotFound): LedgerNotFound') { + // return notFoundError(404, { + // reason: `schema definition with schemaId "${schemaId}" not found.`, + // }) + // } else if (error instanceof AnonCredsError && error.cause instanceof AnonCredsError) { + // if ((error.cause.cause, 'LedgerInvalidTransaction')) { + // return forbiddenError(403, { + // reason: `schema definition with schemaId "${schemaId}" can not be returned.`, + // }) + // } + // if ((error.cause.cause, 'CommonInvalidStructure')) { + // return badRequestError(400, { + // reason: `schemaId "${schemaId}" has invalid structure.`, + // }) + // } + // } + + // return internalServerError(500, { message: `something went wrong: ${error}` }) + // } + // } + + // @Security('apiKey') + // @Post('/credential-definition/:tenantId') + // public async createCredentialDefinition( + // @Body() + // credentialDefinitionRequest: { + // issuerId: string + // schemaId: string + // tag: string + // endorse?: boolean + // endorserDid?: string + // }, + // @Path('tenantId') tenantId: string, + // @Res() notFoundError: TsoaResponse<404, { reason: string }>, + // @Res() internalServerError: TsoaResponse<500, { message: string }> + // ) { + // let credentialDefinitionRecord + // try { + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // credentialDefinitionRequest.endorse = credentialDefinitionRequest.endorse + // ? credentialDefinitionRequest.endorse + // : false + + // if (!credentialDefinitionRequest.endorse) { + // const { credentialDefinitionState } = await tenantAgent.modules.anoncreds.registerCredentialDefinition({ + // credentialDefinition: { + // issuerId: credentialDefinitionRequest.issuerId, + // schemaId: credentialDefinitionRequest.schemaId, + // tag: credentialDefinitionRequest.tag, + // }, + // options: {}, + // }) + + // if (!credentialDefinitionState?.credentialDefinitionId) { + // throw new Error('Credential Definition Id not found') + // } + // const indyCredDefId = parseIndyCredentialDefinitionId(credentialDefinitionState.credentialDefinitionId) + // const getCredentialDefinitionId = await getUnqualifiedCredentialDefinitionId( + // indyCredDefId.namespaceIdentifier, + // indyCredDefId.schemaSeqNo, + // indyCredDefId.tag + // ) + // if (credentialDefinitionState.state === CredentialEnum.Finished) { + // credentialDefinitionState.credentialDefinitionId = getCredentialDefinitionId + // } + + // credentialDefinitionRecord = credentialDefinitionState + // } else { + // const createCredDefTxResult = await tenantAgent.modules.anoncreds.registerCredentialDefinition({ + // credentialDefinition: { + // issuerId: credentialDefinitionRequest.issuerId, + // tag: credentialDefinitionRequest.tag, + // schemaId: credentialDefinitionRequest.schemaId, + // type: 'CL', + // }, + // options: { + // endorserMode: 'external', + // endorserDid: credentialDefinitionRequest.endorserDid ? credentialDefinitionRequest.endorserDid : '', + // }, + // }) + + // credentialDefinitionRecord = createCredDefTxResult + // } + // }) + + // return credentialDefinitionRecord + // } catch (error) { + // if (error instanceof notFoundError) { + // return notFoundError(404, { + // reason: `schema with schemaId "${credentialDefinitionRequest.schemaId}" not found.`, + // }) + // } + + // return internalServerError(500, { message: `something went wrong: ${error}` }) + // } + // } + + // @Security('apiKey') + // @Get('/credential-definition/:credentialDefinitionId/:tenantId') + // public async getCredentialDefinitionById( + // @Path('credentialDefinitionId') credentialDefinitionId: CredentialDefinitionId, + // @Path('tenantId') tenantId: string, + // @Res() badRequestError: TsoaResponse<400, { reason: string }>, + // @Res() notFoundError: TsoaResponse<404, { reason: string }>, + // @Res() internalServerError: TsoaResponse<500, { message: string }> + // ) { + // let getCredDef + // try { + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // getCredDef = await tenantAgent.modules.anoncreds.getCredentialDefinition(credentialDefinitionId) + // }) + + // return getCredDef + // } catch (error) { + // if (error instanceof AriesFrameworkError && error.message === 'IndyError(LedgerNotFound): LedgerNotFound') { + // return notFoundError(404, { + // reason: `credential definition with credentialDefinitionId "${credentialDefinitionId}" not found.`, + // }) + // } else if (error instanceof AnonCredsError && error.cause instanceof AriesFrameworkError) { + // if ((error.cause.cause, 'CommonInvalidStructure')) { + // return badRequestError(400, { + // reason: `credentialDefinitionId "${credentialDefinitionId}" has invalid structure.`, + // }) + // } + // } + + // return internalServerError(500, { message: `something went wrong: ${error}` }) + // } + // } + + // @Security('apiKey') + // @Post('/credentials/create-offer/:tenantId') + // public async createOffer( + // @Body() createOfferOptions: CreateOfferOptions, + // @Path('tenantId') tenantId: string, + // @Res() internalServerError: TsoaResponse<500, { message: string }> + // ) { + // let offer + // try { + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // offer = await tenantAgent.credentials.offerCredential({ + // connectionId: createOfferOptions.connectionId, + // protocolVersion: createOfferOptions.protocolVersion as CredentialProtocolVersionType<[]>, + // credentialFormats: createOfferOptions.credentialFormats, + // autoAcceptCredential: createOfferOptions.autoAcceptCredential, + // }) + // }) + + // return offer + // } catch (error) { + // return internalServerError(500, { message: `something went wrong: ${error}` }) + // } + // } + + // @Security('apiKey') + // @Post('/credentials/create-offer-oob/:tenantId') + // public async createOfferOob( + // @Path('tenantId') tenantId: string, + // @Body() createOfferOptions: CreateOfferOobOptions, + // @Res() internalServerError: TsoaResponse<500, { message: string }> + // ) { + // let createOfferOobRecord + + // try { + // let routing: Routing + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // const linkSecretIds = await tenantAgent.modules.anoncreds.getLinkSecretIds() + // if (linkSecretIds.length === 0) { + // await tenantAgent.modules.anoncreds.createLinkSecret() + // } + + // if (createOfferOptions?.recipientKey) { + // routing = { + // endpoints: tenantAgent.config.endpoints, + // routingKeys: [], + // recipientKey: Key.fromPublicKeyBase58(createOfferOptions.recipientKey, KeyType.Ed25519), + // mediatorId: undefined, + // } + // } else { + // routing = await tenantAgent.mediationRecipient.getRouting({}) + // } + + // const offerOob = await tenantAgent.credentials.createOffer({ + // protocolVersion: createOfferOptions.protocolVersion as CredentialProtocolVersionType<[]>, + // credentialFormats: createOfferOptions.credentialFormats, + // autoAcceptCredential: createOfferOptions.autoAcceptCredential, + // comment: createOfferOptions.comment, + // }) + + // const credentialMessage = offerOob.message + // const outOfBandRecord = await tenantAgent.oob.createInvitation({ + // label: createOfferOptions.label, + // handshakeProtocols: [HandshakeProtocol.Connections], + // messages: [credentialMessage], + // autoAcceptConnection: true, + // imageUrl: createOfferOptions?.imageUrl, + // goalCode: createOfferOptions?.goalCode, + // routing, + // }) + + // createOfferOobRecord = { + // invitationUrl: outOfBandRecord.outOfBandInvitation.toUrl({ + // domain: this.agent.config.endpoints[0], + // }), + // invitation: outOfBandRecord.outOfBandInvitation.toJSON({ + // useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, + // }), + // outOfBandRecord: outOfBandRecord.toJSON(), + // outOfBandRecordId: outOfBandRecord.id, + // recipientKey: createOfferOptions?.recipientKey ? {} : { recipientKey: routing.recipientKey.publicKeyBase58 }, + // } + // }) + // return createOfferOobRecord + // } catch (error) { + // return internalServerError(500, { message: `something went wrong: ${error}` }) + // } + // } + + // @Security('apiKey') + // @Post('/credentials/accept-offer/:tenantId') + // public async acceptOffer( + // @Res() notFoundError: TsoaResponse<404, { reason: string }>, + // @Res() internalServerError: TsoaResponse<500, { message: string }>, + // @Path('tenantId') tenantId: string, + // @Body() acceptCredentialOfferOptions: AcceptCredentialOfferOptions + // ) { + // let acceptOffer + // try { + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // const linkSecretIds = await tenantAgent.modules.anoncreds.getLinkSecretIds() + // if (linkSecretIds.length === 0) { + // await tenantAgent.modules.anoncreds.createLinkSecret() + // } + // acceptOffer = await tenantAgent.credentials.acceptOffer({ + // credentialRecordId: acceptCredentialOfferOptions.credentialRecordId, + // credentialFormats: acceptCredentialOfferOptions.credentialFormats, + // autoAcceptCredential: acceptCredentialOfferOptions.autoAcceptCredential, + // comment: acceptCredentialOfferOptions.comment, + // }) + // }) + + // return acceptOffer + // } catch (error) { + // if (error instanceof RecordNotFoundError) { + // return notFoundError(404, { + // reason: `credential with credential record id "${acceptCredentialOfferOptions.credentialRecordId}" not found.`, + // }) + // } + + // return internalServerError(500, { message: `something went wrong: ${error}` }) + // } + // } + + // @Security('apiKey') + // @Get('/credentials/:credentialRecordId/:tenantId') + // public async getCredentialById( + // @Path('credentialRecordId') credentialRecordId: RecordId, + // @Path('tenantId') tenantId: string, + // @Res() notFoundError: TsoaResponse<404, { reason: string }>, + // @Res() internalServerError: TsoaResponse<500, { message: string }> + // ) { + // let credentialRecord + // try { + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // const credential = await tenantAgent.credentials.getById(credentialRecordId) + // credentialRecord = credential.toJSON() + // }) + + // return credentialRecord + // } catch (error) { + // if (error instanceof RecordNotFoundError) { + // return notFoundError(404, { + // reason: `credential with credential record id "${credentialRecordId}" not found.`, + // }) + // } + + // return internalServerError(500, { message: `something went wrong: ${error}` }) + // } + // } + + // @Security('apiKey') + // @Get('/credentials/:tenantId') + // public async getAllCredentials( + // @Path('tenantId') tenantId: string, + // @Query('threadId') threadId?: string, + // @Query('connectionId') connectionId?: string, + // @Query('state') state?: CredentialState + // ) { + // let credentialRecord + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // const credentialRepository = tenantAgent.dependencyManager.resolve(CredentialRepository) + // const credentials = await credentialRepository.findByQuery(tenantAgent.context, { + // connectionId, + // threadId, + // state, + // }) + // credentialRecord = credentials.map((c: any) => c.toJSON()) + // }) + // return credentialRecord + // } + + // @Security('apiKey') + // @Get('/proofs/:tenantId') + // public async getAllProofs(@Path('tenantId') tenantId: string, @Query('threadId') threadId?: string) { + // let proofRecord + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // let proofs = await tenantAgent.proofs.getAll() + // if (threadId) proofs = proofs.filter((p: any) => p.threadId === threadId) + // proofRecord = proofs.map((proof: any) => proof.toJSON()) + // }) + // return proofRecord + // } + + // @Security('apiKey') + // @Get('/form-data/:tenantId/:proofRecordId') + // @Example(ProofRecordExample) + // public async proofFormData( + // @Path('proofRecordId') proofRecordId: string, + // @Path('tenantId') tenantId: string, + // @Res() notFoundError: TsoaResponse<404, { reason: string }>, + // @Res() internalServerError: TsoaResponse<500, { message: string }> + // ) { + // let proof + // try { + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // proof = await tenantAgent.proofs.getFormatData(proofRecordId) + // }) + // return proof + // } catch (error) { + // if (error instanceof RecordNotFoundError) { + // return notFoundError(404, { + // reason: `proof with proofRecordId "${proofRecordId}" not found.`, + // }) + // } + + // return internalServerError(500, { message: `something went wrong: ${error}` }) + // } + // } + + // @Security('apiKey') + // @Post('/proofs/request-proof/:tenantId') + // @Example(ProofRecordExample) + // public async requestProof( + // @Body() requestProofOptions: RequestProofOptions, + // @Path('tenantId') tenantId: string, + // @Res() notFoundError: TsoaResponse<404, { reason: string }>, + // @Res() internalServerError: TsoaResponse<500, { message: string }> + // ) { + // let proof + // try { + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // const requestProofPayload = { + // connectionId: requestProofOptions.connectionId, + // protocolVersion: requestProofOptions.protocolVersion as ProofsProtocolVersionType<[]>, + // comment: requestProofOptions.comment, + // proofFormats: requestProofOptions.proofFormats, + // autoAcceptProof: requestProofOptions.autoAcceptProof, + // goalCode: requestProofOptions.goalCode, + // parentThreadId: requestProofOptions.parentThreadId, + // willConfirm: requestProofOptions.willConfirm, + // } + // proof = await tenantAgent.proofs.requestProof(requestProofPayload) + // }) + + // return proof + // } catch (error) { + // return internalServerError(500, { message: `something went wrong: ${error}` }) + // } + // } + + // @Security('apiKey') + // @Post('/proofs/create-request-oob/:tenantId') + // public async createRequest( + // @Path('tenantId') tenantId: string, + // @Body() createRequestOptions: CreateProofRequestOobOptions, + // @Res() internalServerError: TsoaResponse<500, { message: string }> + // ) { + // let oobProofRecord + // try { + // let routing: Routing + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // if (createRequestOptions?.recipientKey) { + // routing = { + // endpoints: tenantAgent.config.endpoints, + // routingKeys: [], + // recipientKey: Key.fromPublicKeyBase58(createRequestOptions.recipientKey, KeyType.Ed25519), + // mediatorId: undefined, + // } + // } else { + // routing = await tenantAgent.mediationRecipient.getRouting({}) + // } + // const proof = await tenantAgent.proofs.createRequest({ + // protocolVersion: createRequestOptions.protocolVersion as ProofsProtocolVersionType<[]>, + // proofFormats: createRequestOptions.proofFormats, + // goalCode: createRequestOptions.goalCode, + // willConfirm: createRequestOptions.willConfirm, + // parentThreadId: createRequestOptions.parentThreadId, + // autoAcceptProof: createRequestOptions.autoAcceptProof, + // comment: createRequestOptions.comment, + // }) + + // const proofMessage = proof.message + // const outOfBandRecord = await tenantAgent.oob.createInvitation({ + // label: createRequestOptions.label, + // handshakeProtocols: [HandshakeProtocol.Connections], + // messages: [proofMessage], + // autoAcceptConnection: true, + // imageUrl: createRequestOptions?.imageUrl, + // routing, + // goalCode: createRequestOptions?.goalCode, + // }) + + // oobProofRecord = { + // invitationUrl: outOfBandRecord.outOfBandInvitation.toUrl({ + // domain: this.agent.config.endpoints[0], + // }), + // invitation: outOfBandRecord.outOfBandInvitation.toJSON({ + // useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, + // }), + // outOfBandRecord: outOfBandRecord.toJSON(), + // proofRecordThId: proof.proofRecord.threadId, + // proofMessageId: proof.message.thread?.threadId + // ? proof.message.thread?.threadId + // : proof.message.threadId + // ? proof.message.thread + // : proof.message.id, + // recipientKey: createRequestOptions?.recipientKey + // ? {} + // : { recipientKey: routing.recipientKey.publicKeyBase58 }, + // } + // }) + + // return oobProofRecord + // } catch (error) { + // return internalServerError(500, { message: `something went wrong: ${error}` }) + // } + // } + + // @Security('apiKey') + // @Post('/proofs/:proofRecordId/accept-request/:tenantId') + // @Example(ProofRecordExample) + // public async acceptRequest( + // @Path('tenantId') tenantId: string, + // @Path('proofRecordId') proofRecordId: string, + // @Body() + // request: { + // filterByPresentationPreview?: boolean + // filterByNonRevocationRequirements?: boolean + // comment?: string + // }, + // @Res() notFoundError: TsoaResponse<404, { reason: string }>, + // @Res() internalServerError: TsoaResponse<500, { message: string }> + // ) { + // let proofRecord + // try { + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // const requestedCredentials = await tenantAgent.proofs.selectCredentialsForRequest({ + // proofRecordId, + // }) + + // const acceptProofRequest: AcceptProofRequestOptions = { + // proofRecordId, + // comment: request.comment, + // proofFormats: requestedCredentials.proofFormats, + // } + + // const proof = await tenantAgent.proofs.acceptRequest(acceptProofRequest) + + // proofRecord = proof.toJSON() + // }) + // return proofRecord + // } catch (error) { + // if (error instanceof RecordNotFoundError) { + // return notFoundError(404, { + // reason: `proof with proofRecordId "${proofRecordId}" not found.`, + // }) + // } + + // return internalServerError(500, { message: `something went wrong: ${error}` }) + // } + // } + + // @Security('apiKey') + // @Post('/proofs/:proofRecordId/accept-presentation/:tenantId') + // @Example(ProofRecordExample) + // public async acceptPresentation( + // @Path('tenantId') tenantId: string, + // @Path('proofRecordId') proofRecordId: string, + // @Res() notFoundError: TsoaResponse<404, { reason: string }>, + // @Res() internalServerError: TsoaResponse<500, { message: string }> + // ) { + // let proof + // try { + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // proof = await tenantAgent.proofs.acceptPresentation({ proofRecordId }) + // }) + + // return proof + // } catch (error) { + // if (error instanceof RecordNotFoundError) { + // return notFoundError(404, { + // reason: `proof with proofRecordId "${proofRecordId}" not found.`, + // }) + // } + + // return internalServerError(500, { message: `something went wrong: ${error}` }) + // } + // } + + // @Security('apiKey') + // @Get('/proofs/:proofRecordId/:tenantId') + // @Example(ProofRecordExample) + // public async getProofById( + // @Path('tenantId') tenantId: string, + // @Path('proofRecordId') proofRecordId: RecordId, + // @Res() notFoundError: TsoaResponse<404, { reason: string }>, + // @Res() internalServerError: TsoaResponse<500, { message: string }> + // ) { + // let proofRecord + // try { + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // const proof = await tenantAgent.proofs.getById(proofRecordId) + // proofRecord = proof.toJSON() + // }) + // return proofRecord + // } catch (error) { + // if (error instanceof RecordNotFoundError) { + // return notFoundError(404, { + // reason: `proof with proofRecordId "${proofRecordId}" not found.`, + // }) + // } + + // return internalServerError(500, { message: `something went wrong: ${error}` }) + // } + // } + + // @Security('apiKey') + @Security('jwt') @Delete(':tenantId') public async deleteTenantById( + @Request() request: Req, @Path('tenantId') tenantId: string, @Res() notFoundError: TsoaResponse<404, { reason: string }>, @Res() internalServerError: TsoaResponse<500, { message: string }> ) { try { - const deleteTenant = await this.agent.modules.tenants.deleteTenantById(tenantId) + const agent = request.agent as Agent + const deleteTenant = await agent.modules.tenants.deleteTenantById(tenantId) return JsonTransformer.toJSON(deleteTenant) } catch (error) { if (error instanceof RecordNotFoundError) { @@ -1682,221 +1669,239 @@ export class MultiTenancyController extends Controller { } } - @Security('apiKey') - @Post('/did/web/:tenantId') - public async createDidWeb( - @Path('tenantId') tenantId: string, - @Body() didOptions: DidCreate, - @Res() internalServerError: TsoaResponse<500, { message: string }> - ) { - try { - let didDoc - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - if (!didOptions.seed) { - throw Error('Seed is required') - } - if (!didOptions.keyType) { - throw Error('keyType is required') - } - if (didOptions.keyType !== KeyType.Ed25519 && didOptions.keyType !== KeyType.Bls12381g2) { - throw Error('Only ed25519 and bls12381g2 key type supported') - } - const did = `did:${didOptions.method}:${didOptions.domain}` - let didDocument: any - const keyId = `${did}#key-1` - const key = await tenantAgent.wallet.createKey({ - keyType: didOptions.keyType, - seed: TypedArrayEncoder.fromString(didOptions.seed), - }) - if (didOptions.keyType === 'ed25519') { - didDocument = new DidDocumentBuilder(did) - .addContext('https://w3id.org/security/suites/ed25519-2018/v1') - .addVerificationMethod(getEd25519VerificationKey2018({ key, id: keyId, controller: did })) - .addAuthentication(keyId) - .build() - } - if (didOptions.keyType === 'bls12381g2') { - didDocument = new DidDocumentBuilder(did) - .addContext('https://w3id.org/security/bbs/v1') - .addVerificationMethod(getBls12381G2Key2020({ key, id: keyId, controller: did })) - .addAuthentication(keyId) - .build() - } - - didDoc = { - did, - didDocument: didDocument.toJSON(), - } - }) - return didDoc - } catch (error) { - return internalServerError(500, { - message: `something went wrong: ${error}`, - }) - } - } - - @Security('apiKey') - @Post('/did/key:tenantId') - public async createDidKey( - @Path('tenantId') tenantId: string, - @Body() didOptions: DidCreate, - @Res() internalServerError: TsoaResponse<500, { message: string }> - ) { - try { - let didCreateResponse - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - if (!didOptions.seed) { - throw Error('Seed is required') - } - didCreateResponse = await tenantAgent.dids.create({ - method: 'key', - options: { - keyType: KeyType.Ed25519, + // @Security('apiKey') + // @Post('/did/web/:tenantId') + // public async createDidWeb( + // @Path('tenantId') tenantId: string, + // @Body() didOptions: DidCreate, + // @Res() internalServerError: TsoaResponse<500, { message: string }> + // ) { + // try { + // let didDoc + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // if (!didOptions.seed) { + // throw Error('Seed is required') + // } + // if (!didOptions.keyType) { + // throw Error('keyType is required') + // } + // if (didOptions.keyType !== KeyType.Ed25519 && didOptions.keyType !== KeyType.Bls12381g2) { + // throw Error('Only ed25519 and bls12381g2 key type supported') + // } + // const did = `did:${didOptions.method}:${didOptions.domain}` + // let didDocument: any + // const keyId = `${did}#key-1` + // const key = await tenantAgent.wallet.createKey({ + // keyType: didOptions.keyType, + // seed: TypedArrayEncoder.fromString(didOptions.seed), + // }) + // if (didOptions.keyType === 'ed25519') { + // didDocument = new DidDocumentBuilder(did) + // .addContext('https://w3id.org/security/suites/ed25519-2018/v1') + // .addVerificationMethod(getEd25519VerificationKey2018({ key, id: keyId, controller: did })) + // .addAuthentication(keyId) + // .build() + // } + // if (didOptions.keyType === 'bls12381g2') { + // didDocument = new DidDocumentBuilder(did) + // .addContext('https://w3id.org/security/bbs/v1') + // .addVerificationMethod(getBls12381G2Key2020({ key, id: keyId, controller: did })) + // .addAuthentication(keyId) + // .build() + // } + + // didDoc = { + // did, + // didDocument: didDocument.toJSON(), + // } + // }) + // return didDoc + // } catch (error) { + // return internalServerError(500, { + // message: `something went wrong: ${error}`, + // }) + // } + // } + + // @Security('apiKey') + // @Post('/did/key:tenantId') + // public async createDidKey( + // @Path('tenantId') tenantId: string, + // @Body() didOptions: DidCreate, + // @Res() internalServerError: TsoaResponse<500, { message: string }> + // ) { + // try { + // let didCreateResponse + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // if (!didOptions.seed) { + // throw Error('Seed is required') + // } + // didCreateResponse = await tenantAgent.dids.create({ + // method: 'key', + // options: { + // keyType: KeyType.Ed25519, + // }, + // secret: { + // privateKey: TypedArrayEncoder.fromString(didOptions.seed), + // }, + // }) + // }) + // return didCreateResponse + // } catch (error) { + // return internalServerError(500, { + // message: `something went wrong: ${error}`, + // }) + // } + // } + + // /** + // * Retrieve question and answer records by query + // * + // * @param tenantId Tenant identifier + // * @param connectionId Connection identifier + // * @param role Role of the question + // * @param state State of the question + // * @param threadId Thread identifier + // * @returns QuestionAnswerRecord[] + // */ + // @Security('apiKey') + // @Get('/question-answer/:tenantId') + // public async getQuestionAnswerRecords( + // @Path('tenantId') tenantId: string, + // @Query('connectionId') connectionId?: string, + // @Query('role') role?: QuestionAnswerRole, + // @Query('state') state?: QuestionAnswerState, + // @Query('threadId') threadId?: string + // ) { + // let questionAnswerRecords: QuestionAnswerRecord[] = [] + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // questionAnswerRecords = await tenantAgent.modules.questionAnswer.findAllByQuery({ + // connectionId, + // role, + // state, + // threadId, + // }) + // }) + // return questionAnswerRecords.map((record) => record.toJSON()) + // } + + // /** + // * Send a question to a connection + // * + // * @param tenantId Tenant identifier + // * @param connectionId Connection identifier + // * @param content The content of the message + // */ + // @Security('apiKey') + // @Post('/question-answer/question/:connectionId/:tenantId') + // public async sendQuestion( + // @Path('connectionId') connectionId: RecordId, + // @Path('tenantId') tenantId: string, + // @Body() + // config: { + // question: string + // validResponses: ValidResponse[] + // detail?: string + // }, + // @Res() notFoundError: TsoaResponse<404, { reason: string }>, + // @Res() internalServerError: TsoaResponse<500, { message: string }> + // ) { + // try { + // const { question, validResponses, detail } = config + // let questionAnswerRecord + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // questionAnswerRecord = await tenantAgent.modules.questionAnswer.sendQuestion(connectionId, { + // question, + // validResponses, + // detail, + // }) + // questionAnswerRecord = questionAnswerRecord?.toJSON() + // }) + + // return questionAnswerRecord + // } catch (error) { + // if (error instanceof RecordNotFoundError) { + // return notFoundError(404, { reason: `connection with connection id "${connectionId}" not found.` }) + // } + // return internalServerError(500, { message: `something went wrong: ${error}` }) + // } + // } + + // /** + // * Send a answer to question + // * + // * @param tenantId Tenant identifier + // * @param id Question Answer Record identifier + // * @param response The response of the question + // */ + // @Security('apiKey') + // @Post('/question-answer/answer/:id/:tenantId') + // public async sendAnswer( + // @Path('id') id: RecordId, + // @Path('tenantId') tenantId: string, + // @Body() request: Record<'response', string>, + // @Res() notFoundError: TsoaResponse<404, { reason: string }>, + // @Res() internalServerError: TsoaResponse<500, { message: string }> + // ) { + // try { + // let questionAnswerRecord + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // const record = await tenantAgent.modules.questionAnswer.sendAnswer(id, request.response) + // questionAnswerRecord = record.toJSON() + // }) + // return questionAnswerRecord + // } catch (error) { + // if (error instanceof RecordNotFoundError) { + // return notFoundError(404, { reason: `record with connection id "${id}" not found.` }) + // } + // return internalServerError(500, { message: `something went wrong: ${error}` }) + // } + // } + + // /** + // * Retrieve question answer record by id + // * + // * @param id Question Answer Record identifier + // * @param tenantId Tenant identifier + // * @returns ConnectionRecord + // */ + // @Security('apiKey') + // @Get('/question-answer/:id/:tenantId') + // public async getQuestionAnswerRecordById( + // @Path('id') id: RecordId, + // @Path('tenantId') tenantId: string, + // @Res() notFoundError: TsoaResponse<404, { reason: string }> + // ) { + // let questionAnswerRecord + // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + // const record = await tenantAgent.modules.questionAnswer.findById(id) + // questionAnswerRecord = record + // }) + + // if (!questionAnswerRecord) { + // return notFoundError(404, { + // reason: `Question Answer Record with id "${id}" not found.`, + // }) + // } + + // return questionAnswerRecord + // } + + private async createToken(agent: Agent, tenantId: string, secretKey?: string) { + let key: string + if (!secretKey) { + key = await generateSecretKey() + await agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { + tenantAgent.genericRecords.save({ + content: { + secretKey: key, }, - secret: { - privateKey: TypedArrayEncoder.fromString(didOptions.seed), - }, - }) - }) - return didCreateResponse - } catch (error) { - return internalServerError(500, { - message: `something went wrong: ${error}`, - }) - } - } - - /** - * Retrieve question and answer records by query - * - * @param tenantId Tenant identifier - * @param connectionId Connection identifier - * @param role Role of the question - * @param state State of the question - * @param threadId Thread identifier - * @returns QuestionAnswerRecord[] - */ - @Security('apiKey') - @Get('/question-answer/:tenantId') - public async getQuestionAnswerRecords( - @Path('tenantId') tenantId: string, - @Query('connectionId') connectionId?: string, - @Query('role') role?: QuestionAnswerRole, - @Query('state') state?: QuestionAnswerState, - @Query('threadId') threadId?: string - ) { - let questionAnswerRecords: QuestionAnswerRecord[] = [] - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - questionAnswerRecords = await tenantAgent.modules.questionAnswer.findAllByQuery({ - connectionId, - role, - state, - threadId, - }) - }) - return questionAnswerRecords.map((record) => record.toJSON()) - } - - /** - * Send a question to a connection - * - * @param tenantId Tenant identifier - * @param connectionId Connection identifier - * @param content The content of the message - */ - @Security('apiKey') - @Post('/question-answer/question/:connectionId/:tenantId') - public async sendQuestion( - @Path('connectionId') connectionId: RecordId, - @Path('tenantId') tenantId: string, - @Body() - config: { - question: string - validResponses: ValidResponse[] - detail?: string - }, - @Res() notFoundError: TsoaResponse<404, { reason: string }>, - @Res() internalServerError: TsoaResponse<500, { message: string }> - ) { - try { - const { question, validResponses, detail } = config - let questionAnswerRecord - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - questionAnswerRecord = await tenantAgent.modules.questionAnswer.sendQuestion(connectionId, { - question, - validResponses, - detail, }) - questionAnswerRecord = questionAnswerRecord?.toJSON() - }) - - return questionAnswerRecord - } catch (error) { - if (error instanceof RecordNotFoundError) { - return notFoundError(404, { reason: `connection with connection id "${connectionId}" not found.` }) - } - return internalServerError(500, { message: `something went wrong: ${error}` }) - } - } - - /** - * Send a answer to question - * - * @param tenantId Tenant identifier - * @param id Question Answer Record identifier - * @param response The response of the question - */ - @Security('apiKey') - @Post('/question-answer/answer/:id/:tenantId') - public async sendAnswer( - @Path('id') id: RecordId, - @Path('tenantId') tenantId: string, - @Body() request: Record<'response', string>, - @Res() notFoundError: TsoaResponse<404, { reason: string }>, - @Res() internalServerError: TsoaResponse<500, { message: string }> - ) { - try { - let questionAnswerRecord - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - const record = await tenantAgent.modules.questionAnswer.sendAnswer(id, request.response) - questionAnswerRecord = record.toJSON() - }) - return questionAnswerRecord - } catch (error) { - if (error instanceof RecordNotFoundError) { - return notFoundError(404, { reason: `record with connection id "${id}" not found.` }) - } - return internalServerError(500, { message: `something went wrong: ${error}` }) - } - } - - /** - * Retrieve question answer record by id - * - * @param id Question Answer Record identifier - * @param tenantId Tenant identifier - * @returns ConnectionRecord - */ - @Security('apiKey') - @Get('/question-answer/:id/:tenantId') - public async getQuestionAnswerRecordById( - @Path('id') id: RecordId, - @Path('tenantId') tenantId: string, - @Res() notFoundError: TsoaResponse<404, { reason: string }> - ) { - let questionAnswerRecord - await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - const record = await tenantAgent.modules.questionAnswer.findById(id) - questionAnswerRecord = record - }) - - if (!questionAnswerRecord) { - return notFoundError(404, { - reason: `Question Answer Record with id "${id}" not found.`, }) + } else { + key = secretKey } - - return questionAnswerRecord + const token = jwt.sign({ role: AgentRole.RestTenantAgent, tenantId }, key) + return token } } diff --git a/src/controllers/outofband/OutOfBandController.ts b/src/controllers/outofband/OutOfBandController.ts index 9dabc5c4..4cde3a9e 100644 --- a/src/controllers/outofband/OutOfBandController.ts +++ b/src/controllers/outofband/OutOfBandController.ts @@ -2,15 +2,16 @@ import type { OutOfBandInvitationProps, OutOfBandRecordWithInvitationProps } fro import type { AgentMessageType, RecipientKeyOption } from '../types' import type { ConnectionRecordProps, CreateLegacyInvitationConfig, Routing } from '@aries-framework/core' +// eslint-disable-next-line import/no-extraneous-dependencies import { AgentMessage, JsonTransformer, OutOfBandInvitation, - Agent, RecordNotFoundError, Key, KeyType, } from '@aries-framework/core' +import { Request as Req } from 'express' import { injectable } from 'tsyringe' import { ConnectionRecordExample, outOfBandInvitationExample, outOfBandRecordExample, RecordId } from '../examples' @@ -30,25 +31,20 @@ import { Path, Post, Query, - Res, + Request, Route, Tags, TsoaResponse, Security, + Res, } from 'tsoa' @Tags('Out Of Band') -@Security('apiKey') +// @Security('apiKey') +@Security('jwt') @Route('/oob') @injectable() export class OutOfBandController extends Controller { - private agent: Agent - - public constructor(agent: Agent) { - super() - this.agent = agent - } - /** * Retrieve all out of band records * @param invitationId invitation identifier @@ -56,8 +52,8 @@ export class OutOfBandController extends Controller { */ @Example([outOfBandRecordExample]) @Get() - public async getAllOutOfBandRecords(@Query('invitationId') invitationId?: RecordId) { - let outOfBandRecords = await this.agent.oob.getAll() + public async getAllOutOfBandRecords(@Request() request: Req, @Query('invitationId') invitationId?: RecordId) { + let outOfBandRecords = await request.agent.oob.getAll() if (invitationId) outOfBandRecords = outOfBandRecords.filter((o) => o.outOfBandInvitation.id === invitationId) @@ -72,10 +68,11 @@ export class OutOfBandController extends Controller { @Example(outOfBandRecordExample) @Get('/:outOfBandId') public async getOutOfBandRecordById( + @Request() request: Req, @Path('outOfBandId') outOfBandId: RecordId, @Res() notFoundError: TsoaResponse<404, { reason: string }> ) { - const outOfBandRecord = await this.agent.oob.findById(outOfBandId) + const outOfBandRecord = await request.agent.oob.findById(outOfBandId) if (!outOfBandRecord) return notFoundError(404, { reason: `Out of band record with id "${outOfBandId}" not found.` }) @@ -100,17 +97,18 @@ export class OutOfBandController extends Controller { }) @Post('/create-invitation') public async createInvitation( + @Request() request: Req, @Res() internalServerError: TsoaResponse<500, { message: string }>, @Body() config: CreateInvitationOptions // props removed because of issues with serialization ) { try { - const outOfBandRecord = await this.agent.oob.createInvitation(config) + const outOfBandRecord = await request.agent.oob.createInvitation(config) return { invitationUrl: outOfBandRecord.outOfBandInvitation.toUrl({ - domain: this.agent.config.endpoints[0], + domain: request.agent.config.endpoints[0], }), invitation: outOfBandRecord.outOfBandInvitation.toJSON({ - useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, + useDidSovPrefixWhereAllowed: request.agent.config.useDidSovPrefixWhereAllowed, }), outOfBandRecord: outOfBandRecord.toJSON(), } @@ -133,6 +131,7 @@ export class OutOfBandController extends Controller { }) @Post('/create-legacy-invitation') public async createLegacyInvitation( + @Request() request: Req, @Res() internalServerError: TsoaResponse<500, { message: string }>, @Body() config?: Omit & RecipientKeyOption ) { @@ -140,25 +139,25 @@ export class OutOfBandController extends Controller { let routing: Routing if (config?.recipientKey) { routing = { - endpoints: this.agent.config.endpoints, + endpoints: request.agent.config.endpoints, routingKeys: [], recipientKey: Key.fromPublicKeyBase58(config.recipientKey, KeyType.Ed25519), mediatorId: undefined, } } else { - routing = await this.agent.mediationRecipient.getRouting({}) + routing = await request.agent.mediationRecipient.getRouting({}) } - const { outOfBandRecord, invitation } = await this.agent.oob.createLegacyInvitation({ + const { outOfBandRecord, invitation } = await request.agent.oob.createLegacyInvitation({ ...config, routing, }) return { invitationUrl: invitation.toUrl({ - domain: this.agent.config.endpoints[0], - useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, + domain: request.agent.config.endpoints[0], + useDidSovPrefixWhereAllowed: request.agent.config.useDidSovPrefixWhereAllowed, }), invitation: invitation.toJSON({ - useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, + useDidSovPrefixWhereAllowed: request.agent.config.useDidSovPrefixWhereAllowed, }), outOfBandRecord: outOfBandRecord.toJSON(), ...(config?.recipientKey ? {} : { recipientKey: routing.recipientKey.publicKeyBase58 }), @@ -183,6 +182,7 @@ export class OutOfBandController extends Controller { }) @Post('/create-legacy-connectionless-invitation') public async createLegacyConnectionlessInvitation( + @Request() request: Req, @Body() config: { recordId: string @@ -195,7 +195,7 @@ export class OutOfBandController extends Controller { try { const agentMessage = JsonTransformer.fromJSON(config.message, AgentMessage) - return await this.agent.oob.createLegacyConnectionlessInvitation({ + return await request.agent.oob.createLegacyConnectionlessInvitation({ ...config, message: agentMessage, }) @@ -221,6 +221,7 @@ export class OutOfBandController extends Controller { }) @Post('/receive-invitation') public async receiveInvitation( + @Request() request: Req, @Body() invitationRequest: ReceiveInvitationProps, @Res() internalServerError: TsoaResponse<500, { message: string }> ) { @@ -228,7 +229,7 @@ export class OutOfBandController extends Controller { try { const invite = new OutOfBandInvitation({ ...invitation, handshakeProtocols: invitation.handshake_protocols }) - const { outOfBandRecord, connectionRecord } = await this.agent.oob.receiveInvitation(invite, config) + const { outOfBandRecord, connectionRecord } = await request.agent.oob.receiveInvitation(invite, config) return { outOfBandRecord: outOfBandRecord.toJSON(), @@ -253,17 +254,21 @@ export class OutOfBandController extends Controller { }) @Post('/receive-invitation-url') public async receiveInvitationFromUrl( + @Request() request: Req, @Body() invitationRequest: ReceiveInvitationByUrlProps, @Res() internalServerError: TsoaResponse<500, { message: string }> ) { const { invitationUrl, ...config } = invitationRequest try { - const linkSecretIds = await this.agent.modules.anoncreds.getLinkSecretIds() + const linkSecretIds = await request.agent.modules.anoncreds.getLinkSecretIds() if (linkSecretIds.length === 0) { - await this.agent.modules.anoncreds.createLinkSecret() + await request.agent.modules.anoncreds.createLinkSecret() } - const { outOfBandRecord, connectionRecord } = await this.agent.oob.receiveInvitationFromUrl(invitationUrl, config) + const { outOfBandRecord, connectionRecord } = await request.agent.oob.receiveInvitationFromUrl( + invitationUrl, + config + ) return { outOfBandRecord: outOfBandRecord.toJSON(), connectionRecord: connectionRecord?.toJSON(), @@ -283,13 +288,14 @@ export class OutOfBandController extends Controller { }) @Post('/:outOfBandId/accept-invitation') public async acceptInvitation( + @Request() request: Req, @Path('outOfBandId') outOfBandId: RecordId, @Body() acceptInvitationConfig: AcceptInvitationConfig, @Res() notFoundError: TsoaResponse<404, { reason: string }>, @Res() internalServerError: TsoaResponse<500, { message: string }> ) { try { - const { outOfBandRecord, connectionRecord } = await this.agent.oob.acceptInvitation( + const { outOfBandRecord, connectionRecord } = await request.agent.oob.acceptInvitation( outOfBandId, acceptInvitationConfig ) @@ -315,13 +321,14 @@ export class OutOfBandController extends Controller { */ @Delete('/:outOfBandId') public async deleteOutOfBandRecord( + @Request() request: Req, @Path('outOfBandId') outOfBandId: RecordId, @Res() notFoundError: TsoaResponse<404, { reason: string }>, @Res() internalServerError: TsoaResponse<500, { message: string }> ) { try { this.setStatus(204) - await this.agent.oob.deleteById(outOfBandId) + await request.agent.oob.deleteById(outOfBandId) } catch (error) { if (error instanceof RecordNotFoundError) { return notFoundError(404, { reason: `Out of band record with id "${outOfBandId}" not found.` }) diff --git a/src/controllers/polygon/PolygonController.ts b/src/controllers/polygon/PolygonController.ts index c65074f1..e91186d6 100644 --- a/src/controllers/polygon/PolygonController.ts +++ b/src/controllers/polygon/PolygonController.ts @@ -1,24 +1,18 @@ -import type { RestAgentModules } from '../../cliAgent' - -import { Agent, AriesFrameworkError } from '@aries-framework/core' +// eslint-disable-next-line import/no-extraneous-dependencies +import { AriesFrameworkError } from '@aries-framework/core' import { generateSecp256k1KeyPair } from '@ayanworks/credo-polygon-w3c-module' import { DidOperation } from '@ayanworks/credo-polygon-w3c-module/build/ledger' +import { Request as Req } from 'express' import { injectable } from 'tsyringe' -import { Route, Tags, Security, Controller, Post, TsoaResponse, Res, Body, Get, Path } from 'tsoa' +import { Route, Tags, Security, Controller, Post, TsoaResponse, Res, Body, Get, Path, Request } from 'tsoa' @Tags('Polygon') -@Security('apiKey') +// @Security('apiKey') +@Security('jwt') @Route('/polygon') @injectable() export class Polygon extends Controller { - private agent: Agent - - public constructor(agent: Agent) { - super() - this.agent = agent - } - /** * Create Secp256k1 key pair for polygon DID * @@ -45,6 +39,7 @@ export class Polygon extends Controller { */ @Post('create-schema') public async createSchema( + @Request() request: Req, @Body() createSchemaRequest: { did: string @@ -62,7 +57,7 @@ export class Polygon extends Controller { }) } - return this.agent.modules.polygon.createSchema({ + return request.agent.modules.polygon.createSchema({ did, schemaName, schema, @@ -79,6 +74,7 @@ export class Polygon extends Controller { */ @Post('estimate-transaction') public async estimateTransaction( + @Request() request: Req, @Body() estimateTransactionRequest: { operation: any @@ -96,9 +92,9 @@ export class Polygon extends Controller { }) } if (operation === DidOperation.Create) { - return this.agent.modules.polygon.estimateFeeForDidOperation({ operation }) + return request.agent.modules.polygon.estimateFeeForDidOperation({ operation }) } else if (operation === DidOperation.Update) { - return this.agent.modules.polygon.estimateFeeForDidOperation({ operation }) + return request.agent.modules.polygon.estimateFeeForDidOperation({ operation }) } } catch (error) { return internalServerError(500, { message: `something went wrong: ${error}` }) @@ -112,13 +108,14 @@ export class Polygon extends Controller { */ @Get(':did/:schemaId') public async getSchemaById( + @Request() request: Req, @Path('did') did: string, @Path('schemaId') schemaId: string, @Res() internalServerError: TsoaResponse<500, { message: string }>, @Res() forbiddenError: TsoaResponse<401, { reason: string }> ): Promise { try { - return this.agent.modules.polygon.getSchemaById(did, schemaId) + return request.agent.modules.polygon.getSchemaById(did, schemaId) } catch (error) { if (error instanceof AriesFrameworkError) { if (error.message.includes('UnauthorizedClientRequest')) { diff --git a/src/controllers/proofs/ProofController.ts b/src/controllers/proofs/ProofController.ts index 5f9bed8c..5ae8fc99 100644 --- a/src/controllers/proofs/ProofController.ts +++ b/src/controllers/proofs/ProofController.ts @@ -5,7 +5,10 @@ import type { Routing, } from '@aries-framework/core' -import { Agent, HandshakeProtocol, Key, KeyType, RecordNotFoundError } from '@aries-framework/core' +// eslint-disable-next-line import/no-extraneous-dependencies +import { HandshakeProtocol, Key, KeyType, RecordNotFoundError } from '@aries-framework/core' +import { Request as Req } from 'express' +// eslint-disable-next-line import/no-extraneous-dependencies import { injectable } from 'tsyringe' import { ProofRecordExample, RecordId } from '../examples' @@ -16,19 +19,28 @@ import { RequestProofProposalOptions, } from '../types' -import { Body, Controller, Example, Get, Path, Post, Query, Res, Route, Tags, TsoaResponse, Security } from 'tsoa' +import { + Body, + Controller, + Example, + Get, + Path, + Post, + Query, + Res, + Route, + Tags, + TsoaResponse, + Security, + Request, +} from 'tsoa' @Tags('Proofs') @Route('/proofs') -@Security('apiKey') +// @Security('apiKey') +@Security('jwt') @injectable() export class ProofController extends Controller { - private agent: Agent - public constructor(agent: Agent) { - super() - this.agent = agent - } - /** * Retrieve all proof records * @@ -37,8 +49,8 @@ export class ProofController extends Controller { */ @Example([ProofRecordExample]) @Get('/') - public async getAllProofs(@Query('threadId') threadId?: string) { - let proofs = await this.agent.proofs.getAll() + public async getAllProofs(@Request() request: Req, @Query('threadId') threadId?: string) { + let proofs = await request.agent.proofs.getAll() if (threadId) proofs = proofs.filter((p) => p.threadId === threadId) @@ -54,12 +66,13 @@ export class ProofController extends Controller { @Get('/:proofRecordId') @Example(ProofRecordExample) public async getProofById( + @Request() request: Req, @Path('proofRecordId') proofRecordId: RecordId, @Res() notFoundError: TsoaResponse<404, { reason: string }>, @Res() internalServerError: TsoaResponse<500, { message: string }> ) { try { - const proof = await this.agent.proofs.getById(proofRecordId) + const proof = await request.agent.proofs.getById(proofRecordId) return proof.toJSON() } catch (error) { @@ -82,12 +95,13 @@ export class ProofController extends Controller { @Post('/propose-proof') @Example(ProofRecordExample) public async proposeProof( + @Request() request: Req, @Body() requestProofProposalOptions: RequestProofProposalOptions, @Res() notFoundError: TsoaResponse<404, { reason: string }>, @Res() internalServerError: TsoaResponse<500, { message: string }> ) { try { - const proof = await this.agent.proofs.proposeProof({ + const proof = await request.agent.proofs.proposeProof({ connectionId: requestProofProposalOptions.connectionId, protocolVersion: 'v1' as ProofsProtocolVersionType<[]>, proofFormats: requestProofProposalOptions.proofFormats, @@ -119,12 +133,13 @@ export class ProofController extends Controller { @Post('/:proofRecordId/accept-proposal') @Example(ProofRecordExample) public async acceptProposal( + @Request() request: Req, @Body() acceptProposal: AcceptProofProposal, @Res() notFoundError: TsoaResponse<404, { reason: string }>, @Res() internalServerError: TsoaResponse<500, { message: string }> ) { try { - const proof = await this.agent.proofs.acceptProposal(acceptProposal) + const proof = await request.agent.proofs.acceptProposal(acceptProposal) return proof } catch (error) { @@ -140,6 +155,7 @@ export class ProofController extends Controller { @Post('/request-proof') @Example(ProofRecordExample) public async requestProof( + @Request() request: Req, @Body() requestProofOptions: RequestProofOptions, @Res() notFoundError: TsoaResponse<404, { reason: string }>, @Res() internalServerError: TsoaResponse<500, { message: string }> @@ -155,7 +171,7 @@ export class ProofController extends Controller { parentThreadId: requestProofOptions.parentThreadId, willConfirm: requestProofOptions.willConfirm, } - const proof = await this.agent.proofs.requestProof(requestProofPayload) + const proof = await request.agent.proofs.requestProof(requestProofPayload) return proof } catch (error) { @@ -165,6 +181,7 @@ export class ProofController extends Controller { @Post('create-request-oob') public async createRequest( + @Request() request: Req, @Body() createRequestOptions: CreateProofRequestOobOptions, @Res() internalServerError: TsoaResponse<500, { message: string }> ) { @@ -172,15 +189,15 @@ export class ProofController extends Controller { let routing: Routing if (createRequestOptions?.recipientKey) { routing = { - endpoints: this.agent.config.endpoints, + endpoints: request.agent.config.endpoints, routingKeys: [], recipientKey: Key.fromPublicKeyBase58(createRequestOptions.recipientKey, KeyType.Ed25519), mediatorId: undefined, } } else { - routing = await this.agent.mediationRecipient.getRouting({}) + routing = await request.agent.mediationRecipient.getRouting({}) } - const proof = await this.agent.proofs.createRequest({ + const proof = await request.agent.proofs.createRequest({ protocolVersion: createRequestOptions.protocolVersion as ProofsProtocolVersionType<[]>, proofFormats: createRequestOptions.proofFormats, goalCode: createRequestOptions.goalCode, @@ -190,7 +207,7 @@ export class ProofController extends Controller { comment: createRequestOptions.comment, }) const proofMessage = proof.message - const outOfBandRecord = await this.agent.oob.createInvitation({ + const outOfBandRecord = await request.agent.oob.createInvitation({ label: createRequestOptions.label, handshakeProtocols: [HandshakeProtocol.Connections], messages: [proofMessage], @@ -201,10 +218,10 @@ export class ProofController extends Controller { return { invitationUrl: outOfBandRecord.outOfBandInvitation.toUrl({ - domain: this.agent.config.endpoints[0], + domain: request.agent.config.endpoints[0], }), invitation: outOfBandRecord.outOfBandInvitation.toJSON({ - useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, + useDidSovPrefixWhereAllowed: request.agent.config.useDidSovPrefixWhereAllowed, }), outOfBandRecord: outOfBandRecord.toJSON(), recipientKey: createRequestOptions?.recipientKey ? {} : { recipientKey: routing.recipientKey.publicKeyBase58 }, @@ -225,9 +242,10 @@ export class ProofController extends Controller { @Post('/:proofRecordId/accept-request') @Example(ProofRecordExample) public async acceptRequest( + @Request() request: Req, @Path('proofRecordId') proofRecordId: string, @Body() - request: { + requestBody: { filterByPresentationPreview?: boolean filterByNonRevocationRequirements?: boolean comment?: string @@ -236,17 +254,17 @@ export class ProofController extends Controller { @Res() internalServerError: TsoaResponse<500, { message: string }> ) { try { - const requestedCredentials = await this.agent.proofs.selectCredentialsForRequest({ + const requestedCredentials = await request.agent.proofs.selectCredentialsForRequest({ proofRecordId, }) const acceptProofRequest: AcceptProofRequestOptions = { proofRecordId, - comment: request.comment, + comment: requestBody.comment, proofFormats: requestedCredentials.proofFormats, } - const proof = await this.agent.proofs.acceptRequest(acceptProofRequest) + const proof = await request.agent.proofs.acceptRequest(acceptProofRequest) return proof.toJSON() } catch (error) { @@ -269,12 +287,13 @@ export class ProofController extends Controller { @Post('/:proofRecordId/accept-presentation') @Example(ProofRecordExample) public async acceptPresentation( + @Request() request: Req, @Path('proofRecordId') proofRecordId: string, @Res() notFoundError: TsoaResponse<404, { reason: string }>, @Res() internalServerError: TsoaResponse<500, { message: string }> ) { try { - const proof = await this.agent.proofs.acceptPresentation({ proofRecordId }) + const proof = await request.agent.proofs.acceptPresentation({ proofRecordId }) return proof } catch (error) { if (error instanceof RecordNotFoundError) { @@ -289,12 +308,13 @@ export class ProofController extends Controller { @Get('/:proofRecordId/form-data') @Example(ProofRecordExample) public async proofFormData( + @Request() request: Req, @Path('proofRecordId') proofRecordId: string, @Res() notFoundError: TsoaResponse<404, { reason: string }>, @Res() internalServerError: TsoaResponse<500, { message: string }> ) { try { - const proof = await this.agent.proofs.getFormatData(proofRecordId) + const proof = await request.agent.proofs.getFormatData(proofRecordId) return proof } catch (error) { if (error instanceof RecordNotFoundError) { diff --git a/src/controllers/question-answer/QuestionAnswerController.ts b/src/controllers/question-answer/QuestionAnswerController.ts index ac84d1e8..88788316 100644 --- a/src/controllers/question-answer/QuestionAnswerController.ts +++ b/src/controllers/question-answer/QuestionAnswerController.ts @@ -1,26 +1,22 @@ -import type { RestAgentModules } from '../../cliAgent' import type { ValidResponse } from '@aries-framework/question-answer' -import { Agent, RecordNotFoundError } from '@aries-framework/core' +// eslint-disable-next-line import/no-extraneous-dependencies +import { RecordNotFoundError } from '@aries-framework/core' +// eslint-disable-next-line import/no-extraneous-dependencies import { QuestionAnswerRole, QuestionAnswerState } from '@aries-framework/question-answer' +import { Request as Req } from 'express' import { injectable } from 'tsyringe' import { RecordId } from '../examples' -import { Body, Controller, Get, Path, Post, Res, Route, Tags, TsoaResponse, Query, Security } from 'tsoa' +import { Body, Controller, Get, Path, Post, Res, Route, Tags, TsoaResponse, Query, Security, Request } from 'tsoa' @Tags('Question Answer') @Route('/question-answer') -@Security('apiKey') +// @Security('apiKey') +@Security('jwt') @injectable() export class QuestionAnswerController extends Controller { - private agent: Agent - - public constructor(agent: Agent) { - super() - this.agent = agent - } - /** * Retrieve question and answer records by query * @@ -32,12 +28,13 @@ export class QuestionAnswerController extends Controller { */ @Get('/') public async getQuestionAnswerRecords( + @Request() request: Req, @Query('connectionId') connectionId?: string, @Query('role') role?: QuestionAnswerRole, @Query('state') state?: QuestionAnswerState, @Query('threadId') threadId?: string ) { - const questionAnswerRecords = await this.agent.modules.questionAnswer.findAllByQuery({ + const questionAnswerRecords = await request.agent.modules.questionAnswer.findAllByQuery({ connectionId, role, state, @@ -54,6 +51,7 @@ export class QuestionAnswerController extends Controller { */ @Post('question/:connectionId') public async sendQuestion( + @Request() request: Req, @Path('connectionId') connectionId: RecordId, @Body() config: { @@ -67,7 +65,7 @@ export class QuestionAnswerController extends Controller { try { const { question, validResponses, detail } = config - const record = await this.agent.modules.questionAnswer.sendQuestion(connectionId, { + const record = await request.agent.modules.questionAnswer.sendQuestion(connectionId, { question, validResponses, detail, @@ -90,13 +88,14 @@ export class QuestionAnswerController extends Controller { */ @Post('answer/:id') public async sendAnswer( + @Request() request: Req, @Path('id') id: RecordId, - @Body() request: Record<'response', string>, + @Body() requestBody: Record<'response', string>, @Res() notFoundError: TsoaResponse<404, { reason: string }>, @Res() internalServerError: TsoaResponse<500, { message: string }> ) { try { - const record = await this.agent.modules.questionAnswer.sendAnswer(id, request.response) + const record = await request.agent.modules.questionAnswer.sendAnswer(id, requestBody.response) return record.toJSON() } catch (error) { if (error instanceof RecordNotFoundError) { @@ -113,10 +112,11 @@ export class QuestionAnswerController extends Controller { */ @Get('/:id') public async getQuestionAnswerRecordById( + @Request() request: Req, @Path('id') id: RecordId, @Res() notFoundError: TsoaResponse<404, { reason: string }> ) { - const record = await this.agent.modules.questionAnswer.findById(id) + const record = await request.agent.modules.questionAnswer.findById(id) if (!record) return notFoundError(404, { diff --git a/src/routes/routes.ts b/src/routes/routes.ts index 4831b8e2..f948d17d 100644 --- a/src/routes/routes.ts +++ b/src/routes/routes.ts @@ -3,35 +3,35 @@ // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa import { Controller, ValidationService, FieldErrors, ValidateError, TsoaRoute, HttpStatusCodeLiteral, TsoaResponse, fetchMiddlewares } from '@tsoa/runtime'; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa +import { QuestionAnswerController } from './../controllers/question-answer/QuestionAnswerController'; +// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa +import { ProofController } from './../controllers/proofs/ProofController'; +// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa +import { Polygon } from './../controllers/polygon/PolygonController'; +// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa +import { OutOfBandController } from './../controllers/outofband/OutOfBandController'; +// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa import { AgentController } from './../controllers/agent/AgentController'; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa import { BasicMessageController } from './../controllers/basic-messages/BasicMessageController'; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa import { ConnectionController } from './../controllers/connections/ConnectionController'; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa -import { OutOfBandController } from './../controllers/outofband/OutOfBandController'; -// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa import { CredentialDefinitionController } from './../controllers/credentials/CredentialDefinitionController'; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa import { SchemaController } from './../controllers/credentials/SchemaController'; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa import { DidController } from './../controllers/did/DidController'; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa -import { MultiTenancyController } from './../controllers/multi-tenancy/MultiTenancyController'; -// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa -import { ProofController } from './../controllers/proofs/ProofController'; -// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa import { EndorserTransactionController } from './../controllers/endorser-transaction/EndorserTransactionController'; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa import { CredentialController } from './../controllers/credentials/CredentialController'; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa -import { Polygon } from './../controllers/polygon/PolygonController'; -// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa import { MultiTenantController } from './../controllers/additional-endpoint/multitenant.Controller'; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa import { ContextController } from './../controllers/additional-endpoint/context.Controller'; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa -import { QuestionAnswerController } from './../controllers/question-answer/QuestionAnswerController'; +import { MultiTenancyController } from './../controllers/multi-tenancy/MultiTenancyController'; import { expressAuthentication } from './../authentication'; // @ts-ignore - no great way to install types from subpackage import { iocContainer } from './../utils/tsyringeTsoaIocContainer'; @@ -41,48 +41,100 @@ import type { RequestHandler, Router } from 'express'; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa const models: TsoaRoute.Models = { - "AgentInfo": { - "dataType": "refObject", - "properties": { - "label": {"dataType":"string","required":true}, - "endpoints": {"dataType":"array","array":{"dataType":"string"},"required":true}, - "isInitialized": {"dataType":"boolean","required":true}, - "publicDid": {"dataType":"void","required":true}, - }, - "additionalProperties": false, + "Record_string.unknown_": { + "dataType": "refAlias", + "type": {"dataType":"nestedObjectLiteral","nestedProperties":{},"validators":{}}, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "AgentToken": { + "QuestionAnswerRole": { + "dataType": "refEnum", + "enums": ["questioner","responder"], + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "QuestionAnswerState": { + "dataType": "refEnum", + "enums": ["question-sent","question-received","answer-received","answer-sent"], + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "RecordId": { + "dataType": "refAlias", + "type": {"dataType":"string","validators":{}}, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "ValidResponse": { "dataType": "refObject", "properties": { - "token": {"dataType":"string","required":true}, + "text": {"dataType":"string","required":true}, }, "additionalProperties": false, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "Record_string.unknown_": { + "Record_response.string_": { "dataType": "refAlias", - "type": {"dataType":"nestedObjectLiteral","nestedProperties":{},"additionalProperties":{"dataType":"any"},"validators":{}}, + "type": {"dataType":"nestedObjectLiteral","nestedProperties":{"response":{"dataType":"string","required":true}},"validators":{}}, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "BasicMessageRecord": { - "dataType": "refAlias", - "type": {"ref":"Record_string.unknown_","validators":{}}, + "AutoAcceptProof": { + "dataType": "refEnum", + "enums": ["always","contentApproved","never"], }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "RecordId": { - "dataType": "refAlias", - "type": {"dataType":"string","validators":{}}, + "RequestProofProposalOptions": { + "dataType": "refObject", + "properties": { + "connectionId": {"dataType":"string","required":true}, + "proofFormats": {"dataType":"any","required":true}, + "goalCode": {"dataType":"string"}, + "parentThreadId": {"dataType":"string"}, + "autoAcceptProof": {"ref":"AutoAcceptProof"}, + "comment": {"dataType":"string"}, + }, + "additionalProperties": false, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "Record_content.string_": { - "dataType": "refAlias", - "type": {"dataType":"nestedObjectLiteral","nestedProperties":{"content":{"dataType":"string","required":true}},"validators":{}}, + "AcceptProofProposal": { + "dataType": "refObject", + "properties": { + "proofRecordId": {"dataType":"string","required":true}, + "proofFormats": {"dataType":"any","required":true}, + "comment": {"dataType":"string"}, + "autoAcceptProof": {"ref":"AutoAcceptProof"}, + "goalCode": {"dataType":"string"}, + "willConfirm": {"dataType":"boolean"}, + }, + "additionalProperties": false, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "DidExchangeState": { - "dataType": "refEnum", - "enums": ["start","invitation-sent","invitation-received","request-sent","request-received","response-sent","response-received","abandoned","completed"], + "RequestProofOptions": { + "dataType": "refObject", + "properties": { + "connectionId": {"dataType":"string","required":true}, + "protocolVersion": {"dataType":"string","required":true}, + "proofFormats": {"dataType":"any","required":true}, + "comment": {"dataType":"string","required":true}, + "autoAcceptProof": {"ref":"AutoAcceptProof","required":true}, + "goalCode": {"dataType":"string"}, + "parentThreadId": {"dataType":"string"}, + "willConfirm": {"dataType":"boolean"}, + }, + "additionalProperties": false, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "CreateProofRequestOobOptions": { + "dataType": "refObject", + "properties": { + "protocolVersion": {"dataType":"string","required":true}, + "proofFormats": {"dataType":"any","required":true}, + "goalCode": {"dataType":"string"}, + "parentThreadId": {"dataType":"string"}, + "willConfirm": {"dataType":"boolean"}, + "autoAcceptProof": {"ref":"AutoAcceptProof"}, + "comment": {"dataType":"string"}, + "label": {"dataType":"string"}, + "imageUrl": {"dataType":"string"}, + "recipientKey": {"dataType":"string"}, + }, + "additionalProperties": false, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa "HandshakeProtocol": { @@ -218,7 +270,7 @@ const models: TsoaRoute.Models = { // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa "Pick_CreateLegacyInvitationConfig.Exclude_keyofCreateLegacyInvitationConfig.routing__": { "dataType": "refAlias", - "type": {"dataType":"nestedObjectLiteral","nestedProperties":{"label":{"dataType":"string"},"alias":{"dataType":"string"},"imageUrl":{"dataType":"string"},"multiUseInvitation":{"dataType":"boolean"},"autoAcceptConnection":{"dataType":"boolean"}},"validators":{}}, + "type": {"dataType":"nestedObjectLiteral","nestedProperties":{"alias":{"dataType":"string"},"label":{"dataType":"string"},"imageUrl":{"dataType":"string"},"multiUseInvitation":{"dataType":"boolean"},"autoAcceptConnection":{"dataType":"boolean"}},"validators":{}}, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa "Omit_CreateLegacyInvitationConfig.routing_": { @@ -274,7 +326,7 @@ const models: TsoaRoute.Models = { // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa "Pick_ReceiveOutOfBandInvitationConfig.Exclude_keyofReceiveOutOfBandInvitationConfig.routing__": { "dataType": "refAlias", - "type": {"dataType":"nestedObjectLiteral","nestedProperties":{"label":{"dataType":"string"},"alias":{"dataType":"string"},"imageUrl":{"dataType":"string"},"autoAcceptConnection":{"dataType":"boolean"},"autoAcceptInvitation":{"dataType":"boolean"},"reuseConnection":{"dataType":"boolean"},"acceptInvitationTimeoutMs":{"dataType":"double"}},"validators":{}}, + "type": {"dataType":"nestedObjectLiteral","nestedProperties":{"alias":{"dataType":"string"},"label":{"dataType":"string"},"imageUrl":{"dataType":"string"},"autoAcceptConnection":{"dataType":"boolean"},"autoAcceptInvitation":{"dataType":"boolean"},"reuseConnection":{"dataType":"boolean"},"acceptInvitationTimeoutMs":{"dataType":"double"}},"validators":{}}, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa "Omit_ReceiveOutOfBandInvitationConfig.routing_": { @@ -285,8 +337,8 @@ const models: TsoaRoute.Models = { "ReceiveInvitationProps": { "dataType": "refObject", "properties": { - "label": {"dataType":"string"}, "alias": {"dataType":"string"}, + "label": {"dataType":"string"}, "imageUrl": {"dataType":"string"}, "autoAcceptConnection": {"dataType":"boolean"}, "autoAcceptInvitation": {"dataType":"boolean"}, @@ -300,8 +352,8 @@ const models: TsoaRoute.Models = { "ReceiveInvitationByUrlProps": { "dataType": "refObject", "properties": { - "label": {"dataType":"string"}, "alias": {"dataType":"string"}, + "label": {"dataType":"string"}, "imageUrl": {"dataType":"string"}, "autoAcceptConnection": {"dataType":"boolean"}, "autoAcceptInvitation": {"dataType":"boolean"}, @@ -325,6 +377,40 @@ const models: TsoaRoute.Models = { "additionalProperties": false, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "AgentInfo": { + "dataType": "refObject", + "properties": { + "label": {"dataType":"string","required":true}, + "endpoints": {"dataType":"array","array":{"dataType":"string"},"required":true}, + "isInitialized": {"dataType":"boolean","required":true}, + "publicDid": {"dataType":"void","required":true}, + }, + "additionalProperties": false, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "AgentToken": { + "dataType": "refObject", + "properties": { + "token": {"dataType":"string","required":true}, + }, + "additionalProperties": false, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "BasicMessageRecord": { + "dataType": "refAlias", + "type": {"ref":"Record_string.unknown_","validators":{}}, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "Record_content.string_": { + "dataType": "refAlias", + "type": {"dataType":"nestedObjectLiteral","nestedProperties":{"content":{"dataType":"string","required":true}},"validators":{}}, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "DidExchangeState": { + "dataType": "refEnum", + "enums": ["start","invitation-sent","invitation-received","request-sent","request-received","response-sent","response-received","abandoned","completed"], + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa "CredentialDefinitionId": { "dataType": "refAlias", "type": {"dataType":"string","validators":{}}, @@ -398,25 +484,11 @@ const models: TsoaRoute.Models = { "additionalProperties": false, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "Pick_TenantConfig.Exclude_keyofTenantConfig.walletConfig__": { - "dataType": "refAlias", - "type": {"dataType":"nestedObjectLiteral","nestedProperties":{"label":{"dataType":"string","required":true},"connectionImageUrl":{"dataType":"string"}},"validators":{}}, - }, - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "Omit_TenantConfig.walletConfig_": { - "dataType": "refAlias", - "type": {"ref":"Pick_TenantConfig.Exclude_keyofTenantConfig.walletConfig__","validators":{}}, - }, - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "CreateTenantOptions": { + "EndorserTransaction": { "dataType": "refObject", "properties": { - "config": {"ref":"Omit_TenantConfig.walletConfig_","required":true}, - "seed": {"dataType":"string"}, - "method": {"dataType":"string"}, - "role": {"dataType":"string"}, - "endorserDid": {"dataType":"string"}, - "did": {"dataType":"string"}, + "transaction": {"dataType":"union","subSchemas":[{"dataType":"string"},{"ref":"Record_string.unknown_"}],"required":true}, + "endorserDid": {"dataType":"string","required":true}, }, "additionalProperties": false, }, @@ -430,39 +502,63 @@ const models: TsoaRoute.Models = { "additionalProperties": false, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "EndorserTransaction": { + "WriteTransaction": { "dataType": "refObject", "properties": { - "transaction": {"dataType":"union","subSchemas":[{"dataType":"string"},{"ref":"Record_string.unknown_"}],"required":true}, - "endorserDid": {"dataType":"string","required":true}, + "endorsedTransaction": {"dataType":"string","required":true}, + "endorserDid": {"dataType":"string"}, + "schema": {"dataType":"nestedObjectLiteral","nestedProperties":{"attributes":{"dataType":"array","array":{"dataType":"string"},"required":true},"version":{"ref":"Version","required":true},"name":{"dataType":"string","required":true},"issuerId":{"dataType":"string","required":true}}}, + "credentialDefinition": {"dataType":"nestedObjectLiteral","nestedProperties":{"type":{"dataType":"string","required":true},"value":{"dataType":"any","required":true},"tag":{"dataType":"string","required":true},"issuerId":{"dataType":"string","required":true},"schemaId":{"dataType":"string","required":true}}}, }, "additionalProperties": false, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "Pick_CreateOutOfBandInvitationConfig.Exclude_keyofCreateOutOfBandInvitationConfig.routing-or-appendedAttachments-or-messages__": { + "CredentialState": { + "dataType": "refEnum", + "enums": ["proposal-sent","proposal-received","offer-sent","offer-received","declined","request-sent","request-received","credential-issued","credential-received","done","abandoned"], + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "W3cCredentialRecord": { "dataType": "refAlias", - "type": {"dataType":"nestedObjectLiteral","nestedProperties":{"label":{"dataType":"string"},"alias":{"dataType":"string"},"imageUrl":{"dataType":"string"},"multiUseInvitation":{"dataType":"boolean"},"autoAcceptConnection":{"dataType":"boolean"},"goalCode":{"dataType":"string"},"goal":{"dataType":"string"},"handshake":{"dataType":"boolean"},"handshakeProtocols":{"dataType":"array","array":{"dataType":"refEnum","ref":"HandshakeProtocol"}}},"validators":{}}, + "type": {"ref":"Record_string.unknown_","validators":{}}, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "Omit_CreateOutOfBandInvitationConfig.routing-or-appendedAttachments-or-messages_": { + "ConnectionRecord": { "dataType": "refAlias", - "type": {"ref":"Pick_CreateOutOfBandInvitationConfig.Exclude_keyofCreateOutOfBandInvitationConfig.routing-or-appendedAttachments-or-messages__","validators":{}}, + "type": {"ref":"Record_string.unknown_","validators":{}}, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "WriteTransaction": { + "AutoAcceptCredential": { + "dataType": "refEnum", + "enums": ["always","contentApproved","never"], + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "ProposeCredentialOptions": { "dataType": "refObject", "properties": { - "endorsedTransaction": {"dataType":"string","required":true}, - "endorserDid": {"dataType":"string"}, - "schema": {"dataType":"nestedObjectLiteral","nestedProperties":{"attributes":{"dataType":"array","array":{"dataType":"string"},"required":true},"version":{"ref":"Version","required":true},"name":{"dataType":"string","required":true},"issuerId":{"dataType":"string","required":true}}}, - "credentialDefinition": {"dataType":"nestedObjectLiteral","nestedProperties":{"type":{"dataType":"string","required":true},"value":{"dataType":"any","required":true},"tag":{"dataType":"string","required":true},"issuerId":{"dataType":"string","required":true},"schemaId":{"dataType":"string","required":true}}}, + "connectionRecord": {"ref":"ConnectionRecord","required":true}, + "credentialFormats": {"dataType":"nestedObjectLiteral","nestedProperties":{"indy":{"dataType":"nestedObjectLiteral","nestedProperties":{"attributes":{"dataType":"array","array":{"dataType":"nestedObjectLiteral","nestedProperties":{"value":{"dataType":"string","required":true},"name":{"dataType":"string","required":true}}},"required":true},"issuerDid":{"dataType":"string","required":true},"credentialDefinitionId":{"dataType":"string","required":true},"schemaVersion":{"dataType":"string","required":true},"schemaName":{"dataType":"string","required":true},"schemaId":{"dataType":"string","required":true},"schemaIssuerDid":{"dataType":"string","required":true}},"required":true}},"required":true}, + "autoAcceptCredential": {"ref":"AutoAcceptCredential"}, + "comment": {"dataType":"string"}, + "connectionId": {"dataType":"string","required":true}, }, "additionalProperties": false, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "AutoAcceptCredential": { - "dataType": "refEnum", - "enums": ["always","contentApproved","never"], + "CredentialFormatPayload_CredentialFormats.acceptProposal_": { + "dataType": "refAlias", + "type": {"dataType":"nestedObjectLiteral","nestedProperties":{},"additionalProperties":{"dataType":"any"},"validators":{}}, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "AcceptCredentialProposalOptions": { + "dataType": "refObject", + "properties": { + "credentialRecordId": {"dataType":"string","required":true}, + "credentialFormats": {"ref":"CredentialFormatPayload_CredentialFormats.acceptProposal_"}, + "autoAcceptCredential": {"ref":"AutoAcceptCredential"}, + "comment": {"dataType":"string"}, + }, + "additionalProperties": false, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa "CreateOfferOptions": { @@ -564,1236 +660,96 @@ const models: TsoaRoute.Models = { "additionalProperties": false, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "CredentialFormatPayload_CredentialFormatsFromProtocols_CredentialProtocol-Array_.acceptOffer_": { + "CredentialFormatPayload_CredentialFormats.acceptOffer_": { "dataType": "refAlias", - "type": {"dataType":"nestedObjectLiteral","nestedProperties":{},"validators":{}}, + "type": {"dataType":"nestedObjectLiteral","nestedProperties":{},"additionalProperties":{"dataType":"any"},"validators":{}}, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "AcceptCredentialOfferOptions": { + "CredentialOfferOptions": { "dataType": "refObject", "properties": { + "credentialRecordId": {"dataType":"string","required":true}, + "credentialFormats": {"ref":"CredentialFormatPayload_CredentialFormats.acceptOffer_"}, "autoAcceptCredential": {"ref":"AutoAcceptCredential"}, "comment": {"dataType":"string"}, - "credentialRecordId": {"dataType":"string","required":true}, - "credentialFormats": {"ref":"CredentialFormatPayload_CredentialFormatsFromProtocols_CredentialProtocol-Array_.acceptOffer_"}, }, "additionalProperties": false, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "CredentialState": { - "dataType": "refEnum", - "enums": ["proposal-sent","proposal-received","offer-sent","offer-received","declined","request-sent","request-received","credential-issued","credential-received","done","abandoned"], + "CredentialExchangeRecord": { + "dataType": "refAlias", + "type": {"ref":"Record_string.unknown_","validators":{}}, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "AutoAcceptProof": { - "dataType": "refEnum", - "enums": ["always","contentApproved","never"], + "CredentialFormatPayload_CredentialFormats.acceptRequest_": { + "dataType": "refAlias", + "type": {"dataType":"nestedObjectLiteral","nestedProperties":{},"additionalProperties":{"dataType":"any"},"validators":{}}, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "RequestProofOptions": { + "AcceptCredentialRequestOptions": { "dataType": "refObject", "properties": { - "connectionId": {"dataType":"string","required":true}, - "protocolVersion": {"dataType":"string","required":true}, - "proofFormats": {"dataType":"any","required":true}, - "comment": {"dataType":"string","required":true}, - "autoAcceptProof": {"ref":"AutoAcceptProof","required":true}, - "goalCode": {"dataType":"string"}, - "parentThreadId": {"dataType":"string"}, - "willConfirm": {"dataType":"boolean"}, - }, - "additionalProperties": false, - }, - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "CreateProofRequestOobOptions": { - "dataType": "refObject", - "properties": { - "protocolVersion": {"dataType":"string","required":true}, - "proofFormats": {"dataType":"any","required":true}, - "goalCode": {"dataType":"string"}, - "parentThreadId": {"dataType":"string"}, - "willConfirm": {"dataType":"boolean"}, - "autoAcceptProof": {"ref":"AutoAcceptProof"}, - "comment": {"dataType":"string"}, - "label": {"dataType":"string"}, - "imageUrl": {"dataType":"string"}, - "recipientKey": {"dataType":"string"}, - }, - "additionalProperties": false, - }, - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "QuestionAnswerRole": { - "dataType": "refEnum", - "enums": ["questioner","responder"], - }, - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "QuestionAnswerState": { - "dataType": "refEnum", - "enums": ["question-sent","question-received","answer-received","answer-sent"], - }, - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "ValidResponse": { - "dataType": "refObject", - "properties": { - "text": {"dataType":"string","required":true}, - }, - "additionalProperties": false, - }, - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "Record_response.string_": { - "dataType": "refAlias", - "type": {"dataType":"nestedObjectLiteral","nestedProperties":{"response":{"dataType":"string","required":true}},"validators":{}}, - }, - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "ProofFormat": { - "dataType": "refObject", - "properties": { - "formatKey": {"dataType":"string","required":true}, - "proofFormats": {"dataType":"nestedObjectLiteral","nestedProperties":{"selectCredentialsForRequest":{"dataType":"nestedObjectLiteral","nestedProperties":{"output":{"dataType":"any","required":true},"input":{"dataType":"any","required":true}},"required":true},"getCredentialsForRequest":{"dataType":"nestedObjectLiteral","nestedProperties":{"output":{"dataType":"any","required":true},"input":{"dataType":"any","required":true}},"required":true},"acceptRequest":{"dataType":"any","required":true},"createRequest":{"dataType":"any","required":true},"acceptProposal":{"dataType":"any","required":true},"createProposal":{"dataType":"any","required":true}},"required":true}, - "formatData": {"dataType":"nestedObjectLiteral","nestedProperties":{"presentation":{"dataType":"any","required":true},"request":{"dataType":"any","required":true},"proposal":{"dataType":"any","required":true}},"required":true}, - }, - "additionalProperties": false, - }, - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "RequestProofProposalOptions": { - "dataType": "refObject", - "properties": { - "connectionId": {"dataType":"string","required":true}, - "proofFormats": {"dataType":"nestedObjectLiteral","nestedProperties":{"action":{"dataType":"enum","enums":["createProposal"],"required":true},"formats":{"dataType":"array","array":{"dataType":"refObject","ref":"ProofFormat"},"required":true}},"required":true}, - "goalCode": {"dataType":"string"}, - "parentThreadId": {"dataType":"string"}, - "autoAcceptProof": {"ref":"AutoAcceptProof"}, - "comment": {"dataType":"string"}, - }, - "additionalProperties": false, - }, - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "AcceptProofProposal": { - "dataType": "refObject", - "properties": { - "proofRecordId": {"dataType":"string","required":true}, - "proofFormats": {"dataType":"nestedObjectLiteral","nestedProperties":{"action":{"dataType":"enum","enums":["acceptProposal"],"required":true},"formats":{"dataType":"array","array":{"dataType":"refObject","ref":"ProofFormat"},"required":true}},"required":true}, - "comment": {"dataType":"string"}, - "autoAcceptProof": {"ref":"AutoAcceptProof"}, - "goalCode": {"dataType":"string"}, - "willConfirm": {"dataType":"boolean"}, - }, - "additionalProperties": false, - }, - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "W3cCredentialRecord": { - "dataType": "refAlias", - "type": {"ref":"Record_string.unknown_","validators":{}}, - }, - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "ConnectionRecord": { - "dataType": "refAlias", - "type": {"ref":"Record_string.unknown_","validators":{}}, - }, - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "ProposeCredentialOptions": { - "dataType": "refObject", - "properties": { - "connectionRecord": {"ref":"ConnectionRecord","required":true}, - "credentialFormats": {"dataType":"nestedObjectLiteral","nestedProperties":{"indy":{"dataType":"nestedObjectLiteral","nestedProperties":{"attributes":{"dataType":"array","array":{"dataType":"nestedObjectLiteral","nestedProperties":{"value":{"dataType":"string","required":true},"name":{"dataType":"string","required":true}}},"required":true},"issuerDid":{"dataType":"string","required":true},"credentialDefinitionId":{"dataType":"string","required":true},"schemaVersion":{"dataType":"string","required":true},"schemaName":{"dataType":"string","required":true},"schemaId":{"dataType":"string","required":true},"schemaIssuerDid":{"dataType":"string","required":true}},"required":true}},"required":true}, - "autoAcceptCredential": {"ref":"AutoAcceptCredential"}, - "comment": {"dataType":"string"}, - "connectionId": {"dataType":"string","required":true}, - }, - "additionalProperties": false, - }, - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "CredentialFormatPayload_CredentialFormats.acceptProposal_": { - "dataType": "refAlias", - "type": {"dataType":"nestedObjectLiteral","nestedProperties":{},"additionalProperties":{"dataType":"any"},"validators":{}}, - }, - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "AcceptCredentialProposalOptions": { - "dataType": "refObject", - "properties": { - "credentialRecordId": {"dataType":"string","required":true}, - "credentialFormats": {"ref":"CredentialFormatPayload_CredentialFormats.acceptProposal_"}, - "autoAcceptCredential": {"ref":"AutoAcceptCredential"}, - "comment": {"dataType":"string"}, - }, - "additionalProperties": false, - }, - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "CredentialFormatPayload_CredentialFormats.acceptOffer_": { - "dataType": "refAlias", - "type": {"dataType":"nestedObjectLiteral","nestedProperties":{},"additionalProperties":{"dataType":"any"},"validators":{}}, - }, - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "CredentialOfferOptions": { - "dataType": "refObject", - "properties": { - "credentialRecordId": {"dataType":"string","required":true}, - "credentialFormats": {"ref":"CredentialFormatPayload_CredentialFormats.acceptOffer_"}, - "autoAcceptCredential": {"ref":"AutoAcceptCredential"}, - "comment": {"dataType":"string"}, - }, - "additionalProperties": false, - }, - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "CredentialExchangeRecord": { - "dataType": "refAlias", - "type": {"ref":"Record_string.unknown_","validators":{}}, - }, - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "CredentialFormatPayload_CredentialFormats.acceptRequest_": { - "dataType": "refAlias", - "type": {"dataType":"nestedObjectLiteral","nestedProperties":{},"additionalProperties":{"dataType":"any"},"validators":{}}, - }, - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "AcceptCredentialRequestOptions": { - "dataType": "refObject", - "properties": { - "credentialRecord": {"ref":"CredentialExchangeRecord","required":true}, - "credentialFormats": {"ref":"CredentialFormatPayload_CredentialFormats.acceptRequest_"}, - "autoAcceptCredential": {"ref":"AutoAcceptCredential"}, - "comment": {"dataType":"string"}, - }, - "additionalProperties": false, - }, - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "AcceptCredential": { - "dataType": "refObject", - "properties": { - "credentialRecord": {"ref":"CredentialExchangeRecord","required":true}, - }, - "additionalProperties": false, - }, - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa -}; -const validationService = new ValidationService(models); - -// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - -export function RegisterRoutes(app: Router) { - // ########################################################################################################### - // NOTE: If you do not see routes for all of your controllers in this file, then you might not have informed tsoa of where to look - // Please look into the "controllerPathGlobs" config option described in the readme: https://github.com/lukeautry/tsoa - // ########################################################################################################### - app.get('/agent/info', - authenticateMiddleware([{"jwt":[]}]), - ...(fetchMiddlewares(AgentController)), - ...(fetchMiddlewares(AgentController.prototype.getAgentInfo)), - - async function AgentController_getAgentInfo(request: any, response: any, next: any) { - const args = { - request: {"in":"request","name":"request","required":true,"dataType":"object"}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(AgentController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.getAgentInfo.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/agent/token', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(AgentController)), - ...(fetchMiddlewares(AgentController.prototype.getAgentToken)), - - async function AgentController_getAgentToken(request: any, response: any, next: any) { - const args = { - request: {"in":"request","name":"request","required":true,"dataType":"object"}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(AgentController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.getAgentToken.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.delete('/agent/wallet', - authenticateMiddleware([{"jwt":[]}]), - ...(fetchMiddlewares(AgentController)), - ...(fetchMiddlewares(AgentController.prototype.deleteWallet)), - - async function AgentController_deleteWallet(request: any, response: any, next: any) { - const args = { - request: {"in":"request","name":"request","required":true,"dataType":"object"}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(AgentController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.deleteWallet.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/basic-messages/:connectionId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(BasicMessageController)), - ...(fetchMiddlewares(BasicMessageController.prototype.getBasicMessages)), - - async function BasicMessageController_getBasicMessages(request: any, response: any, next: any) { - const args = { - connectionId: {"in":"path","name":"connectionId","required":true,"ref":"RecordId"}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(BasicMessageController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.getBasicMessages.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/basic-messages/:connectionId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(BasicMessageController)), - ...(fetchMiddlewares(BasicMessageController.prototype.sendMessage)), - - async function BasicMessageController_sendMessage(request: any, response: any, next: any) { - const args = { - connectionId: {"in":"path","name":"connectionId","required":true,"ref":"RecordId"}, - request: {"in":"body","name":"request","required":true,"ref":"Record_content.string_"}, - notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(BasicMessageController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.sendMessage.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/connections', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(ConnectionController)), - ...(fetchMiddlewares(ConnectionController.prototype.getAllConnections)), - - async function ConnectionController_getAllConnections(request: any, response: any, next: any) { - const args = { - outOfBandId: {"in":"query","name":"outOfBandId","dataType":"string"}, - alias: {"in":"query","name":"alias","dataType":"string"}, - state: {"in":"query","name":"state","ref":"DidExchangeState"}, - myDid: {"in":"query","name":"myDid","dataType":"string"}, - theirDid: {"in":"query","name":"theirDid","dataType":"string"}, - theirLabel: {"in":"query","name":"theirLabel","dataType":"string"}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(ConnectionController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.getAllConnections.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/connections/:connectionId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(ConnectionController)), - ...(fetchMiddlewares(ConnectionController.prototype.getConnectionById)), - - async function ConnectionController_getConnectionById(request: any, response: any, next: any) { - const args = { - connectionId: {"in":"path","name":"connectionId","required":true,"ref":"RecordId"}, - notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(ConnectionController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.getConnectionById.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.delete('/connections/:connectionId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(ConnectionController)), - ...(fetchMiddlewares(ConnectionController.prototype.deleteConnection)), - - async function ConnectionController_deleteConnection(request: any, response: any, next: any) { - const args = { - connectionId: {"in":"path","name":"connectionId","required":true,"ref":"RecordId"}, - notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(ConnectionController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.deleteConnection.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/connections/:connectionId/accept-request', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(ConnectionController)), - ...(fetchMiddlewares(ConnectionController.prototype.acceptRequest)), - - async function ConnectionController_acceptRequest(request: any, response: any, next: any) { - const args = { - connectionId: {"in":"path","name":"connectionId","required":true,"ref":"RecordId"}, - notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(ConnectionController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.acceptRequest.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/connections/:connectionId/accept-response', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(ConnectionController)), - ...(fetchMiddlewares(ConnectionController.prototype.acceptResponse)), - - async function ConnectionController_acceptResponse(request: any, response: any, next: any) { - const args = { - connectionId: {"in":"path","name":"connectionId","required":true,"ref":"RecordId"}, - notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(ConnectionController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.acceptResponse.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/url/:invitationId', - ...(fetchMiddlewares(ConnectionController)), - ...(fetchMiddlewares(ConnectionController.prototype.getInvitation)), - - async function ConnectionController_getInvitation(request: any, response: any, next: any) { - const args = { - invitationId: {"in":"path","name":"invitationId","required":true,"dataType":"string"}, - notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(ConnectionController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.getInvitation.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/oob', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(OutOfBandController)), - ...(fetchMiddlewares(OutOfBandController.prototype.getAllOutOfBandRecords)), - - async function OutOfBandController_getAllOutOfBandRecords(request: any, response: any, next: any) { - const args = { - invitationId: {"in":"query","name":"invitationId","ref":"RecordId"}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(OutOfBandController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.getAllOutOfBandRecords.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/oob/:outOfBandId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(OutOfBandController)), - ...(fetchMiddlewares(OutOfBandController.prototype.getOutOfBandRecordById)), - - async function OutOfBandController_getOutOfBandRecordById(request: any, response: any, next: any) { - const args = { - outOfBandId: {"in":"path","name":"outOfBandId","required":true,"ref":"RecordId"}, - notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(OutOfBandController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.getOutOfBandRecordById.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/oob/create-invitation', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(OutOfBandController)), - ...(fetchMiddlewares(OutOfBandController.prototype.createInvitation)), - - async function OutOfBandController_createInvitation(request: any, response: any, next: any) { - const args = { - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - config: {"in":"body","name":"config","required":true,"ref":"CreateInvitationOptions"}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(OutOfBandController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.createInvitation.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/oob/create-legacy-invitation', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(OutOfBandController)), - ...(fetchMiddlewares(OutOfBandController.prototype.createLegacyInvitation)), - - async function OutOfBandController_createLegacyInvitation(request: any, response: any, next: any) { - const args = { - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - config: {"in":"body","name":"config","dataType":"intersection","subSchemas":[{"ref":"Omit_CreateLegacyInvitationConfig.routing_"},{"ref":"RecipientKeyOption"}]}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(OutOfBandController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.createLegacyInvitation.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/oob/create-legacy-connectionless-invitation', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(OutOfBandController)), - ...(fetchMiddlewares(OutOfBandController.prototype.createLegacyConnectionlessInvitation)), - - async function OutOfBandController_createLegacyConnectionlessInvitation(request: any, response: any, next: any) { - const args = { - config: {"in":"body","name":"config","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"domain":{"dataType":"string","required":true},"message":{"ref":"AgentMessageType","required":true},"recordId":{"dataType":"string","required":true}}}, - notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(OutOfBandController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.createLegacyConnectionlessInvitation.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/oob/receive-invitation', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(OutOfBandController)), - ...(fetchMiddlewares(OutOfBandController.prototype.receiveInvitation)), - - async function OutOfBandController_receiveInvitation(request: any, response: any, next: any) { - const args = { - invitationRequest: {"in":"body","name":"invitationRequest","required":true,"ref":"ReceiveInvitationProps"}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(OutOfBandController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.receiveInvitation.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/oob/receive-invitation-url', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(OutOfBandController)), - ...(fetchMiddlewares(OutOfBandController.prototype.receiveInvitationFromUrl)), - - async function OutOfBandController_receiveInvitationFromUrl(request: any, response: any, next: any) { - const args = { - invitationRequest: {"in":"body","name":"invitationRequest","required":true,"ref":"ReceiveInvitationByUrlProps"}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(OutOfBandController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.receiveInvitationFromUrl.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/oob/:outOfBandId/accept-invitation', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(OutOfBandController)), - ...(fetchMiddlewares(OutOfBandController.prototype.acceptInvitation)), - - async function OutOfBandController_acceptInvitation(request: any, response: any, next: any) { - const args = { - outOfBandId: {"in":"path","name":"outOfBandId","required":true,"ref":"RecordId"}, - acceptInvitationConfig: {"in":"body","name":"acceptInvitationConfig","required":true,"ref":"AcceptInvitationConfig"}, - notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(OutOfBandController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.acceptInvitation.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.delete('/oob/:outOfBandId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(OutOfBandController)), - ...(fetchMiddlewares(OutOfBandController.prototype.deleteOutOfBandRecord)), - - async function OutOfBandController_deleteOutOfBandRecord(request: any, response: any, next: any) { - const args = { - outOfBandId: {"in":"path","name":"outOfBandId","required":true,"ref":"RecordId"}, - notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(OutOfBandController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.deleteOutOfBandRecord.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/credential-definitions/:credentialDefinitionId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(CredentialDefinitionController)), - ...(fetchMiddlewares(CredentialDefinitionController.prototype.getCredentialDefinitionById)), - - async function CredentialDefinitionController_getCredentialDefinitionById(request: any, response: any, next: any) { - const args = { - credentialDefinitionId: {"in":"path","name":"credentialDefinitionId","required":true,"ref":"CredentialDefinitionId"}, - badRequestError: {"in":"res","name":"400","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(CredentialDefinitionController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.getCredentialDefinitionById.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/credential-definitions', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(CredentialDefinitionController)), - ...(fetchMiddlewares(CredentialDefinitionController.prototype.createCredentialDefinition)), - - async function CredentialDefinitionController_createCredentialDefinition(request: any, response: any, next: any) { - const args = { - credentialDefinitionRequest: {"in":"body","name":"credentialDefinitionRequest","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"endorserDid":{"dataType":"string"},"endorse":{"dataType":"boolean"},"tag":{"dataType":"string","required":true},"schemaId":{"ref":"SchemaId","required":true},"issuerId":{"dataType":"string","required":true}}}, - notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(CredentialDefinitionController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.createCredentialDefinition.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/schemas/:schemaId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(SchemaController)), - ...(fetchMiddlewares(SchemaController.prototype.getSchemaById)), - - async function SchemaController_getSchemaById(request: any, response: any, next: any) { - const args = { - schemaId: {"in":"path","name":"schemaId","required":true,"ref":"SchemaId"}, - notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - forbiddenError: {"in":"res","name":"403","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - badRequestError: {"in":"res","name":"400","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(SchemaController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.getSchemaById.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/schemas', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(SchemaController)), - ...(fetchMiddlewares(SchemaController.prototype.createSchema)), - - async function SchemaController_createSchema(request: any, response: any, next: any) { - const args = { - schema: {"in":"body","name":"schema","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"endorserDid":{"dataType":"string"},"endorse":{"dataType":"boolean"},"attributes":{"dataType":"array","array":{"dataType":"string"},"required":true},"version":{"ref":"Version","required":true},"name":{"dataType":"string","required":true},"issuerId":{"dataType":"string","required":true}}}, - forbiddenError: {"in":"res","name":"400","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(SchemaController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.createSchema.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/dids/:did', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(DidController)), - ...(fetchMiddlewares(DidController.prototype.getDidRecordByDid)), - - async function DidController_getDidRecordByDid(request: any, response: any, next: any) { - const args = { - did: {"in":"path","name":"did","required":true,"ref":"Did"}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(DidController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.getDidRecordByDid.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/dids/write', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(DidController)), - ...(fetchMiddlewares(DidController.prototype.writeDid)), - - async function DidController_writeDid(request: any, response: any, next: any) { - const args = { - createDidOptions: {"in":"body","name":"createDidOptions","required":true,"ref":"DidCreate"}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(DidController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.writeDid.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/dids', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(DidController)), - ...(fetchMiddlewares(DidController.prototype.getDids)), - - async function DidController_getDids(request: any, response: any, next: any) { - const args = { - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(DidController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.getDids.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/multi-tenancy/create-tenant', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.createTenant)), - - async function MultiTenancyController_createTenant(request: any, response: any, next: any) { - const args = { - createTenantOptions: {"in":"body","name":"createTenantOptions","required":true,"ref":"CreateTenantOptions"}, - notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(MultiTenancyController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.createTenant.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/multi-tenancy/create-did/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.createDid)), - - async function MultiTenancyController_createDid(request: any, response: any, next: any) { - const args = { - createDidOptions: {"in":"body","name":"createDidOptions","required":true,"ref":"DidCreate"}, - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, - notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(MultiTenancyController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.createDid.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/multi-tenancy/dids/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.getDids)), - - async function MultiTenancyController_getDids(request: any, response: any, next: any) { - const args = { - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(MultiTenancyController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.getDids.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/multi-tenancy/transactions/set-endorser-role/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.didNymTransaction)), - - async function MultiTenancyController_didNymTransaction(request: any, response: any, next: any) { - const args = { - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, - didNymTransaction: {"in":"body","name":"didNymTransaction","required":true,"ref":"DidNymTransaction"}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(MultiTenancyController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } + "credentialRecord": {"ref":"CredentialExchangeRecord","required":true}, + "credentialFormats": {"ref":"CredentialFormatPayload_CredentialFormats.acceptRequest_"}, + "autoAcceptCredential": {"ref":"AutoAcceptCredential"}, + "comment": {"dataType":"string"}, + }, + "additionalProperties": false, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "AcceptCredential": { + "dataType": "refObject", + "properties": { + "credentialRecord": {"ref":"CredentialExchangeRecord","required":true}, + }, + "additionalProperties": false, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "Pick_TenantConfig.Exclude_keyofTenantConfig.walletConfig__": { + "dataType": "refAlias", + "type": {"dataType":"nestedObjectLiteral","nestedProperties":{"label":{"dataType":"string","required":true},"connectionImageUrl":{"dataType":"string"}},"validators":{}}, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "Omit_TenantConfig.walletConfig_": { + "dataType": "refAlias", + "type": {"ref":"Pick_TenantConfig.Exclude_keyofTenantConfig.walletConfig__","validators":{}}, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "CreateTenantOptions": { + "dataType": "refObject", + "properties": { + "config": {"ref":"Omit_TenantConfig.walletConfig_","required":true}, + "seed": {"dataType":"string"}, + "method": {"dataType":"string"}, + "role": {"dataType":"string"}, + "endorserDid": {"dataType":"string"}, + "did": {"dataType":"string"}, + }, + "additionalProperties": false, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa +}; +const validationService = new ValidationService(models); +// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - const promise = controller.didNymTransaction.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/multi-tenancy/transactions/endorse/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.endorserTransaction)), +export function RegisterRoutes(app: Router) { + // ########################################################################################################### + // NOTE: If you do not see routes for all of your controllers in this file, then you might not have informed tsoa of where to look + // Please look into the "controllerPathGlobs" config option described in the readme: https://github.com/lukeautry/tsoa + // ########################################################################################################### + app.get('/question-answer', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(QuestionAnswerController)), + ...(fetchMiddlewares(QuestionAnswerController.prototype.getQuestionAnswerRecords)), - async function MultiTenancyController_endorserTransaction(request: any, response: any, next: any) { + async function QuestionAnswerController_getQuestionAnswerRecords(request: any, response: any, next: any) { const args = { - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, - endorserTransaction: {"in":"body","name":"endorserTransaction","required":true,"ref":"EndorserTransaction"}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - forbiddenError: {"in":"res","name":"400","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + connectionId: {"in":"query","name":"connectionId","dataType":"string"}, + role: {"in":"query","name":"role","ref":"QuestionAnswerRole"}, + state: {"in":"query","name":"state","ref":"QuestionAnswerState"}, + threadId: {"in":"query","name":"threadId","dataType":"string"}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -1804,29 +760,31 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(QuestionAnswerController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.endorserTransaction.apply(controller, validatedArgs as any); + const promise = controller.getQuestionAnswerRecords.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/multi-tenancy/connections/:connectionId/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.getConnectionById)), + app.post('/question-answer/question/:connectionId', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(QuestionAnswerController)), + ...(fetchMiddlewares(QuestionAnswerController.prototype.sendQuestion)), - async function MultiTenancyController_getConnectionById(request: any, response: any, next: any) { + async function QuestionAnswerController_sendQuestion(request: any, response: any, next: any) { const args = { - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, connectionId: {"in":"path","name":"connectionId","required":true,"ref":"RecordId"}, + config: {"in":"body","name":"config","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"detail":{"dataType":"string"},"validResponses":{"dataType":"array","array":{"dataType":"refObject","ref":"ValidResponse"},"required":true},"question":{"dataType":"string","required":true}}}, notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, + internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -1837,29 +795,31 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(QuestionAnswerController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.getConnectionById.apply(controller, validatedArgs as any); + const promise = controller.sendQuestion.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/multi-tenancy/create-invitation/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.createInvitation)), + app.post('/question-answer/answer/:id', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(QuestionAnswerController)), + ...(fetchMiddlewares(QuestionAnswerController.prototype.sendAnswer)), - async function MultiTenancyController_createInvitation(request: any, response: any, next: any) { + async function QuestionAnswerController_sendAnswer(request: any, response: any, next: any) { const args = { + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + id: {"in":"path","name":"id","required":true,"ref":"RecordId"}, + requestBody: {"in":"body","name":"requestBody","required":true,"ref":"Record_response.string_"}, + notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, - config: {"in":"body","name":"config","ref":"Omit_CreateOutOfBandInvitationConfig.routing-or-appendedAttachments-or-messages_"}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -1870,29 +830,29 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(QuestionAnswerController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.createInvitation.apply(controller, validatedArgs as any); + const promise = controller.sendAnswer.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/multi-tenancy/create-legacy-invitation/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.createLegacyInvitation)), + app.get('/question-answer/:id', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(QuestionAnswerController)), + ...(fetchMiddlewares(QuestionAnswerController.prototype.getQuestionAnswerRecordById)), - async function MultiTenancyController_createLegacyInvitation(request: any, response: any, next: any) { + async function QuestionAnswerController_getQuestionAnswerRecordById(request: any, response: any, next: any) { const args = { - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, - config: {"in":"body","name":"config","dataType":"intersection","subSchemas":[{"ref":"Omit_CreateOutOfBandInvitationConfig.routing-or-appendedAttachments-or-messages_"},{"ref":"RecipientKeyOption"}]}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + id: {"in":"path","name":"id","required":true,"ref":"RecordId"}, + notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -1903,29 +863,28 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(QuestionAnswerController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.createLegacyInvitation.apply(controller, validatedArgs as any); + const promise = controller.getQuestionAnswerRecordById.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/multi-tenancy/receive-invitation/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.receiveInvitation)), + app.get('/proofs', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(ProofController)), + ...(fetchMiddlewares(ProofController.prototype.getAllProofs)), - async function MultiTenancyController_receiveInvitation(request: any, response: any, next: any) { + async function ProofController_getAllProofs(request: any, response: any, next: any) { const args = { - invitationRequest: {"in":"body","name":"invitationRequest","required":true,"ref":"ReceiveInvitationProps"}, - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + threadId: {"in":"query","name":"threadId","dataType":"string"}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -1936,28 +895,29 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(ProofController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.receiveInvitation.apply(controller, validatedArgs as any); + const promise = controller.getAllProofs.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/multi-tenancy/receive-invitation-url/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.receiveInvitationFromUrl)), + app.get('/proofs/:proofRecordId', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(ProofController)), + ...(fetchMiddlewares(ProofController.prototype.getProofById)), - async function MultiTenancyController_receiveInvitationFromUrl(request: any, response: any, next: any) { + async function ProofController_getProofById(request: any, response: any, next: any) { const args = { - invitationRequest: {"in":"body","name":"invitationRequest","required":true,"ref":"ReceiveInvitationByUrlProps"}, - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + proofRecordId: {"in":"path","name":"proofRecordId","required":true,"ref":"RecordId"}, + notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; @@ -1969,29 +929,30 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(ProofController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.receiveInvitationFromUrl.apply(controller, validatedArgs as any); + const promise = controller.getProofById.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/multi-tenancy/oob/:invitationId/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.getAllOutOfBandRecords)), + app.post('/proofs/propose-proof', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(ProofController)), + ...(fetchMiddlewares(ProofController.prototype.proposeProof)), - async function MultiTenancyController_getAllOutOfBandRecords(request: any, response: any, next: any) { + async function ProofController_proposeProof(request: any, response: any, next: any) { const args = { - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + requestProofProposalOptions: {"in":"body","name":"requestProofProposalOptions","required":true,"ref":"RequestProofProposalOptions"}, + notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - invitationId: {"in":"path","name":"invitationId","required":true,"dataType":"string"}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -2002,34 +963,30 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(ProofController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.getAllOutOfBandRecords.apply(controller, validatedArgs as any); + const promise = controller.proposeProof.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/multi-tenancy/connections/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.getAllConnections)), + app.post('/proofs/:proofRecordId/accept-proposal', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(ProofController)), + ...(fetchMiddlewares(ProofController.prototype.acceptProposal)), - async function MultiTenancyController_getAllConnections(request: any, response: any, next: any) { + async function ProofController_acceptProposal(request: any, response: any, next: any) { const args = { - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + acceptProposal: {"in":"body","name":"acceptProposal","required":true,"ref":"AcceptProofProposal"}, + notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - outOfBandId: {"in":"query","name":"outOfBandId","dataType":"string"}, - alias: {"in":"query","name":"alias","dataType":"string"}, - state: {"in":"query","name":"state","ref":"DidExchangeState"}, - myDid: {"in":"query","name":"myDid","dataType":"string"}, - theirDid: {"in":"query","name":"theirDid","dataType":"string"}, - theirLabel: {"in":"query","name":"theirLabel","dataType":"string"}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -2040,28 +997,30 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(ProofController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.getAllConnections.apply(controller, validatedArgs as any); + const promise = controller.acceptProposal.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/multi-tenancy/url/:tenantId/:invitationId', - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.getInvitation)), + app.post('/proofs/request-proof', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(ProofController)), + ...(fetchMiddlewares(ProofController.prototype.requestProof)), - async function MultiTenancyController_getInvitation(request: any, response: any, next: any) { + async function ProofController_requestProof(request: any, response: any, next: any) { const args = { - invitationId: {"in":"path","name":"invitationId","required":true,"dataType":"string"}, - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + requestProofOptions: {"in":"body","name":"requestProofOptions","required":true,"ref":"RequestProofOptions"}, notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, + internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -2072,29 +1031,28 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(ProofController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.getInvitation.apply(controller, validatedArgs as any); + const promise = controller.requestProof.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/multi-tenancy/schema/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.createSchema)), + app.post('/proofs/create-request-oob', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(ProofController)), + ...(fetchMiddlewares(ProofController.prototype.createRequest)), - async function MultiTenancyController_createSchema(request: any, response: any, next: any) { + async function ProofController_createRequest(request: any, response: any, next: any) { const args = { - schema: {"in":"body","name":"schema","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"endorserDid":{"dataType":"string"},"endorse":{"dataType":"boolean"},"attributes":{"dataType":"array","array":{"dataType":"string"},"required":true},"version":{"ref":"Version","required":true},"name":{"dataType":"string","required":true},"issuerId":{"dataType":"string","required":true}}}, - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, - forbiddenError: {"in":"res","name":"400","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + createRequestOptions: {"in":"body","name":"createRequestOptions","required":true,"ref":"CreateProofRequestOobOptions"}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; @@ -2106,28 +1064,30 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(ProofController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.createSchema.apply(controller, validatedArgs as any); + const promise = controller.createRequest.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/multi-tenancy/polygon-wc3/schema/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.createPolygonW3CSchema)), + app.post('/proofs/:proofRecordId/accept-request', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(ProofController)), + ...(fetchMiddlewares(ProofController.prototype.acceptRequest)), - async function MultiTenancyController_createPolygonW3CSchema(request: any, response: any, next: any) { + async function ProofController_acceptRequest(request: any, response: any, next: any) { const args = { - createSchemaRequest: {"in":"body","name":"createSchemaRequest","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"schema":{"dataType":"object","required":true},"schemaName":{"dataType":"string","required":true},"did":{"dataType":"string","required":true}}}, - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + proofRecordId: {"in":"path","name":"proofRecordId","required":true,"dataType":"string"}, + requestBody: {"in":"body","name":"requestBody","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"comment":{"dataType":"string"},"filterByNonRevocationRequirements":{"dataType":"boolean"},"filterByPresentationPreview":{"dataType":"boolean"}}}, + notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; @@ -2139,32 +1099,30 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(ProofController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.createPolygonW3CSchema.apply(controller, validatedArgs as any); + const promise = controller.acceptRequest.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/multi-tenancy/polygon-wc3/schema/:did/:schemaId/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.getPolygonW3CSchemaById)), + app.post('/proofs/:proofRecordId/accept-presentation', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(ProofController)), + ...(fetchMiddlewares(ProofController.prototype.acceptPresentation)), - async function MultiTenancyController_getPolygonW3CSchemaById(request: any, response: any, next: any) { + async function ProofController_acceptPresentation(request: any, response: any, next: any) { const args = { - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, - did: {"in":"path","name":"did","required":true,"dataType":"string"}, - schemaId: {"in":"path","name":"schemaId","required":true,"dataType":"string"}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + proofRecordId: {"in":"path","name":"proofRecordId","required":true,"dataType":"string"}, + notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - badRequestError: {"in":"res","name":"400","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - forbiddenError: {"in":"res","name":"401","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -2175,30 +1133,30 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(ProofController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.getPolygonW3CSchemaById.apply(controller, validatedArgs as any); + const promise = controller.acceptPresentation.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/multi-tenancy/transactions/write/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.writeSchemaAndCredDefOnLedger)), + app.get('/proofs/:proofRecordId/form-data', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(ProofController)), + ...(fetchMiddlewares(ProofController.prototype.proofFormData)), - async function MultiTenancyController_writeSchemaAndCredDefOnLedger(request: any, response: any, next: any) { + async function ProofController_proofFormData(request: any, response: any, next: any) { const args = { - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, - forbiddenError: {"in":"res","name":"400","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + proofRecordId: {"in":"path","name":"proofRecordId","required":true,"dataType":"string"}, + notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - writeTransaction: {"in":"body","name":"writeTransaction","required":true,"ref":"WriteTransaction"}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -2209,31 +1167,26 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(ProofController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.writeSchemaAndCredDefOnLedger.apply(controller, validatedArgs as any); + const promise = controller.proofFormData.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/multi-tenancy/schema/:schemaId/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.getSchemaById)), + app.post('/polygon/create-keys', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(Polygon)), + ...(fetchMiddlewares(Polygon.prototype.createKeyPair)), - async function MultiTenancyController_getSchemaById(request: any, response: any, next: any) { + async function Polygon_createKeyPair(request: any, response: any, next: any) { const args = { - schemaId: {"in":"path","name":"schemaId","required":true,"ref":"SchemaId"}, - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, - notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - forbiddenError: {"in":"res","name":"403","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - badRequestError: {"in":"res","name":"400","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; @@ -2245,30 +1198,30 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(Polygon); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.getSchemaById.apply(controller, validatedArgs as any); + const promise = controller.createKeyPair.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/multi-tenancy/credential-definition/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.createCredentialDefinition)), + app.post('/polygon/create-schema', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(Polygon)), + ...(fetchMiddlewares(Polygon.prototype.createSchema)), - async function MultiTenancyController_createCredentialDefinition(request: any, response: any, next: any) { + async function Polygon_createSchema(request: any, response: any, next: any) { const args = { - credentialDefinitionRequest: {"in":"body","name":"credentialDefinitionRequest","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"endorserDid":{"dataType":"string"},"endorse":{"dataType":"boolean"},"tag":{"dataType":"string","required":true},"schemaId":{"dataType":"string","required":true},"issuerId":{"dataType":"string","required":true}}}, - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, - notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + createSchemaRequest: {"in":"body","name":"createSchemaRequest","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"schema":{"dataType":"object","required":true},"schemaName":{"dataType":"string","required":true},"did":{"dataType":"string","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, + badRequestError: {"in":"res","name":"400","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -2279,31 +1232,30 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(Polygon); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.createCredentialDefinition.apply(controller, validatedArgs as any); + const promise = controller.createSchema.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/multi-tenancy/credential-definition/:credentialDefinitionId/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.getCredentialDefinitionById)), + app.post('/polygon/estimate-transaction', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(Polygon)), + ...(fetchMiddlewares(Polygon.prototype.estimateTransaction)), - async function MultiTenancyController_getCredentialDefinitionById(request: any, response: any, next: any) { + async function Polygon_estimateTransaction(request: any, response: any, next: any) { const args = { - credentialDefinitionId: {"in":"path","name":"credentialDefinitionId","required":true,"ref":"CredentialDefinitionId"}, - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, - badRequestError: {"in":"res","name":"400","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + estimateTransactionRequest: {"in":"body","name":"estimateTransactionRequest","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"transaction":{"dataType":"any","required":true},"operation":{"dataType":"any","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, + badRequestError: {"in":"res","name":"400","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -2314,29 +1266,31 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(Polygon); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.getCredentialDefinitionById.apply(controller, validatedArgs as any); + const promise = controller.estimateTransaction.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/multi-tenancy/credentials/create-offer/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.createOffer)), + app.get('/polygon/:did/:schemaId', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(Polygon)), + ...(fetchMiddlewares(Polygon.prototype.getSchemaById)), - async function MultiTenancyController_createOffer(request: any, response: any, next: any) { + async function Polygon_getSchemaById(request: any, response: any, next: any) { const args = { - createOfferOptions: {"in":"body","name":"createOfferOptions","required":true,"ref":"CreateOfferOptions"}, - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + did: {"in":"path","name":"did","required":true,"dataType":"string"}, + schemaId: {"in":"path","name":"schemaId","required":true,"dataType":"string"}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, + forbiddenError: {"in":"res","name":"401","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -2347,29 +1301,28 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(Polygon); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.createOffer.apply(controller, validatedArgs as any); + const promise = controller.getSchemaById.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/multi-tenancy/credentials/create-offer-oob/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.createOfferOob)), + app.get('/oob', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(OutOfBandController)), + ...(fetchMiddlewares(OutOfBandController.prototype.getAllOutOfBandRecords)), - async function MultiTenancyController_createOfferOob(request: any, response: any, next: any) { + async function OutOfBandController_getAllOutOfBandRecords(request: any, response: any, next: any) { const args = { - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, - createOfferOptions: {"in":"body","name":"createOfferOptions","required":true,"ref":"CreateOfferOobOptions"}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + invitationId: {"in":"query","name":"invitationId","ref":"RecordId"}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -2380,30 +1333,29 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(OutOfBandController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.createOfferOob.apply(controller, validatedArgs as any); + const promise = controller.getAllOutOfBandRecords.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/multi-tenancy/credentials/accept-offer/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.acceptOffer)), + app.get('/oob/:outOfBandId', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(OutOfBandController)), + ...(fetchMiddlewares(OutOfBandController.prototype.getOutOfBandRecordById)), - async function MultiTenancyController_acceptOffer(request: any, response: any, next: any) { + async function OutOfBandController_getOutOfBandRecordById(request: any, response: any, next: any) { const args = { + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + outOfBandId: {"in":"path","name":"outOfBandId","required":true,"ref":"RecordId"}, notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, - acceptCredentialOfferOptions: {"in":"body","name":"acceptCredentialOfferOptions","required":true,"ref":"AcceptCredentialOfferOptions"}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -2414,30 +1366,29 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(OutOfBandController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.acceptOffer.apply(controller, validatedArgs as any); + const promise = controller.getOutOfBandRecordById.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/multi-tenancy/credentials/:credentialRecordId/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.getCredentialById)), + app.post('/oob/create-invitation', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(OutOfBandController)), + ...(fetchMiddlewares(OutOfBandController.prototype.createInvitation)), - async function MultiTenancyController_getCredentialById(request: any, response: any, next: any) { + async function OutOfBandController_createInvitation(request: any, response: any, next: any) { const args = { - credentialRecordId: {"in":"path","name":"credentialRecordId","required":true,"ref":"RecordId"}, - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, - notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, + config: {"in":"body","name":"config","required":true,"ref":"CreateInvitationOptions"}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -2448,30 +1399,29 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(OutOfBandController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.getCredentialById.apply(controller, validatedArgs as any); + const promise = controller.createInvitation.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/multi-tenancy/credentials/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.getAllCredentials)), + app.post('/oob/create-legacy-invitation', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(OutOfBandController)), + ...(fetchMiddlewares(OutOfBandController.prototype.createLegacyInvitation)), - async function MultiTenancyController_getAllCredentials(request: any, response: any, next: any) { + async function OutOfBandController_createLegacyInvitation(request: any, response: any, next: any) { const args = { - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, - threadId: {"in":"query","name":"threadId","dataType":"string"}, - connectionId: {"in":"query","name":"connectionId","dataType":"string"}, - state: {"in":"query","name":"state","ref":"CredentialState"}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, + config: {"in":"body","name":"config","dataType":"intersection","subSchemas":[{"ref":"Omit_CreateLegacyInvitationConfig.routing_"},{"ref":"RecipientKeyOption"}]}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -2482,28 +1432,30 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(OutOfBandController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.getAllCredentials.apply(controller, validatedArgs as any); + const promise = controller.createLegacyInvitation.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/multi-tenancy/proofs/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.getAllProofs)), + app.post('/oob/create-legacy-connectionless-invitation', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(OutOfBandController)), + ...(fetchMiddlewares(OutOfBandController.prototype.createLegacyConnectionlessInvitation)), - async function MultiTenancyController_getAllProofs(request: any, response: any, next: any) { + async function OutOfBandController_createLegacyConnectionlessInvitation(request: any, response: any, next: any) { const args = { - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, - threadId: {"in":"query","name":"threadId","dataType":"string"}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + config: {"in":"body","name":"config","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"domain":{"dataType":"string","required":true},"message":{"ref":"AgentMessageType","required":true},"recordId":{"dataType":"string","required":true}}}, + notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, + internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -2514,29 +1466,28 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(OutOfBandController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.getAllProofs.apply(controller, validatedArgs as any); + const promise = controller.createLegacyConnectionlessInvitation.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/multi-tenancy/form-data/:tenantId/:proofRecordId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.proofFormData)), + app.post('/oob/receive-invitation', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(OutOfBandController)), + ...(fetchMiddlewares(OutOfBandController.prototype.receiveInvitation)), - async function MultiTenancyController_proofFormData(request: any, response: any, next: any) { + async function OutOfBandController_receiveInvitation(request: any, response: any, next: any) { const args = { - proofRecordId: {"in":"path","name":"proofRecordId","required":true,"dataType":"string"}, - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, - notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + invitationRequest: {"in":"body","name":"invitationRequest","required":true,"ref":"ReceiveInvitationProps"}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; @@ -2548,29 +1499,28 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(OutOfBandController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.proofFormData.apply(controller, validatedArgs as any); + const promise = controller.receiveInvitation.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/multi-tenancy/proofs/request-proof/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.requestProof)), + app.post('/oob/receive-invitation-url', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(OutOfBandController)), + ...(fetchMiddlewares(OutOfBandController.prototype.receiveInvitationFromUrl)), - async function MultiTenancyController_requestProof(request: any, response: any, next: any) { + async function OutOfBandController_receiveInvitationFromUrl(request: any, response: any, next: any) { const args = { - requestProofOptions: {"in":"body","name":"requestProofOptions","required":true,"ref":"RequestProofOptions"}, - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, - notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + invitationRequest: {"in":"body","name":"invitationRequest","required":true,"ref":"ReceiveInvitationByUrlProps"}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; @@ -2582,28 +1532,30 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(OutOfBandController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.requestProof.apply(controller, validatedArgs as any); + const promise = controller.receiveInvitationFromUrl.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/multi-tenancy/proofs/create-request-oob/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.createRequest)), + app.post('/oob/:outOfBandId/accept-invitation', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(OutOfBandController)), + ...(fetchMiddlewares(OutOfBandController.prototype.acceptInvitation)), - async function MultiTenancyController_createRequest(request: any, response: any, next: any) { + async function OutOfBandController_acceptInvitation(request: any, response: any, next: any) { const args = { - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, - createRequestOptions: {"in":"body","name":"createRequestOptions","required":true,"ref":"CreateProofRequestOobOptions"}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + outOfBandId: {"in":"path","name":"outOfBandId","required":true,"ref":"RecordId"}, + acceptInvitationConfig: {"in":"body","name":"acceptInvitationConfig","required":true,"ref":"AcceptInvitationConfig"}, + notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; @@ -2615,29 +1567,28 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(OutOfBandController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.createRequest.apply(controller, validatedArgs as any); + const promise = controller.acceptInvitation.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/multi-tenancy/proofs/:proofRecordId/accept-request/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.acceptRequest)), + app.delete('/oob/:outOfBandId', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(OutOfBandController)), + ...(fetchMiddlewares(OutOfBandController.prototype.deleteOutOfBandRecord)), - async function MultiTenancyController_acceptRequest(request: any, response: any, next: any) { + async function OutOfBandController_deleteOutOfBandRecord(request: any, response: any, next: any) { const args = { - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, - proofRecordId: {"in":"path","name":"proofRecordId","required":true,"dataType":"string"}, - request: {"in":"body","name":"request","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"comment":{"dataType":"string"},"filterByNonRevocationRequirements":{"dataType":"boolean"},"filterByPresentationPreview":{"dataType":"boolean"}}}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + outOfBandId: {"in":"path","name":"outOfBandId","required":true,"ref":"RecordId"}, notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; @@ -2650,30 +1601,27 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(OutOfBandController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.acceptRequest.apply(controller, validatedArgs as any); + const promise = controller.deleteOutOfBandRecord.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/multi-tenancy/proofs/:proofRecordId/accept-presentation/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.acceptPresentation)), + app.get('/agent/info', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(AgentController)), + ...(fetchMiddlewares(AgentController.prototype.getAgentInfo)), - async function MultiTenancyController_acceptPresentation(request: any, response: any, next: any) { + async function AgentController_getAgentInfo(request: any, response: any, next: any) { const args = { - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, - proofRecordId: {"in":"path","name":"proofRecordId","required":true,"dataType":"string"}, - notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -2684,30 +1632,27 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(AgentController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.acceptPresentation.apply(controller, validatedArgs as any); + const promise = controller.getAgentInfo.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/multi-tenancy/proofs/:proofRecordId/:tenantId', + app.post('/agent/token', authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.getProofById)), + ...(fetchMiddlewares(AgentController)), + ...(fetchMiddlewares(AgentController.prototype.getAgentToken)), - async function MultiTenancyController_getProofById(request: any, response: any, next: any) { - const args = { - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, - proofRecordId: {"in":"path","name":"proofRecordId","required":true,"ref":"RecordId"}, - notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, + async function AgentController_getAgentToken(request: any, response: any, next: any) { + const args = { + request: {"in":"request","name":"request","required":true,"dataType":"object"}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -2718,29 +1663,27 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(AgentController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.getProofById.apply(controller, validatedArgs as any); + const promise = controller.getAgentToken.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.delete('/multi-tenancy/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.deleteTenantById)), + app.delete('/agent/wallet', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(AgentController)), + ...(fetchMiddlewares(AgentController.prototype.deleteWallet)), - async function MultiTenancyController_deleteTenantById(request: any, response: any, next: any) { + async function AgentController_deleteWallet(request: any, response: any, next: any) { const args = { - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, - notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -2751,29 +1694,28 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(AgentController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.deleteTenantById.apply(controller, validatedArgs as any); + const promise = controller.deleteWallet.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/multi-tenancy/did/web/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.createDidWeb)), + app.get('/basic-messages/:connectionId', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(BasicMessageController)), + ...(fetchMiddlewares(BasicMessageController.prototype.getBasicMessages)), - async function MultiTenancyController_createDidWeb(request: any, response: any, next: any) { + async function BasicMessageController_getBasicMessages(request: any, response: any, next: any) { const args = { - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, - didOptions: {"in":"body","name":"didOptions","required":true,"ref":"DidCreate"}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, + connectionId: {"in":"path","name":"connectionId","required":true,"ref":"RecordId"}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -2784,28 +1726,30 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(BasicMessageController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.createDidWeb.apply(controller, validatedArgs as any); + const promise = controller.getBasicMessages.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/multi-tenancy/did/key:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.createDidKey)), + app.post('/basic-messages/:connectionId', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(BasicMessageController)), + ...(fetchMiddlewares(BasicMessageController.prototype.sendMessage)), - async function MultiTenancyController_createDidKey(request: any, response: any, next: any) { + async function BasicMessageController_sendMessage(request: any, response: any, next: any) { const args = { - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, - didOptions: {"in":"body","name":"didOptions","required":true,"ref":"DidCreate"}, + connectionId: {"in":"path","name":"connectionId","required":true,"ref":"RecordId"}, + requestBody: {"in":"body","name":"requestBody","required":true,"ref":"Record_content.string_"}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; @@ -2817,31 +1761,33 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(BasicMessageController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.createDidKey.apply(controller, validatedArgs as any); + const promise = controller.sendMessage.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/multi-tenancy/question-answer/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.getQuestionAnswerRecords)), + app.get('/connections', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(ConnectionController)), + ...(fetchMiddlewares(ConnectionController.prototype.getAllConnections)), - async function MultiTenancyController_getQuestionAnswerRecords(request: any, response: any, next: any) { + async function ConnectionController_getAllConnections(request: any, response: any, next: any) { const args = { - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, - connectionId: {"in":"query","name":"connectionId","dataType":"string"}, - role: {"in":"query","name":"role","ref":"QuestionAnswerRole"}, - state: {"in":"query","name":"state","ref":"QuestionAnswerState"}, - threadId: {"in":"query","name":"threadId","dataType":"string"}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + outOfBandId: {"in":"query","name":"outOfBandId","dataType":"string"}, + alias: {"in":"query","name":"alias","dataType":"string"}, + state: {"in":"query","name":"state","ref":"DidExchangeState"}, + myDid: {"in":"query","name":"myDid","dataType":"string"}, + theirDid: {"in":"query","name":"theirDid","dataType":"string"}, + theirLabel: {"in":"query","name":"theirLabel","dataType":"string"}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -2852,31 +1798,29 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(ConnectionController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.getQuestionAnswerRecords.apply(controller, validatedArgs as any); + const promise = controller.getAllConnections.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/multi-tenancy/question-answer/question/:connectionId/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.sendQuestion)), + app.get('/connections/:connectionId', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(ConnectionController)), + ...(fetchMiddlewares(ConnectionController.prototype.getConnectionById)), - async function MultiTenancyController_sendQuestion(request: any, response: any, next: any) { + async function ConnectionController_getConnectionById(request: any, response: any, next: any) { const args = { + request: {"in":"request","name":"request","required":true,"dataType":"object"}, connectionId: {"in":"path","name":"connectionId","required":true,"ref":"RecordId"}, - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, - config: {"in":"body","name":"config","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"detail":{"dataType":"string"},"validResponses":{"dataType":"array","array":{"dataType":"refObject","ref":"ValidResponse"},"required":true},"question":{"dataType":"string","required":true}}}, notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -2887,29 +1831,28 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(ConnectionController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.sendQuestion.apply(controller, validatedArgs as any); + const promise = controller.getConnectionById.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/multi-tenancy/question-answer/answer/:id/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.sendAnswer)), + app.delete('/connections/:connectionId', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(ConnectionController)), + ...(fetchMiddlewares(ConnectionController.prototype.deleteConnection)), - async function MultiTenancyController_sendAnswer(request: any, response: any, next: any) { + async function ConnectionController_deleteConnection(request: any, response: any, next: any) { const args = { - id: {"in":"path","name":"id","required":true,"ref":"RecordId"}, - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, - request: {"in":"body","name":"request","required":true,"ref":"Record_response.string_"}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + connectionId: {"in":"path","name":"connectionId","required":true,"ref":"RecordId"}, notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; @@ -2922,29 +1865,30 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(ConnectionController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.sendAnswer.apply(controller, validatedArgs as any); + const promise = controller.deleteConnection.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/multi-tenancy/question-answer/:id/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenancyController)), - ...(fetchMiddlewares(MultiTenancyController.prototype.getQuestionAnswerRecordById)), + app.post('/connections/:connectionId/accept-request', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(ConnectionController)), + ...(fetchMiddlewares(ConnectionController.prototype.acceptRequest)), - async function MultiTenancyController_getQuestionAnswerRecordById(request: any, response: any, next: any) { + async function ConnectionController_acceptRequest(request: any, response: any, next: any) { const args = { - id: {"in":"path","name":"id","required":true,"ref":"RecordId"}, - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + connectionId: {"in":"path","name":"connectionId","required":true,"ref":"RecordId"}, notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, + internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -2955,27 +1899,30 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(MultiTenancyController); + const controller: any = await container.get(ConnectionController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.getQuestionAnswerRecordById.apply(controller, validatedArgs as any); + const promise = controller.acceptRequest.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/proofs', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(ProofController)), - ...(fetchMiddlewares(ProofController.prototype.getAllProofs)), + app.post('/connections/:connectionId/accept-response', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(ConnectionController)), + ...(fetchMiddlewares(ConnectionController.prototype.acceptResponse)), - async function ProofController_getAllProofs(request: any, response: any, next: any) { + async function ConnectionController_acceptResponse(request: any, response: any, next: any) { const args = { - threadId: {"in":"query","name":"threadId","dataType":"string"}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + connectionId: {"in":"path","name":"connectionId","required":true,"ref":"RecordId"}, + notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, + internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -2986,27 +1933,27 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(ProofController); + const controller: any = await container.get(ConnectionController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.getAllProofs.apply(controller, validatedArgs as any); + const promise = controller.acceptResponse.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/proofs/:proofRecordId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(ProofController)), - ...(fetchMiddlewares(ProofController.prototype.getProofById)), + app.get('/url/:invitationId', + ...(fetchMiddlewares(ConnectionController)), + ...(fetchMiddlewares(ConnectionController.prototype.getInvitation)), - async function ProofController_getProofById(request: any, response: any, next: any) { + async function ConnectionController_getInvitation(request: any, response: any, next: any) { const args = { - proofRecordId: {"in":"path","name":"proofRecordId","required":true,"ref":"RecordId"}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + invitationId: {"in":"path","name":"invitationId","required":true,"dataType":"string"}, notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; @@ -3019,27 +1966,29 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(ProofController); + const controller: any = await container.get(ConnectionController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.getProofById.apply(controller, validatedArgs as any); + const promise = controller.getInvitation.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/proofs/propose-proof', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(ProofController)), - ...(fetchMiddlewares(ProofController.prototype.proposeProof)), + app.get('/credential-definitions/:credentialDefinitionId', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(CredentialDefinitionController)), + ...(fetchMiddlewares(CredentialDefinitionController.prototype.getCredentialDefinitionById)), - async function ProofController_proposeProof(request: any, response: any, next: any) { + async function CredentialDefinitionController_getCredentialDefinitionById(request: any, response: any, next: any) { const args = { - requestProofProposalOptions: {"in":"body","name":"requestProofProposalOptions","required":true,"ref":"RequestProofProposalOptions"}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + credentialDefinitionId: {"in":"path","name":"credentialDefinitionId","required":true,"ref":"CredentialDefinitionId"}, + badRequestError: {"in":"res","name":"400","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; @@ -3052,27 +2001,28 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(ProofController); + const controller: any = await container.get(CredentialDefinitionController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.proposeProof.apply(controller, validatedArgs as any); + const promise = controller.getCredentialDefinitionById.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/proofs/:proofRecordId/accept-proposal', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(ProofController)), - ...(fetchMiddlewares(ProofController.prototype.acceptProposal)), + app.post('/credential-definitions', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(CredentialDefinitionController)), + ...(fetchMiddlewares(CredentialDefinitionController.prototype.createCredentialDefinition)), - async function ProofController_acceptProposal(request: any, response: any, next: any) { + async function CredentialDefinitionController_createCredentialDefinition(request: any, response: any, next: any) { const args = { - acceptProposal: {"in":"body","name":"acceptProposal","required":true,"ref":"AcceptProofProposal"}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + credentialDefinitionRequest: {"in":"body","name":"credentialDefinitionRequest","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"endorserDid":{"dataType":"string"},"endorse":{"dataType":"boolean"},"tag":{"dataType":"string","required":true},"schemaId":{"ref":"SchemaId","required":true},"issuerId":{"dataType":"string","required":true}}}, notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; @@ -3085,28 +2035,31 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(ProofController); + const controller: any = await container.get(CredentialDefinitionController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.acceptProposal.apply(controller, validatedArgs as any); + const promise = controller.createCredentialDefinition.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/proofs/request-proof', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(ProofController)), - ...(fetchMiddlewares(ProofController.prototype.requestProof)), + app.get('/schemas/:schemaId', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(SchemaController)), + ...(fetchMiddlewares(SchemaController.prototype.getSchemaById)), - async function ProofController_requestProof(request: any, response: any, next: any) { + async function SchemaController_getSchemaById(request: any, response: any, next: any) { const args = { - requestProofOptions: {"in":"body","name":"requestProofOptions","required":true,"ref":"RequestProofOptions"}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + schemaId: {"in":"path","name":"schemaId","required":true,"ref":"SchemaId"}, notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, + forbiddenError: {"in":"res","name":"403","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, + badRequestError: {"in":"res","name":"400","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; @@ -3118,27 +2071,29 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(ProofController); + const controller: any = await container.get(SchemaController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.requestProof.apply(controller, validatedArgs as any); + const promise = controller.getSchemaById.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/proofs/create-request-oob', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(ProofController)), - ...(fetchMiddlewares(ProofController.prototype.createRequest)), + app.post('/schemas', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(SchemaController)), + ...(fetchMiddlewares(SchemaController.prototype.createSchema)), - async function ProofController_createRequest(request: any, response: any, next: any) { + async function SchemaController_createSchema(request: any, response: any, next: any) { const args = { - createRequestOptions: {"in":"body","name":"createRequestOptions","required":true,"ref":"CreateProofRequestOobOptions"}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + schema: {"in":"body","name":"schema","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"endorserDid":{"dataType":"string"},"endorse":{"dataType":"boolean"},"attributes":{"dataType":"array","array":{"dataType":"string"},"required":true},"version":{"ref":"Version","required":true},"name":{"dataType":"string","required":true},"issuerId":{"dataType":"string","required":true}}}, + forbiddenError: {"in":"res","name":"400","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; @@ -3150,30 +2105,28 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(ProofController); + const controller: any = await container.get(SchemaController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.createRequest.apply(controller, validatedArgs as any); + const promise = controller.createSchema.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/proofs/:proofRecordId/accept-request', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(ProofController)), - ...(fetchMiddlewares(ProofController.prototype.acceptRequest)), + app.get('/dids/:did', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(DidController)), + ...(fetchMiddlewares(DidController.prototype.getDidRecordByDid)), - async function ProofController_acceptRequest(request: any, response: any, next: any) { + async function DidController_getDidRecordByDid(request: any, response: any, next: any) { const args = { - proofRecordId: {"in":"path","name":"proofRecordId","required":true,"dataType":"string"}, - request: {"in":"body","name":"request","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"comment":{"dataType":"string"},"filterByNonRevocationRequirements":{"dataType":"boolean"},"filterByPresentationPreview":{"dataType":"boolean"}}}, - notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + did: {"in":"path","name":"did","required":true,"ref":"Did"}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -3184,28 +2137,28 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(ProofController); + const controller: any = await container.get(DidController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.acceptRequest.apply(controller, validatedArgs as any); + const promise = controller.getDidRecordByDid.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/proofs/:proofRecordId/accept-presentation', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(ProofController)), - ...(fetchMiddlewares(ProofController.prototype.acceptPresentation)), + app.post('/dids/write', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(DidController)), + ...(fetchMiddlewares(DidController.prototype.writeDid)), - async function ProofController_acceptPresentation(request: any, response: any, next: any) { + async function DidController_writeDid(request: any, response: any, next: any) { const args = { - proofRecordId: {"in":"path","name":"proofRecordId","required":true,"dataType":"string"}, - notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + createDidOptions: {"in":"body","name":"createDidOptions","required":true,"ref":"DidCreate"}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; @@ -3217,28 +2170,27 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(ProofController); + const controller: any = await container.get(DidController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.acceptPresentation.apply(controller, validatedArgs as any); + const promise = controller.writeDid.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/proofs/:proofRecordId/form-data', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(ProofController)), - ...(fetchMiddlewares(ProofController.prototype.proofFormData)), + app.get('/dids', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(DidController)), + ...(fetchMiddlewares(DidController.prototype.getDids)), - async function ProofController_proofFormData(request: any, response: any, next: any) { + async function DidController_getDids(request: any, response: any, next: any) { const args = { - proofRecordId: {"in":"path","name":"proofRecordId","required":true,"dataType":"string"}, - notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; @@ -3250,13 +2202,13 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(ProofController); + const controller: any = await container.get(DidController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.proofFormData.apply(controller, validatedArgs as any); + const promise = controller.getDids.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); @@ -3264,12 +2216,13 @@ export function RegisterRoutes(app: Router) { }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.post('/transactions/endorse', - authenticateMiddleware([{"apiKey":[]}]), + authenticateMiddleware([{"jwt":[]}]), ...(fetchMiddlewares(EndorserTransactionController)), ...(fetchMiddlewares(EndorserTransactionController.prototype.endorserTransaction)), async function EndorserTransactionController_endorserTransaction(request: any, response: any, next: any) { const args = { + request: {"in":"request","name":"request","required":true,"dataType":"object"}, endorserTransaction: {"in":"body","name":"endorserTransaction","required":true,"ref":"EndorserTransaction"}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, forbiddenError: {"in":"res","name":"400","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, @@ -3297,12 +2250,13 @@ export function RegisterRoutes(app: Router) { }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.post('/transactions/set-endorser-role', - authenticateMiddleware([{"apiKey":[]}]), + authenticateMiddleware([{"jwt":[]}]), ...(fetchMiddlewares(EndorserTransactionController)), ...(fetchMiddlewares(EndorserTransactionController.prototype.didNymTransaction)), async function EndorserTransactionController_didNymTransaction(request: any, response: any, next: any) { const args = { + request: {"in":"request","name":"request","required":true,"dataType":"object"}, didNymTransaction: {"in":"body","name":"didNymTransaction","required":true,"ref":"DidNymTransaction"}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; @@ -3329,12 +2283,13 @@ export function RegisterRoutes(app: Router) { }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.post('/transactions/write', - authenticateMiddleware([{"apiKey":[]}]), + authenticateMiddleware([{"jwt":[]}]), ...(fetchMiddlewares(EndorserTransactionController)), ...(fetchMiddlewares(EndorserTransactionController.prototype.writeSchemaAndCredDefOnLedger)), async function EndorserTransactionController_writeSchemaAndCredDefOnLedger(request: any, response: any, next: any) { const args = { + request: {"in":"request","name":"request","required":true,"dataType":"object"}, forbiddenError: {"in":"res","name":"400","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, writeTransaction: {"in":"body","name":"writeTransaction","required":true,"ref":"WriteTransaction"}, @@ -3362,12 +2317,13 @@ export function RegisterRoutes(app: Router) { }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.get('/credentials', - authenticateMiddleware([{"apiKey":[]}]), + authenticateMiddleware([{"jwt":[]}]), ...(fetchMiddlewares(CredentialController)), ...(fetchMiddlewares(CredentialController.prototype.getAllCredentials)), async function CredentialController_getAllCredentials(request: any, response: any, next: any) { const args = { + request: {"in":"request","name":"request","required":true,"dataType":"object"}, threadId: {"in":"query","name":"threadId","dataType":"string"}, connectionId: {"in":"query","name":"connectionId","dataType":"string"}, state: {"in":"query","name":"state","ref":"CredentialState"}, @@ -3395,12 +2351,13 @@ export function RegisterRoutes(app: Router) { }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.get('/credentials/w3c', - authenticateMiddleware([{"apiKey":[]}]), + authenticateMiddleware([{"jwt":[]}]), ...(fetchMiddlewares(CredentialController)), ...(fetchMiddlewares(CredentialController.prototype.getAllW3c)), async function CredentialController_getAllW3c(request: any, response: any, next: any) { const args = { + request: {"in":"request","name":"request","required":true,"dataType":"object"}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -3425,13 +2382,14 @@ export function RegisterRoutes(app: Router) { }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.get('/credentials/w3c/:id', - authenticateMiddleware([{"apiKey":[]}]), + authenticateMiddleware([{"jwt":[]}]), ...(fetchMiddlewares(CredentialController)), ...(fetchMiddlewares(CredentialController.prototype.getW3cById)), async function CredentialController_getW3cById(request: any, response: any, next: any) { const args = { id: {"in":"path","name":"id","required":true,"dataType":"string"}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -3456,12 +2414,13 @@ export function RegisterRoutes(app: Router) { }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.get('/credentials/:credentialRecordId', - authenticateMiddleware([{"apiKey":[]}]), + authenticateMiddleware([{"jwt":[]}]), ...(fetchMiddlewares(CredentialController)), ...(fetchMiddlewares(CredentialController.prototype.getCredentialById)), async function CredentialController_getCredentialById(request: any, response: any, next: any) { const args = { + request: {"in":"request","name":"request","required":true,"dataType":"object"}, credentialRecordId: {"in":"path","name":"credentialRecordId","required":true,"ref":"RecordId"}, notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, @@ -3489,12 +2448,13 @@ export function RegisterRoutes(app: Router) { }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.post('/credentials/propose-credential', - authenticateMiddleware([{"apiKey":[]}]), + authenticateMiddleware([{"jwt":[]}]), ...(fetchMiddlewares(CredentialController)), ...(fetchMiddlewares(CredentialController.prototype.proposeCredential)), async function CredentialController_proposeCredential(request: any, response: any, next: any) { const args = { + request: {"in":"request","name":"request","required":true,"dataType":"object"}, proposeCredentialOptions: {"in":"body","name":"proposeCredentialOptions","required":true,"ref":"ProposeCredentialOptions"}, notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, @@ -3522,12 +2482,13 @@ export function RegisterRoutes(app: Router) { }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.post('/credentials/accept-proposal', - authenticateMiddleware([{"apiKey":[]}]), + authenticateMiddleware([{"jwt":[]}]), ...(fetchMiddlewares(CredentialController)), ...(fetchMiddlewares(CredentialController.prototype.acceptProposal)), async function CredentialController_acceptProposal(request: any, response: any, next: any) { const args = { + request: {"in":"request","name":"request","required":true,"dataType":"object"}, notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, acceptCredentialProposal: {"in":"body","name":"acceptCredentialProposal","required":true,"ref":"AcceptCredentialProposalOptions"}, @@ -3555,12 +2516,13 @@ export function RegisterRoutes(app: Router) { }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.post('/credentials/create-offer', - authenticateMiddleware([{"apiKey":[]}]), + authenticateMiddleware([{"jwt":[]}]), ...(fetchMiddlewares(CredentialController)), ...(fetchMiddlewares(CredentialController.prototype.createOffer)), async function CredentialController_createOffer(request: any, response: any, next: any) { const args = { + request: {"in":"request","name":"request","required":true,"dataType":"object"}, createOfferOptions: {"in":"body","name":"createOfferOptions","required":true,"ref":"CreateOfferOptions"}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; @@ -3587,12 +2549,13 @@ export function RegisterRoutes(app: Router) { }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.post('/credentials/create-offer-oob', - authenticateMiddleware([{"apiKey":[]}]), + authenticateMiddleware([{"jwt":[]}]), ...(fetchMiddlewares(CredentialController)), ...(fetchMiddlewares(CredentialController.prototype.createOfferOob)), async function CredentialController_createOfferOob(request: any, response: any, next: any) { const args = { + request: {"in":"request","name":"request","required":true,"dataType":"object"}, outOfBandOption: {"in":"body","name":"outOfBandOption","required":true,"ref":"CreateOfferOobOptions"}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; @@ -3619,12 +2582,13 @@ export function RegisterRoutes(app: Router) { }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.post('/credentials/accept-offer', - authenticateMiddleware([{"apiKey":[]}]), + authenticateMiddleware([{"jwt":[]}]), ...(fetchMiddlewares(CredentialController)), ...(fetchMiddlewares(CredentialController.prototype.acceptOffer)), async function CredentialController_acceptOffer(request: any, response: any, next: any) { const args = { + request: {"in":"request","name":"request","required":true,"dataType":"object"}, notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, acceptCredentialOfferOptions: {"in":"body","name":"acceptCredentialOfferOptions","required":true,"ref":"CredentialOfferOptions"}, @@ -3652,12 +2616,13 @@ export function RegisterRoutes(app: Router) { }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.post('/credentials/accept-request', - authenticateMiddleware([{"apiKey":[]}]), + authenticateMiddleware([{"jwt":[]}]), ...(fetchMiddlewares(CredentialController)), ...(fetchMiddlewares(CredentialController.prototype.acceptRequest)), async function CredentialController_acceptRequest(request: any, response: any, next: any) { const args = { + request: {"in":"request","name":"request","required":true,"dataType":"object"}, notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, acceptCredentialRequestOptions: {"in":"body","name":"acceptCredentialRequestOptions","required":true,"ref":"AcceptCredentialRequestOptions"}, @@ -3685,12 +2650,13 @@ export function RegisterRoutes(app: Router) { }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.post('/credentials/accept-credential', - authenticateMiddleware([{"apiKey":[]}]), + authenticateMiddleware([{"jwt":[]}]), ...(fetchMiddlewares(CredentialController)), ...(fetchMiddlewares(CredentialController.prototype.acceptCredential)), async function CredentialController_acceptCredential(request: any, response: any, next: any) { const args = { + request: {"in":"request","name":"request","required":true,"dataType":"object"}, notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, acceptCredential: {"in":"body","name":"acceptCredential","required":true,"ref":"AcceptCredential"}, @@ -3717,114 +2683,17 @@ export function RegisterRoutes(app: Router) { } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/polygon/create-keys', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(Polygon)), - ...(fetchMiddlewares(Polygon.prototype.createKeyPair)), - - async function Polygon_createKeyPair(request: any, response: any, next: any) { - const args = { - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(Polygon); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.createKeyPair.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/polygon/create-schema', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(Polygon)), - ...(fetchMiddlewares(Polygon.prototype.createSchema)), - - async function Polygon_createSchema(request: any, response: any, next: any) { - const args = { - createSchemaRequest: {"in":"body","name":"createSchemaRequest","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"schema":{"dataType":"object","required":true},"schemaName":{"dataType":"string","required":true},"did":{"dataType":"string","required":true}}}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - badRequestError: {"in":"res","name":"400","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(Polygon); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.createSchema.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/polygon/estimate-transaction', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(Polygon)), - ...(fetchMiddlewares(Polygon.prototype.estimateTransaction)), - - async function Polygon_estimateTransaction(request: any, response: any, next: any) { - const args = { - estimateTransactionRequest: {"in":"body","name":"estimateTransactionRequest","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"transaction":{"dataType":"any","required":true},"operation":{"dataType":"any","required":true}}}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - badRequestError: {"in":"res","name":"400","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(Polygon); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.estimateTransaction.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/polygon/:did/:schemaId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(Polygon)), - ...(fetchMiddlewares(Polygon.prototype.getSchemaById)), + app.post('/test-endpoint/multi-tenant/create-tenant', + authenticateMiddleware([{"jwt":["multi-tenant"]}]), + ...(fetchMiddlewares(MultiTenantController)), + ...(fetchMiddlewares(MultiTenantController.prototype.createTenant)), - async function Polygon_getSchemaById(request: any, response: any, next: any) { + async function MultiTenantController_createTenant(request: any, response: any, next: any) { const args = { - did: {"in":"path","name":"did","required":true,"dataType":"string"}, - schemaId: {"in":"path","name":"schemaId","required":true,"dataType":"string"}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + createTenantOptions: {"in":"body","name":"createTenantOptions","required":true,"ref":"CreateTenantOptions"}, + notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - forbiddenError: {"in":"res","name":"401","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -3835,28 +2704,28 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(Polygon); + const controller: any = await container.get(MultiTenantController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.getSchemaById.apply(controller, validatedArgs as any); + const promise = controller.createTenant.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/test-endpoint/multi-tenant/create-tenant', - authenticateMiddleware([{"jwt":[]}]), + app.post('/test-endpoint/multi-tenant/get-token/:tenantId', + authenticateMiddleware([{"jwt":["multi-tenant"]}]), ...(fetchMiddlewares(MultiTenantController)), - ...(fetchMiddlewares(MultiTenantController.prototype.createTenant)), + ...(fetchMiddlewares(MultiTenantController.prototype.getTenantToken)), - async function MultiTenantController_createTenant(request: any, response: any, next: any) { + async function MultiTenantController_getTenantToken(request: any, response: any, next: any) { const args = { request: {"in":"request","name":"request","required":true,"dataType":"object"}, - createTenantOptions: {"in":"body","name":"createTenantOptions","required":true,"ref":"CreateTenantOptions"}, + tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; @@ -3875,7 +2744,7 @@ export function RegisterRoutes(app: Router) { } - const promise = controller.createTenant.apply(controller, validatedArgs as any); + const promise = controller.getTenantToken.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); @@ -4080,17 +2949,17 @@ export function RegisterRoutes(app: Router) { } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/question-answer', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(QuestionAnswerController)), - ...(fetchMiddlewares(QuestionAnswerController.prototype.getQuestionAnswerRecords)), + app.post('/multi-tenancy/create-tenant', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(MultiTenancyController)), + ...(fetchMiddlewares(MultiTenancyController.prototype.createTenant)), - async function QuestionAnswerController_getQuestionAnswerRecords(request: any, response: any, next: any) { + async function MultiTenancyController_createTenant(request: any, response: any, next: any) { const args = { - connectionId: {"in":"query","name":"connectionId","dataType":"string"}, - role: {"in":"query","name":"role","ref":"QuestionAnswerRole"}, - state: {"in":"query","name":"state","ref":"QuestionAnswerState"}, - threadId: {"in":"query","name":"threadId","dataType":"string"}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + createTenantOptions: {"in":"body","name":"createTenantOptions","required":true,"ref":"CreateTenantOptions"}, + notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, + internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -4101,28 +2970,28 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(QuestionAnswerController); + const controller: any = await container.get(MultiTenancyController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.getQuestionAnswerRecords.apply(controller, validatedArgs as any); + const promise = controller.createTenant.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/question-answer/question/:connectionId', + app.get('/multi-tenancy/:tenantId', authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(QuestionAnswerController)), - ...(fetchMiddlewares(QuestionAnswerController.prototype.sendQuestion)), + ...(fetchMiddlewares(MultiTenancyController)), + ...(fetchMiddlewares(MultiTenancyController.prototype.getTenantById)), - async function QuestionAnswerController_sendQuestion(request: any, response: any, next: any) { + async function MultiTenancyController_getTenantById(request: any, response: any, next: any) { const args = { - connectionId: {"in":"path","name":"connectionId","required":true,"ref":"RecordId"}, - config: {"in":"body","name":"config","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"detail":{"dataType":"string"},"validResponses":{"dataType":"array","array":{"dataType":"refObject","ref":"ValidResponse"},"required":true},"question":{"dataType":"string","required":true}}}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; @@ -4135,28 +3004,28 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(QuestionAnswerController); + const controller: any = await container.get(MultiTenancyController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.sendQuestion.apply(controller, validatedArgs as any); + const promise = controller.getTenantById.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/question-answer/answer/:id', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(QuestionAnswerController)), - ...(fetchMiddlewares(QuestionAnswerController.prototype.sendAnswer)), + app.post('/multi-tenancy/get-token/:tenantId', + authenticateMiddleware([{"jwt":["multi-tenant"]}]), + ...(fetchMiddlewares(MultiTenancyController)), + ...(fetchMiddlewares(MultiTenancyController.prototype.getTenantToken)), - async function QuestionAnswerController_sendAnswer(request: any, response: any, next: any) { + async function MultiTenancyController_getTenantToken(request: any, response: any, next: any) { const args = { - id: {"in":"path","name":"id","required":true,"ref":"RecordId"}, - request: {"in":"body","name":"request","required":true,"ref":"Record_response.string_"}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; @@ -4169,28 +3038,30 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(QuestionAnswerController); + const controller: any = await container.get(MultiTenancyController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.sendAnswer.apply(controller, validatedArgs as any); + const promise = controller.getTenantToken.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/question-answer/:id', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(QuestionAnswerController)), - ...(fetchMiddlewares(QuestionAnswerController.prototype.getQuestionAnswerRecordById)), + app.delete('/multi-tenancy/:tenantId', + authenticateMiddleware([{"jwt":[]}]), + ...(fetchMiddlewares(MultiTenancyController)), + ...(fetchMiddlewares(MultiTenancyController.prototype.deleteTenantById)), - async function QuestionAnswerController_getQuestionAnswerRecordById(request: any, response: any, next: any) { + async function MultiTenancyController_deleteTenantById(request: any, response: any, next: any) { const args = { - id: {"in":"path","name":"id","required":true,"ref":"RecordId"}, + request: {"in":"request","name":"request","required":true,"dataType":"object"}, + tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, + internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -4201,13 +3072,13 @@ export function RegisterRoutes(app: Router) { const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - const controller: any = await container.get(QuestionAnswerController); + const controller: any = await container.get(MultiTenancyController); if (typeof controller['setStatus'] === 'function') { controller.setStatus(undefined); } - const promise = controller.getQuestionAnswerRecordById.apply(controller, validatedArgs as any); + const promise = controller.deleteTenantById.apply(controller, validatedArgs as any); promiseHandler(controller, promise, response, undefined, next); } catch (err) { return next(err); diff --git a/src/routes/swagger.json b/src/routes/swagger.json index e54bdcac..909b96f0 100644 --- a/src/routes/swagger.json +++ b/src/routes/swagger.json @@ -7,82 +7,189 @@ "requestBodies": {}, "responses": {}, "schemas": { - "AgentInfo": { + "Record_string.unknown_": { + "properties": {}, + "type": "object", + "description": "Construct a type with a set of properties K of type T" + }, + "QuestionAnswerRole": { + "enum": [ + "questioner", + "responder" + ], + "type": "string" + }, + "QuestionAnswerState": { + "description": "QuestionAnswer states inferred from RFC 0113.", + "enum": [ + "question-sent", + "question-received", + "answer-received", + "answer-sent" + ], + "type": "string" + }, + "RecordId": { + "type": "string", + "example": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e" + }, + "ValidResponse": { "properties": { - "label": { + "text": { + "type": "string" + } + }, + "required": [ + "text" + ], + "type": "object", + "additionalProperties": false + }, + "Record_response.string_": { + "properties": { + "response": { + "type": "string" + } + }, + "required": [ + "response" + ], + "type": "object", + "description": "Construct a type with a set of properties K of type T" + }, + "AutoAcceptProof": { + "description": "Typing of the state for auto acceptance", + "enum": [ + "always", + "contentApproved", + "never" + ], + "type": "string" + }, + "RequestProofProposalOptions": { + "properties": { + "connectionId": { "type": "string" }, - "endpoints": { - "items": { - "type": "string" - }, - "type": "array" + "proofFormats": {}, + "goalCode": { + "type": "string" }, - "isInitialized": { - "type": "boolean" + "parentThreadId": { + "type": "string" }, - "publicDid": {} + "autoAcceptProof": { + "$ref": "#/components/schemas/AutoAcceptProof" + }, + "comment": { + "type": "string" + } }, "required": [ - "label", - "endpoints", - "isInitialized", - "publicDid" + "connectionId", + "proofFormats" ], "type": "object", "additionalProperties": false }, - "AgentToken": { + "AcceptProofProposal": { "properties": { - "token": { + "proofRecordId": { + "type": "string" + }, + "proofFormats": {}, + "comment": { "type": "string" + }, + "autoAcceptProof": { + "$ref": "#/components/schemas/AutoAcceptProof" + }, + "goalCode": { + "type": "string" + }, + "willConfirm": { + "type": "boolean" } }, "required": [ - "token" + "proofRecordId", + "proofFormats" ], "type": "object", "additionalProperties": false }, - "Record_string.unknown_": { - "properties": {}, - "additionalProperties": {}, - "type": "object", - "description": "Construct a type with a set of properties K of type T" - }, - "BasicMessageRecord": { - "$ref": "#/components/schemas/Record_string.unknown_" - }, - "RecordId": { - "type": "string", - "example": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e" - }, - "Record_content.string_": { + "RequestProofOptions": { "properties": { - "content": { + "connectionId": { + "type": "string" + }, + "protocolVersion": { "type": "string" + }, + "proofFormats": {}, + "comment": { + "type": "string" + }, + "autoAcceptProof": { + "$ref": "#/components/schemas/AutoAcceptProof" + }, + "goalCode": { + "type": "string" + }, + "parentThreadId": { + "type": "string" + }, + "willConfirm": { + "type": "boolean" } }, "required": [ - "content" + "connectionId", + "protocolVersion", + "proofFormats", + "comment", + "autoAcceptProof" ], "type": "object", - "description": "Construct a type with a set of properties K of type T" + "additionalProperties": false }, - "DidExchangeState": { - "description": "Connection states as defined in RFC 0023.", - "enum": [ - "start", - "invitation-sent", - "invitation-received", - "request-sent", - "request-received", - "response-sent", - "response-received", - "abandoned", - "completed" + "CreateProofRequestOobOptions": { + "properties": { + "protocolVersion": { + "type": "string" + }, + "proofFormats": {}, + "goalCode": { + "type": "string" + }, + "parentThreadId": { + "type": "string" + }, + "willConfirm": { + "type": "boolean" + }, + "autoAcceptProof": { + "$ref": "#/components/schemas/AutoAcceptProof" + }, + "comment": { + "type": "string" + }, + "label": { + "type": "string" + }, + "imageUrl": { + "type": "string" + }, + "recipientKey": { + "type": "string" + } + }, + "required": [ + "protocolVersion", + "proofFormats" ], - "type": "string" + "type": "object", + "additionalProperties": false }, "HandshakeProtocol": { "enum": [ @@ -393,10 +500,10 @@ }, "Pick_CreateLegacyInvitationConfig.Exclude_keyofCreateLegacyInvitationConfig.routing__": { "properties": { - "label": { + "alias": { "type": "string" }, - "alias": { + "label": { "type": "string" }, "imageUrl": { @@ -536,10 +643,10 @@ }, "Pick_ReceiveOutOfBandInvitationConfig.Exclude_keyofReceiveOutOfBandInvitationConfig.routing__": { "properties": { - "label": { + "alias": { "type": "string" }, - "alias": { + "label": { "type": "string" }, "imageUrl": { @@ -568,10 +675,10 @@ }, "ReceiveInvitationProps": { "properties": { - "label": { + "alias": { "type": "string" }, - "alias": { + "label": { "type": "string" }, "imageUrl": { @@ -602,10 +709,10 @@ }, "ReceiveInvitationByUrlProps": { "properties": { - "label": { + "alias": { "type": "string" }, - "alias": { + "label": { "type": "string" }, "imageUrl": { @@ -658,46 +765,113 @@ "type": "object", "additionalProperties": false }, - "CredentialDefinitionId": { - "type": "string", - "example": "WgWxqztrNooG92RXvxSTWv:3:CL:20:tag" - }, - "SchemaId": { - "type": "string", - "example": "WgWxqztrNooG92RXvxSTWv:2:schema_name:1.0" - }, - "Version": { - "type": "string", - "example": "1.0.0" - }, - "Record_string.any_": { - "properties": {}, - "type": "object", - "description": "Construct a type with a set of properties K of type T" - }, - "DidResolutionMetadata": { + "AgentInfo": { "properties": { - "contentType": { + "label": { "type": "string" }, - "error": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "string", - "enum": [ - "invalidDid", - "notFound", - "representationNotSupported", - "unsupportedDidMethod" - ] - } - ] - }, - "message": { - "type": "string" + "endpoints": { + "items": { + "type": "string" + }, + "type": "array" + }, + "isInitialized": { + "type": "boolean" + }, + "publicDid": {} + }, + "required": [ + "label", + "endpoints", + "isInitialized", + "publicDid" + ], + "type": "object", + "additionalProperties": false + }, + "AgentToken": { + "properties": { + "token": { + "type": "string" + } + }, + "required": [ + "token" + ], + "type": "object", + "additionalProperties": false + }, + "BasicMessageRecord": { + "$ref": "#/components/schemas/Record_string.unknown_" + }, + "Record_content.string_": { + "properties": { + "content": { + "type": "string" + } + }, + "required": [ + "content" + ], + "type": "object", + "description": "Construct a type with a set of properties K of type T" + }, + "DidExchangeState": { + "description": "Connection states as defined in RFC 0023.", + "enum": [ + "start", + "invitation-sent", + "invitation-received", + "request-sent", + "request-received", + "response-sent", + "response-received", + "abandoned", + "completed" + ], + "type": "string" + }, + "CredentialDefinitionId": { + "type": "string", + "example": "WgWxqztrNooG92RXvxSTWv:3:CL:20:tag" + }, + "SchemaId": { + "type": "string", + "example": "WgWxqztrNooG92RXvxSTWv:2:schema_name:1.0" + }, + "Version": { + "type": "string", + "example": "1.0.0" + }, + "Record_string.any_": { + "properties": {}, + "type": "object", + "description": "Construct a type with a set of properties K of type T" + }, + "DidResolutionMetadata": { + "properties": { + "contentType": { + "type": "string" + }, + "error": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "string", + "enum": [ + "invalidDid", + "notFound", + "representationNotSupported", + "unsupportedDidMethod" + ] + } + ] + }, + "message": { + "type": "string" } }, "type": "object", @@ -784,68 +958,6 @@ "type": "object", "additionalProperties": false }, - "Pick_TenantConfig.Exclude_keyofTenantConfig.walletConfig__": { - "properties": { - "label": { - "type": "string" - }, - "connectionImageUrl": { - "type": "string" - } - }, - "required": [ - "label" - ], - "type": "object", - "description": "From T, pick a set of properties whose keys are in the union K" - }, - "Omit_TenantConfig.walletConfig_": { - "$ref": "#/components/schemas/Pick_TenantConfig.Exclude_keyofTenantConfig.walletConfig__", - "description": "Construct a type with the properties of T except for those in type K." - }, - "CreateTenantOptions": { - "properties": { - "config": { - "$ref": "#/components/schemas/Omit_TenantConfig.walletConfig_" - }, - "seed": { - "type": "string" - }, - "method": { - "type": "string" - }, - "role": { - "type": "string" - }, - "endorserDid": { - "type": "string" - }, - "did": { - "type": "string" - } - }, - "required": [ - "config" - ], - "type": "object", - "additionalProperties": false - }, - "DidNymTransaction": { - "properties": { - "did": { - "type": "string" - }, - "nymRequest": { - "type": "string" - } - }, - "required": [ - "did", - "nymRequest" - ], - "type": "object", - "additionalProperties": false - }, "EndorserTransaction": { "properties": { "transaction": { @@ -869,45 +981,21 @@ "type": "object", "additionalProperties": false }, - "Pick_CreateOutOfBandInvitationConfig.Exclude_keyofCreateOutOfBandInvitationConfig.routing-or-appendedAttachments-or-messages__": { + "DidNymTransaction": { "properties": { - "label": { - "type": "string" - }, - "alias": { - "type": "string" - }, - "imageUrl": { - "type": "string" - }, - "multiUseInvitation": { - "type": "boolean" - }, - "autoAcceptConnection": { - "type": "boolean" - }, - "goalCode": { + "did": { "type": "string" }, - "goal": { + "nymRequest": { "type": "string" - }, - "handshake": { - "type": "boolean" - }, - "handshakeProtocols": { - "items": { - "$ref": "#/components/schemas/HandshakeProtocol" - }, - "type": "array" } }, + "required": [ + "did", + "nymRequest" + ], "type": "object", - "description": "From T, pick a set of properties whose keys are in the union K" - }, - "Omit_CreateOutOfBandInvitationConfig.routing-or-appendedAttachments-or-messages_": { - "$ref": "#/components/schemas/Pick_CreateOutOfBandInvitationConfig.Exclude_keyofCreateOutOfBandInvitationConfig.routing-or-appendedAttachments-or-messages__", - "description": "Construct a type with the properties of T except for those in type K." + "additionalProperties": false }, "WriteTransaction": { "properties": { @@ -975,6 +1063,29 @@ "type": "object", "additionalProperties": false }, + "CredentialState": { + "description": "Issue Credential states as defined in RFC 0036 and RFC 0453", + "enum": [ + "proposal-sent", + "proposal-received", + "offer-sent", + "offer-received", + "declined", + "request-sent", + "request-received", + "credential-issued", + "credential-received", + "done", + "abandoned" + ], + "type": "string" + }, + "W3cCredentialRecord": { + "$ref": "#/components/schemas/Record_string.unknown_" + }, + "ConnectionRecord": { + "$ref": "#/components/schemas/Record_string.unknown_" + }, "AutoAcceptCredential": { "description": "Typing of the state for auto acceptance", "enum": [ @@ -984,37 +1095,145 @@ ], "type": "string" }, - "CreateOfferOptions": { - "properties": { - "protocolVersion": { - "type": "string" - }, - "connectionId": { - "type": "string" - }, - "credentialFormats": {}, - "autoAcceptCredential": { - "$ref": "#/components/schemas/AutoAcceptCredential" - }, - "comment": { - "type": "string" - } - }, - "required": [ - "protocolVersion", - "connectionId", - "credentialFormats" - ], - "type": "object", - "additionalProperties": false - }, - "CredentialPreviewAttributeOptions": { + "ProposeCredentialOptions": { "properties": { - "name": { - "type": "string" + "connectionRecord": { + "$ref": "#/components/schemas/ConnectionRecord" }, - "mimeType": { - "type": "string" + "credentialFormats": { + "properties": { + "indy": { + "properties": { + "attributes": { + "items": { + "properties": { + "value": { + "type": "string" + }, + "name": { + "type": "string" + } + }, + "required": [ + "value", + "name" + ], + "type": "object" + }, + "type": "array" + }, + "issuerDid": { + "type": "string" + }, + "credentialDefinitionId": { + "type": "string" + }, + "schemaVersion": { + "type": "string" + }, + "schemaName": { + "type": "string" + }, + "schemaId": { + "type": "string" + }, + "schemaIssuerDid": { + "type": "string" + } + }, + "required": [ + "attributes", + "issuerDid", + "credentialDefinitionId", + "schemaVersion", + "schemaName", + "schemaId", + "schemaIssuerDid" + ], + "type": "object" + } + }, + "required": [ + "indy" + ], + "type": "object" + }, + "autoAcceptCredential": { + "$ref": "#/components/schemas/AutoAcceptCredential" + }, + "comment": { + "type": "string" + }, + "connectionId": { + "type": "string" + } + }, + "required": [ + "connectionRecord", + "credentialFormats", + "connectionId" + ], + "type": "object", + "additionalProperties": false + }, + "CredentialFormatPayload_CredentialFormats.acceptProposal_": { + "properties": {}, + "additionalProperties": {}, + "type": "object", + "description": "Get the payload for a specific method from a list of CredentialFormat interfaces and a method" + }, + "AcceptCredentialProposalOptions": { + "properties": { + "credentialRecordId": { + "type": "string" + }, + "credentialFormats": { + "$ref": "#/components/schemas/CredentialFormatPayload_CredentialFormats.acceptProposal_" + }, + "autoAcceptCredential": { + "$ref": "#/components/schemas/AutoAcceptCredential" + }, + "comment": { + "type": "string" + } + }, + "required": [ + "credentialRecordId" + ], + "type": "object", + "additionalProperties": false + }, + "CreateOfferOptions": { + "properties": { + "protocolVersion": { + "type": "string" + }, + "connectionId": { + "type": "string" + }, + "credentialFormats": {}, + "autoAcceptCredential": { + "$ref": "#/components/schemas/AutoAcceptCredential" + }, + "comment": { + "type": "string" + } + }, + "required": [ + "protocolVersion", + "connectionId", + "credentialFormats" + ], + "type": "object", + "additionalProperties": false + }, + "CredentialPreviewAttributeOptions": { + "properties": { + "name": { + "type": "string" + }, + "mimeType": { + "type": "string" }, "value": { "type": "string" @@ -1235,25 +1454,25 @@ "type": "object", "additionalProperties": false }, - "CredentialFormatPayload_CredentialFormatsFromProtocols_CredentialProtocol-Array_.acceptOffer_": { + "CredentialFormatPayload_CredentialFormats.acceptOffer_": { "properties": {}, + "additionalProperties": {}, "type": "object", "description": "Get the payload for a specific method from a list of CredentialFormat interfaces and a method" }, - "AcceptCredentialOfferOptions": { - "description": "Interface for CredentialsApi.acceptOffer. Will send a request\n\ncredentialFormats is optional because this is an accept method", + "CredentialOfferOptions": { "properties": { + "credentialRecordId": { + "type": "string" + }, + "credentialFormats": { + "$ref": "#/components/schemas/CredentialFormatPayload_CredentialFormats.acceptOffer_" + }, "autoAcceptCredential": { "$ref": "#/components/schemas/AutoAcceptCredential" }, "comment": { "type": "string" - }, - "credentialRecordId": { - "type": "string" - }, - "credentialFormats": { - "$ref": "#/components/schemas/CredentialFormatPayload_CredentialFormatsFromProtocols_CredentialProtocol-Array_.acceptOffer_" } }, "required": [ @@ -1262,3431 +1481,188 @@ "type": "object", "additionalProperties": false }, - "CredentialState": { - "description": "Issue Credential states as defined in RFC 0036 and RFC 0453", - "enum": [ - "proposal-sent", - "proposal-received", - "offer-sent", - "offer-received", - "declined", - "request-sent", - "request-received", - "credential-issued", - "credential-received", - "done", - "abandoned" - ], - "type": "string" + "CredentialExchangeRecord": { + "$ref": "#/components/schemas/Record_string.unknown_" }, - "AutoAcceptProof": { - "description": "Typing of the state for auto acceptance", - "enum": [ - "always", - "contentApproved", - "never" - ], - "type": "string" + "CredentialFormatPayload_CredentialFormats.acceptRequest_": { + "properties": {}, + "additionalProperties": {}, + "type": "object", + "description": "Get the payload for a specific method from a list of CredentialFormat interfaces and a method" }, - "RequestProofOptions": { + "AcceptCredentialRequestOptions": { "properties": { - "connectionId": { - "type": "string" - }, - "protocolVersion": { - "type": "string" - }, - "proofFormats": {}, - "comment": { - "type": "string" + "credentialRecord": { + "$ref": "#/components/schemas/CredentialExchangeRecord" }, - "autoAcceptProof": { - "$ref": "#/components/schemas/AutoAcceptProof" + "credentialFormats": { + "$ref": "#/components/schemas/CredentialFormatPayload_CredentialFormats.acceptRequest_" }, - "goalCode": { - "type": "string" + "autoAcceptCredential": { + "$ref": "#/components/schemas/AutoAcceptCredential" }, - "parentThreadId": { + "comment": { "type": "string" - }, - "willConfirm": { - "type": "boolean" } }, "required": [ - "connectionId", - "protocolVersion", - "proofFormats", - "comment", - "autoAcceptProof" + "credentialRecord" ], "type": "object", "additionalProperties": false }, - "CreateProofRequestOobOptions": { + "AcceptCredential": { + "properties": { + "credentialRecord": { + "$ref": "#/components/schemas/CredentialExchangeRecord" + } + }, + "required": [ + "credentialRecord" + ], + "type": "object", + "additionalProperties": false + }, + "Pick_TenantConfig.Exclude_keyofTenantConfig.walletConfig__": { "properties": { - "protocolVersion": { - "type": "string" - }, - "proofFormats": {}, - "goalCode": { - "type": "string" - }, - "parentThreadId": { - "type": "string" - }, - "willConfirm": { - "type": "boolean" - }, - "autoAcceptProof": { - "$ref": "#/components/schemas/AutoAcceptProof" - }, - "comment": { - "type": "string" - }, "label": { "type": "string" }, - "imageUrl": { - "type": "string" - }, - "recipientKey": { + "connectionImageUrl": { "type": "string" } }, "required": [ - "protocolVersion", - "proofFormats" + "label" ], "type": "object", - "additionalProperties": false + "description": "From T, pick a set of properties whose keys are in the union K" }, - "QuestionAnswerRole": { - "enum": [ - "questioner", - "responder" - ], - "type": "string" - }, - "QuestionAnswerState": { - "description": "QuestionAnswer states inferred from RFC 0113.", - "enum": [ - "question-sent", - "question-received", - "answer-received", - "answer-sent" - ], - "type": "string" - }, - "ValidResponse": { - "properties": { - "text": { - "type": "string" - } - }, - "required": [ - "text" - ], - "type": "object", - "additionalProperties": false - }, - "Record_response.string_": { - "properties": { - "response": { - "type": "string" - } - }, - "required": [ - "response" - ], - "type": "object", - "description": "Construct a type with a set of properties K of type T" - }, - "ProofFormat": { - "properties": { - "formatKey": { - "type": "string" - }, - "proofFormats": { - "properties": { - "selectCredentialsForRequest": { - "properties": { - "output": {}, - "input": {} - }, - "required": [ - "output", - "input" - ], - "type": "object" - }, - "getCredentialsForRequest": { - "properties": { - "output": {}, - "input": {} - }, - "required": [ - "output", - "input" - ], - "type": "object" - }, - "acceptRequest": {}, - "createRequest": {}, - "acceptProposal": {}, - "createProposal": {} - }, - "required": [ - "selectCredentialsForRequest", - "getCredentialsForRequest", - "acceptRequest", - "createRequest", - "acceptProposal", - "createProposal" - ], - "type": "object" - }, - "formatData": { - "properties": { - "presentation": {}, - "request": {}, - "proposal": {} - }, - "required": [ - "presentation", - "request", - "proposal" - ], - "type": "object" - } - }, - "required": [ - "formatKey", - "proofFormats", - "formatData" - ], - "type": "object", - "additionalProperties": false - }, - "RequestProofProposalOptions": { - "properties": { - "connectionId": { - "type": "string" - }, - "proofFormats": { - "properties": { - "action": { - "type": "string", - "enum": [ - "createProposal" - ], - "nullable": false - }, - "formats": { - "items": { - "$ref": "#/components/schemas/ProofFormat" - }, - "type": "array" - } - }, - "required": [ - "action", - "formats" - ], - "type": "object" - }, - "goalCode": { - "type": "string" - }, - "parentThreadId": { - "type": "string" - }, - "autoAcceptProof": { - "$ref": "#/components/schemas/AutoAcceptProof" - }, - "comment": { - "type": "string" - } - }, - "required": [ - "connectionId", - "proofFormats" - ], - "type": "object", - "additionalProperties": false - }, - "AcceptProofProposal": { - "properties": { - "proofRecordId": { - "type": "string" - }, - "proofFormats": { - "properties": { - "action": { - "type": "string", - "enum": [ - "acceptProposal" - ], - "nullable": false - }, - "formats": { - "items": { - "$ref": "#/components/schemas/ProofFormat" - }, - "type": "array" - } - }, - "required": [ - "action", - "formats" - ], - "type": "object" - }, - "comment": { - "type": "string" - }, - "autoAcceptProof": { - "$ref": "#/components/schemas/AutoAcceptProof" - }, - "goalCode": { - "type": "string" - }, - "willConfirm": { - "type": "boolean" - } - }, - "required": [ - "proofRecordId", - "proofFormats" - ], - "type": "object", - "additionalProperties": false - }, - "W3cCredentialRecord": { - "$ref": "#/components/schemas/Record_string.unknown_" - }, - "ConnectionRecord": { - "$ref": "#/components/schemas/Record_string.unknown_" + "Omit_TenantConfig.walletConfig_": { + "$ref": "#/components/schemas/Pick_TenantConfig.Exclude_keyofTenantConfig.walletConfig__", + "description": "Construct a type with the properties of T except for those in type K." }, - "ProposeCredentialOptions": { + "CreateTenantOptions": { "properties": { - "connectionRecord": { - "$ref": "#/components/schemas/ConnectionRecord" - }, - "credentialFormats": { - "properties": { - "indy": { - "properties": { - "attributes": { - "items": { - "properties": { - "value": { - "type": "string" - }, - "name": { - "type": "string" - } - }, - "required": [ - "value", - "name" - ], - "type": "object" - }, - "type": "array" - }, - "issuerDid": { - "type": "string" - }, - "credentialDefinitionId": { - "type": "string" - }, - "schemaVersion": { - "type": "string" - }, - "schemaName": { - "type": "string" - }, - "schemaId": { - "type": "string" - }, - "schemaIssuerDid": { - "type": "string" - } - }, - "required": [ - "attributes", - "issuerDid", - "credentialDefinitionId", - "schemaVersion", - "schemaName", - "schemaId", - "schemaIssuerDid" - ], - "type": "object" - } - }, - "required": [ - "indy" - ], - "type": "object" - }, - "autoAcceptCredential": { - "$ref": "#/components/schemas/AutoAcceptCredential" - }, - "comment": { - "type": "string" + "config": { + "$ref": "#/components/schemas/Omit_TenantConfig.walletConfig_" }, - "connectionId": { - "type": "string" - } - }, - "required": [ - "connectionRecord", - "credentialFormats", - "connectionId" - ], - "type": "object", - "additionalProperties": false - }, - "CredentialFormatPayload_CredentialFormats.acceptProposal_": { - "properties": {}, - "additionalProperties": {}, - "type": "object", - "description": "Get the payload for a specific method from a list of CredentialFormat interfaces and a method" - }, - "AcceptCredentialProposalOptions": { - "properties": { - "credentialRecordId": { + "seed": { "type": "string" }, - "credentialFormats": { - "$ref": "#/components/schemas/CredentialFormatPayload_CredentialFormats.acceptProposal_" - }, - "autoAcceptCredential": { - "$ref": "#/components/schemas/AutoAcceptCredential" - }, - "comment": { - "type": "string" - } - }, - "required": [ - "credentialRecordId" - ], - "type": "object", - "additionalProperties": false - }, - "CredentialFormatPayload_CredentialFormats.acceptOffer_": { - "properties": {}, - "additionalProperties": {}, - "type": "object", - "description": "Get the payload for a specific method from a list of CredentialFormat interfaces and a method" - }, - "CredentialOfferOptions": { - "properties": { - "credentialRecordId": { - "type": "string" - }, - "credentialFormats": { - "$ref": "#/components/schemas/CredentialFormatPayload_CredentialFormats.acceptOffer_" - }, - "autoAcceptCredential": { - "$ref": "#/components/schemas/AutoAcceptCredential" - }, - "comment": { - "type": "string" - } - }, - "required": [ - "credentialRecordId" - ], - "type": "object", - "additionalProperties": false - }, - "CredentialExchangeRecord": { - "$ref": "#/components/schemas/Record_string.unknown_" - }, - "CredentialFormatPayload_CredentialFormats.acceptRequest_": { - "properties": {}, - "additionalProperties": {}, - "type": "object", - "description": "Get the payload for a specific method from a list of CredentialFormat interfaces and a method" - }, - "AcceptCredentialRequestOptions": { - "properties": { - "credentialRecord": { - "$ref": "#/components/schemas/CredentialExchangeRecord" - }, - "credentialFormats": { - "$ref": "#/components/schemas/CredentialFormatPayload_CredentialFormats.acceptRequest_" - }, - "autoAcceptCredential": { - "$ref": "#/components/schemas/AutoAcceptCredential" - }, - "comment": { - "type": "string" - } - }, - "required": [ - "credentialRecord" - ], - "type": "object", - "additionalProperties": false - }, - "AcceptCredential": { - "properties": { - "credentialRecord": { - "$ref": "#/components/schemas/CredentialExchangeRecord" - } - }, - "required": [ - "credentialRecord" - ], - "type": "object", - "additionalProperties": false - } - }, - "securitySchemes": { - "apiKey": { - "type": "apiKey", - "name": "Authorization", - "in": "header" - }, - "jwt": { - "type": "http", - "scheme": "bearer", - "bearerFormat": "JWT" - } - } - }, - "info": { - "title": "@aries-framework/rest", - "version": "0.9.4", - "description": "Rest endpoint wrapper for using your agent over HTTP", - "license": { - "name": "Apache-2.0" - }, - "contact": {} - }, - "paths": { - "/agent/info": { - "get": { - "operationId": "GetAgentInfo", - "responses": { - "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/AgentInfo" - } - } - } - } - }, - "description": "Retrieve basic agent information", - "tags": [ - "Agent" - ], - "security": [ - { - "jwt": [] - } - ], - "parameters": [] - } - }, - "/agent/token": { - "post": { - "operationId": "GetAgentToken", - "responses": { - "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": { - "anyOf": [ - { - "$ref": "#/components/schemas/AgentToken" - }, - { - "type": "string" - } - ] - } - } - } - } - }, - "description": "Retrieve agent token", - "tags": [ - "Agent" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [] - } - }, - "/agent/wallet": { - "delete": { - "operationId": "DeleteWallet", - "responses": { - "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": {} - } - } - } - }, - "description": "Delete wallet", - "tags": [ - "Agent" - ], - "security": [ - { - "jwt": [] - } - ], - "parameters": [] - } - }, - "/basic-messages/{connectionId}": { - "get": { - "operationId": "GetBasicMessages", - "responses": { - "200": { - "description": "BasicMessageRecord[]", - "content": { - "application/json": { - "schema": { - "items": { - "$ref": "#/components/schemas/BasicMessageRecord" - }, - "type": "array" - }, - "examples": { - "Example 1": { - "value": [ - { - "_tags": { - "role": "sender", - "connectionId": "2aecf74c-3073-4f98-9acb-92415d096834" - }, - "metadata": {}, - "id": "74bcf865-1fdc-45b4-b517-9def02dfd25f", - "createdAt": "2022-08-18T08:38:40.216Z", - "content": "string", - "sentTime": "2022-08-18T08:38:40.216Z", - "connectionId": "2aecf74c-3073-4f98-9acb-92415d096834" - } - ] - } - } - } - } - } - }, - "description": "Retrieve basic messages by connection id", - "tags": [ - "Basic Messages" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [ - { - "description": "Connection identifier", - "in": "path", - "name": "connectionId", - "required": true, - "schema": { - "$ref": "#/components/schemas/RecordId" - } - } - ] - }, - "post": { - "operationId": "SendMessage", - "responses": { - "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": {} - } - } - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "reason": { - "type": "string" - } - }, - "required": [ - "reason" - ], - "type": "object" - } - } - } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "description": "Send a basic message to a connection", - "tags": [ - "Basic Messages" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [ - { - "description": "Connection identifier", - "in": "path", - "name": "connectionId", - "required": true, - "schema": { - "$ref": "#/components/schemas/RecordId" - } - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Record_content.string_" - } - } - } - } - } - }, - "/connections": { - "get": { - "operationId": "GetAllConnections", - "responses": { - "200": { - "description": "ConnectionRecord[]", - "content": { - "application/json": { - "schema": {}, - "examples": { - "Example 1": { - "value": [ - { - "_tags": { - "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", - "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", - "invitationKey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz", - "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d", - "verkey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz" - }, - "metadata": {}, - "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", - "createdAt": "2022-01-01T00:00:00.000Z", - "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", - "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", - "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d" - } - ] - } - } - } - } - } - }, - "description": "Retrieve all connections records", - "tags": [ - "Connections" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [ - { - "in": "query", - "name": "outOfBandId", - "required": false, - "schema": { - "type": "string" - } - }, - { - "description": "Alias", - "in": "query", - "name": "alias", - "required": false, - "schema": { - "type": "string" - } - }, - { - "description": "Connection state", - "in": "query", - "name": "state", - "required": false, - "schema": { - "$ref": "#/components/schemas/DidExchangeState" - } - }, - { - "description": "My DID", - "in": "query", - "name": "myDid", - "required": false, - "schema": { - "type": "string" - } - }, - { - "description": "Their DID", - "in": "query", - "name": "theirDid", - "required": false, - "schema": { - "type": "string" - } - }, - { - "description": "Their label", - "in": "query", - "name": "theirLabel", - "required": false, - "schema": { - "type": "string" - } - } - ] - } - }, - "/connections/{connectionId}": { - "get": { - "operationId": "GetConnectionById", - "responses": { - "200": { - "description": "ConnectionRecord", - "content": { - "application/json": { - "schema": {}, - "examples": { - "Example 1": { - "value": { - "_tags": { - "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", - "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", - "invitationKey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz", - "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d", - "verkey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz" - }, - "metadata": {}, - "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", - "createdAt": "2022-01-01T00:00:00.000Z", - "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", - "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", - "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d" - } - } - } - } - } - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "reason": { - "type": "string" - } - }, - "required": [ - "reason" - ], - "type": "object" - } - } - } - } - }, - "description": "Retrieve connection record by connection id", - "tags": [ - "Connections" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [ - { - "description": "Connection identifier", - "in": "path", - "name": "connectionId", - "required": true, - "schema": { - "$ref": "#/components/schemas/RecordId" - } - } - ] - }, - "delete": { - "operationId": "DeleteConnection", - "responses": { - "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": {} - } - } - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "reason": { - "type": "string" - } - }, - "required": [ - "reason" - ], - "type": "object" - } - } - } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "description": "Deletes a connection record from the connection repository.", - "tags": [ - "Connections" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [ - { - "description": "Connection identifier", - "in": "path", - "name": "connectionId", - "required": true, - "schema": { - "$ref": "#/components/schemas/RecordId" - } - } - ] - } - }, - "/connections/{connectionId}/accept-request": { - "post": { - "operationId": "AcceptRequest", - "responses": { - "200": { - "description": "ConnectionRecord", - "content": { - "application/json": { - "schema": {}, - "examples": { - "Example 1": { - "value": { - "_tags": { - "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", - "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", - "invitationKey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz", - "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d", - "verkey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz" - }, - "metadata": {}, - "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", - "createdAt": "2022-01-01T00:00:00.000Z", - "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", - "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", - "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d" - } - } - } - } - } - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "reason": { - "type": "string" - } - }, - "required": [ - "reason" - ], - "type": "object" - } - } - } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "description": "Accept a connection request as inviter by sending a connection response message\nfor the connection with the specified connection id.\n\nThis is not needed when auto accepting of connection is enabled.", - "tags": [ - "Connections" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [ - { - "description": "Connection identifier", - "in": "path", - "name": "connectionId", - "required": true, - "schema": { - "$ref": "#/components/schemas/RecordId" - } - } - ] - } - }, - "/connections/{connectionId}/accept-response": { - "post": { - "operationId": "AcceptResponse", - "responses": { - "200": { - "description": "ConnectionRecord", - "content": { - "application/json": { - "schema": {}, - "examples": { - "Example 1": { - "value": { - "_tags": { - "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", - "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", - "invitationKey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz", - "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d", - "verkey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz" - }, - "metadata": {}, - "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", - "createdAt": "2022-01-01T00:00:00.000Z", - "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", - "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", - "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d" - } - } - } - } - } - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "reason": { - "type": "string" - } - }, - "required": [ - "reason" - ], - "type": "object" - } - } - } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "description": "Accept a connection response as invitee by sending a trust ping message\nfor the connection with the specified connection id.\n\nThis is not needed when auto accepting of connection is enabled.", - "tags": [ - "Connections" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [ - { - "description": "Connection identifier", - "in": "path", - "name": "connectionId", - "required": true, - "schema": { - "$ref": "#/components/schemas/RecordId" - } - } - ] - } - }, - "/url/{invitationId}": { - "get": { - "operationId": "GetInvitation", - "responses": { - "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": {} - } - } - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "reason": { - "type": "string" - } - }, - "required": [ - "reason" - ], - "type": "object" - } - } - } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "tags": [ - "Connections" - ], - "security": [], - "parameters": [ - { - "in": "path", - "name": "invitationId", - "required": true, - "schema": { - "type": "string" - } - } - ] - } - }, - "/oob": { - "get": { - "operationId": "GetAllOutOfBandRecords", - "responses": { - "200": { - "description": "OutOfBandRecord[]", - "content": { - "application/json": { - "schema": { - "items": { - "$ref": "#/components/schemas/Record_string.unknown_" - }, - "type": "array" - }, - "examples": { - "Example 1": { - "value": [ - { - "_tags": { - "invitationId": "1cbd22e4-1906-41e9-8807-83d84437f978", - "state": "await-response", - "role": "sender", - "recipientKeyFingerprints": [ - "z6MktUCPZjfRJXD4GMcYuXiqX2qZ8vBw6UAYpDFiHEUfwuLj" - ] - }, - "outOfBandInvitation": { - "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.1/invitation", - "@id": "d6472943-e5d0-4d95-8b48-790ed5a41931", - "label": "Aries Test Agent", - "accept": [ - "didcomm/aip1", - "didcomm/aip2;env=rfc19" - ], - "handshake_protocols": [ - "https://didcomm.org/didexchange/1.0", - "https://didcomm.org/connections/1.0" - ], - "services": [ - { - "id": "#inline-0", - "serviceEndpoint": "https://6b77-89-20-162-146.ngrok.io", - "type": "did-communication", - "recipientKeys": [ - "did:key:z6MkmTBHTWrvLPN8pBmUj7Ye5ww9GiacXCYMNVvpScSpf1DM" - ], - "routingKeys": [] - } - ] - }, - "metadata": {}, - "id": "42a95528-0e30-4f86-a462-0efb02178b53", - "createdAt": "2022-01-01T00:00:00.000Z", - "reusable": false - } - ] - } - } - } - } - } - }, - "description": "Retrieve all out of band records", - "tags": [ - "Out Of Band" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [ - { - "description": "invitation identifier", - "in": "query", - "name": "invitationId", - "required": false, - "schema": { - "$ref": "#/components/schemas/RecordId" - } - } - ] - } - }, - "/oob/{outOfBandId}": { - "get": { - "operationId": "GetOutOfBandRecordById", - "responses": { - "200": { - "description": "OutOfBandRecord", - "content": { - "application/json": { - "schema": {}, - "examples": { - "Example 1": { - "value": { - "_tags": { - "invitationId": "1cbd22e4-1906-41e9-8807-83d84437f978", - "state": "await-response", - "role": "sender", - "recipientKeyFingerprints": [ - "z6MktUCPZjfRJXD4GMcYuXiqX2qZ8vBw6UAYpDFiHEUfwuLj" - ] - }, - "outOfBandInvitation": { - "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.1/invitation", - "@id": "d6472943-e5d0-4d95-8b48-790ed5a41931", - "label": "Aries Test Agent", - "accept": [ - "didcomm/aip1", - "didcomm/aip2;env=rfc19" - ], - "handshake_protocols": [ - "https://didcomm.org/didexchange/1.0", - "https://didcomm.org/connections/1.0" - ], - "services": [ - { - "id": "#inline-0", - "serviceEndpoint": "https://6b77-89-20-162-146.ngrok.io", - "type": "did-communication", - "recipientKeys": [ - "did:key:z6MkmTBHTWrvLPN8pBmUj7Ye5ww9GiacXCYMNVvpScSpf1DM" - ], - "routingKeys": [] - } - ] - }, - "metadata": {}, - "id": "42a95528-0e30-4f86-a462-0efb02178b53", - "createdAt": "2022-01-01T00:00:00.000Z", - "reusable": false - } - } - } - } - } - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "reason": { - "type": "string" - } - }, - "required": [ - "reason" - ], - "type": "object" - } - } - } - } - }, - "description": "Retrieve an out of band record by id", - "tags": [ - "Out Of Band" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [ - { - "in": "path", - "name": "outOfBandId", - "required": true, - "schema": { - "$ref": "#/components/schemas/RecordId" - } - } - ] - }, - "delete": { - "operationId": "DeleteOutOfBandRecord", - "responses": { - "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": {} - } - } - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "reason": { - "type": "string" - } - }, - "required": [ - "reason" - ], - "type": "object" - } - } - } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "description": "Deletes an out of band record from the repository.", - "tags": [ - "Out Of Band" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [ - { - "description": "Record identifier", - "in": "path", - "name": "outOfBandId", - "required": true, - "schema": { - "$ref": "#/components/schemas/RecordId" - } - } - ] - } - }, - "/oob/create-invitation": { - "post": { - "operationId": "CreateInvitation", - "responses": { - "200": { - "description": "Out of band record", - "content": { - "application/json": { - "schema": {}, - "examples": { - "Example 1": { - "value": { - "invitationUrl": "string", - "invitation": { - "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.1/invitation", - "@id": "d6472943-e5d0-4d95-8b48-790ed5a41931", - "label": "Aries Test Agent", - "accept": [ - "didcomm/aip1", - "didcomm/aip2;env=rfc19" - ], - "handshake_protocols": [ - "https://didcomm.org/didexchange/1.0", - "https://didcomm.org/connections/1.0" - ], - "services": [ - { - "id": "#inline-0", - "serviceEndpoint": "https://6b77-89-20-162-146.ngrok.io", - "type": "did-communication", - "recipientKeys": [ - "did:key:z6MkmTBHTWrvLPN8pBmUj7Ye5ww9GiacXCYMNVvpScSpf1DM" - ], - "routingKeys": [] - } - ] - }, - "outOfBandRecord": { - "_tags": { - "invitationId": "1cbd22e4-1906-41e9-8807-83d84437f978", - "state": "await-response", - "role": "sender", - "recipientKeyFingerprints": [ - "z6MktUCPZjfRJXD4GMcYuXiqX2qZ8vBw6UAYpDFiHEUfwuLj" - ] - }, - "outOfBandInvitation": { - "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.1/invitation", - "@id": "d6472943-e5d0-4d95-8b48-790ed5a41931", - "label": "Aries Test Agent", - "accept": [ - "didcomm/aip1", - "didcomm/aip2;env=rfc19" - ], - "handshake_protocols": [ - "https://didcomm.org/didexchange/1.0", - "https://didcomm.org/connections/1.0" - ], - "services": [ - { - "id": "#inline-0", - "serviceEndpoint": "https://6b77-89-20-162-146.ngrok.io", - "type": "did-communication", - "recipientKeys": [ - "did:key:z6MkmTBHTWrvLPN8pBmUj7Ye5ww9GiacXCYMNVvpScSpf1DM" - ], - "routingKeys": [] - } - ] - }, - "metadata": {}, - "id": "42a95528-0e30-4f86-a462-0efb02178b53", - "createdAt": "2022-01-01T00:00:00.000Z", - "reusable": false - } - } - } - } - } - } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "description": "Creates an outbound out-of-band record containing out-of-band invitation message defined in\nAries RFC 0434: Out-of-Band Protocol 1.1.", - "tags": [ - "Out Of Band" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [], - "requestBody": { - "description": "configuration of how out-of-band invitation should be created", - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CreateInvitationOptions", - "description": "configuration of how out-of-band invitation should be created" - } - } - } - } - } - }, - "/oob/create-legacy-invitation": { - "post": { - "operationId": "CreateLegacyInvitation", - "responses": { - "200": { - "description": "out-of-band record and invitation", - "content": { - "application/json": { - "schema": {}, - "examples": { - "Example 1": { - "value": { - "invitation": { - "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.1/invitation", - "@id": "d6472943-e5d0-4d95-8b48-790ed5a41931", - "label": "Aries Test Agent", - "accept": [ - "didcomm/aip1", - "didcomm/aip2;env=rfc19" - ], - "handshake_protocols": [ - "https://didcomm.org/didexchange/1.0", - "https://didcomm.org/connections/1.0" - ], - "services": [ - { - "id": "#inline-0", - "serviceEndpoint": "https://6b77-89-20-162-146.ngrok.io", - "type": "did-communication", - "recipientKeys": [ - "did:key:z6MkmTBHTWrvLPN8pBmUj7Ye5ww9GiacXCYMNVvpScSpf1DM" - ], - "routingKeys": [] - } - ] - }, - "outOfBandRecord": { - "_tags": { - "invitationId": "1cbd22e4-1906-41e9-8807-83d84437f978", - "state": "await-response", - "role": "sender", - "recipientKeyFingerprints": [ - "z6MktUCPZjfRJXD4GMcYuXiqX2qZ8vBw6UAYpDFiHEUfwuLj" - ] - }, - "outOfBandInvitation": { - "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.1/invitation", - "@id": "d6472943-e5d0-4d95-8b48-790ed5a41931", - "label": "Aries Test Agent", - "accept": [ - "didcomm/aip1", - "didcomm/aip2;env=rfc19" - ], - "handshake_protocols": [ - "https://didcomm.org/didexchange/1.0", - "https://didcomm.org/connections/1.0" - ], - "services": [ - { - "id": "#inline-0", - "serviceEndpoint": "https://6b77-89-20-162-146.ngrok.io", - "type": "did-communication", - "recipientKeys": [ - "did:key:z6MkmTBHTWrvLPN8pBmUj7Ye5ww9GiacXCYMNVvpScSpf1DM" - ], - "routingKeys": [] - } - ] - }, - "metadata": {}, - "id": "42a95528-0e30-4f86-a462-0efb02178b53", - "createdAt": "2022-01-01T00:00:00.000Z", - "reusable": false - } - } - } - } - } - } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "description": "Creates an outbound out-of-band record in the same way how `createInvitation` method does it,\nbut it also converts out-of-band invitation message to an \"legacy\" invitation message defined\nin RFC 0160: Connection Protocol and returns it together with out-of-band record.", - "tags": [ - "Out Of Band" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [], - "requestBody": { - "description": "configuration of how a invitation should be created", - "required": false, - "content": { - "application/json": { - "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/Omit_CreateLegacyInvitationConfig.routing_" - }, - { - "$ref": "#/components/schemas/RecipientKeyOption" - } - ], - "description": "configuration of how a invitation should be created" - } - } - } - } - } - }, - "/oob/create-legacy-connectionless-invitation": { - "post": { - "operationId": "CreateLegacyConnectionlessInvitation", - "responses": { - "200": { - "description": "a message and a invitationUrl", - "content": { - "application/json": { - "schema": {}, - "examples": { - "Example 1": { - "value": { - "message": { - "@id": "eac4ff4e-b4fb-4c1d-aef3-b29c89d1cc00", - "@type": "https://didcomm.org/connections/1.0/invitation" - }, - "invitationUrl": "http://example.com/invitation_url" - } - } - } - } - } - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "reason": { - "type": "string" - } - }, - "required": [ - "reason" - ], - "type": "object" - } - } - } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "description": "Creates a new connectionless legacy invitation.", - "tags": [ - "Out Of Band" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [], - "requestBody": { - "description": "configuration of how a connection invitation should be created", - "required": true, - "content": { - "application/json": { - "schema": { - "properties": { - "domain": { - "type": "string" - }, - "message": { - "$ref": "#/components/schemas/AgentMessageType" - }, - "recordId": { - "type": "string" - } - }, - "required": [ - "domain", - "message", - "recordId" - ], - "type": "object", - "description": "configuration of how a connection invitation should be created" - } - } - } - } - } - }, - "/oob/receive-invitation": { - "post": { - "operationId": "ReceiveInvitation", - "responses": { - "200": { - "description": "out-of-band record and connection record if one has been created.", - "content": { - "application/json": { - "schema": {}, - "examples": { - "Example 1": { - "value": { - "outOfBandRecord": { - "_tags": { - "invitationId": "1cbd22e4-1906-41e9-8807-83d84437f978", - "state": "await-response", - "role": "sender", - "recipientKeyFingerprints": [ - "z6MktUCPZjfRJXD4GMcYuXiqX2qZ8vBw6UAYpDFiHEUfwuLj" - ] - }, - "outOfBandInvitation": { - "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.1/invitation", - "@id": "d6472943-e5d0-4d95-8b48-790ed5a41931", - "label": "Aries Test Agent", - "accept": [ - "didcomm/aip1", - "didcomm/aip2;env=rfc19" - ], - "handshake_protocols": [ - "https://didcomm.org/didexchange/1.0", - "https://didcomm.org/connections/1.0" - ], - "services": [ - { - "id": "#inline-0", - "serviceEndpoint": "https://6b77-89-20-162-146.ngrok.io", - "type": "did-communication", - "recipientKeys": [ - "did:key:z6MkmTBHTWrvLPN8pBmUj7Ye5ww9GiacXCYMNVvpScSpf1DM" - ], - "routingKeys": [] - } - ] - }, - "metadata": {}, - "id": "42a95528-0e30-4f86-a462-0efb02178b53", - "createdAt": "2022-01-01T00:00:00.000Z", - "reusable": false - }, - "connectionRecord": { - "_tags": { - "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", - "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", - "invitationKey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz", - "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d", - "verkey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz" - }, - "metadata": {}, - "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", - "createdAt": "2022-01-01T00:00:00.000Z", - "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", - "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", - "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d" - } - } - } - } - } - } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "description": "Creates inbound out-of-band record and assigns out-of-band invitation message to it if the\nmessage is valid.", - "tags": [ - "Out Of Band" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ReceiveInvitationProps" - } - } - } - } - } - }, - "/oob/receive-invitation-url": { - "post": { - "operationId": "ReceiveInvitationFromUrl", - "responses": { - "200": { - "description": "out-of-band record and connection record if one has been created.", - "content": { - "application/json": { - "schema": {}, - "examples": { - "Example 1": { - "value": { - "outOfBandRecord": { - "_tags": { - "invitationId": "1cbd22e4-1906-41e9-8807-83d84437f978", - "state": "await-response", - "role": "sender", - "recipientKeyFingerprints": [ - "z6MktUCPZjfRJXD4GMcYuXiqX2qZ8vBw6UAYpDFiHEUfwuLj" - ] - }, - "outOfBandInvitation": { - "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.1/invitation", - "@id": "d6472943-e5d0-4d95-8b48-790ed5a41931", - "label": "Aries Test Agent", - "accept": [ - "didcomm/aip1", - "didcomm/aip2;env=rfc19" - ], - "handshake_protocols": [ - "https://didcomm.org/didexchange/1.0", - "https://didcomm.org/connections/1.0" - ], - "services": [ - { - "id": "#inline-0", - "serviceEndpoint": "https://6b77-89-20-162-146.ngrok.io", - "type": "did-communication", - "recipientKeys": [ - "did:key:z6MkmTBHTWrvLPN8pBmUj7Ye5ww9GiacXCYMNVvpScSpf1DM" - ], - "routingKeys": [] - } - ] - }, - "metadata": {}, - "id": "42a95528-0e30-4f86-a462-0efb02178b53", - "createdAt": "2022-01-01T00:00:00.000Z", - "reusable": false - }, - "connectionRecord": { - "_tags": { - "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", - "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", - "invitationKey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz", - "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d", - "verkey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz" - }, - "metadata": {}, - "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", - "createdAt": "2022-01-01T00:00:00.000Z", - "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", - "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", - "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d" - } - } - } - } - } - } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "description": "Creates inbound out-of-band record and assigns out-of-band invitation message to it if the\nmessage is valid.", - "tags": [ - "Out Of Band" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ReceiveInvitationByUrlProps" - } - } - } - } - } - }, - "/oob/{outOfBandId}/accept-invitation": { - "post": { - "operationId": "AcceptInvitation", - "responses": { - "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": {}, - "examples": { - "Example 1": { - "value": { - "outOfBandRecord": { - "_tags": { - "invitationId": "1cbd22e4-1906-41e9-8807-83d84437f978", - "state": "await-response", - "role": "sender", - "recipientKeyFingerprints": [ - "z6MktUCPZjfRJXD4GMcYuXiqX2qZ8vBw6UAYpDFiHEUfwuLj" - ] - }, - "outOfBandInvitation": { - "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.1/invitation", - "@id": "d6472943-e5d0-4d95-8b48-790ed5a41931", - "label": "Aries Test Agent", - "accept": [ - "didcomm/aip1", - "didcomm/aip2;env=rfc19" - ], - "handshake_protocols": [ - "https://didcomm.org/didexchange/1.0", - "https://didcomm.org/connections/1.0" - ], - "services": [ - { - "id": "#inline-0", - "serviceEndpoint": "https://6b77-89-20-162-146.ngrok.io", - "type": "did-communication", - "recipientKeys": [ - "did:key:z6MkmTBHTWrvLPN8pBmUj7Ye5ww9GiacXCYMNVvpScSpf1DM" - ], - "routingKeys": [] - } - ] - }, - "metadata": {}, - "id": "42a95528-0e30-4f86-a462-0efb02178b53", - "createdAt": "2022-01-01T00:00:00.000Z", - "reusable": false - }, - "connectionRecord": { - "_tags": { - "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", - "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", - "invitationKey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz", - "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d", - "verkey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz" - }, - "metadata": {}, - "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", - "createdAt": "2022-01-01T00:00:00.000Z", - "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", - "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", - "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d" - } - } - } - } - } - } - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "reason": { - "type": "string" - } - }, - "required": [ - "reason" - ], - "type": "object" - } - } - } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "description": "Accept a connection invitation as invitee (by sending a connection request message) for the connection with the specified connection id.\nThis is not needed when auto accepting of connections is enabled.", - "tags": [ - "Out Of Band" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [ - { - "in": "path", - "name": "outOfBandId", - "required": true, - "schema": { - "$ref": "#/components/schemas/RecordId" - } - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/AcceptInvitationConfig" - } - } - } - } - } - }, - "/credential-definitions/{credentialDefinitionId}": { - "get": { - "operationId": "GetCredentialDefinitionById", - "responses": { - "200": { - "description": "CredDef", - "content": { - "application/json": { - "schema": {}, - "examples": { - "Example 1": { - "value": { - "ver": "1.0", - "id": "WgWxqztrNooG92RXvxSTWv:3:CL:20:tag", - "schemaId": "351936", - "type": "CL", - "tag": "definition", - "value": { - "primary": { - "n": "string", - "s": "string", - "r": { - "master_secret": "string", - "string": "string" - }, - "rctxt": "string", - "z": "string" - }, - "revocation": { - "g": "1 string", - "g_dash": "string", - "h": "string", - "h0": "string", - "h1": "string", - "h2": "string", - "htilde": "string", - "h_cap": "string", - "u": "string", - "pk": "string", - "y": "string" - } - } - } - } - } - } - } - }, - "400": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "reason": { - "type": "string" - } - }, - "required": [ - "reason" - ], - "type": "object" - } - } - } - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "reason": { - "type": "string" - } - }, - "required": [ - "reason" - ], - "type": "object" - } - } - } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "description": "Retrieve credential definition by credential definition id", - "tags": [ - "Credential Definitions" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [ - { - "in": "path", - "name": "credentialDefinitionId", - "required": true, - "schema": { - "$ref": "#/components/schemas/CredentialDefinitionId" - } - } - ] - } - }, - "/credential-definitions": { - "post": { - "operationId": "CreateCredentialDefinition", - "responses": { - "200": { - "description": "CredDef", - "content": { - "application/json": { - "schema": {}, - "examples": { - "Example 1": { - "value": { - "ver": "1.0", - "id": "WgWxqztrNooG92RXvxSTWv:3:CL:20:tag", - "schemaId": "351936", - "type": "CL", - "tag": "definition", - "value": { - "primary": { - "n": "string", - "s": "string", - "r": { - "master_secret": "string", - "string": "string" - }, - "rctxt": "string", - "z": "string" - }, - "revocation": { - "g": "1 string", - "g_dash": "string", - "h": "string", - "h0": "string", - "h1": "string", - "h2": "string", - "htilde": "string", - "h_cap": "string", - "u": "string", - "pk": "string", - "y": "string" - } - } - } - } - } - } - } - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "reason": { - "type": "string" - } - }, - "required": [ - "reason" - ], - "type": "object" - } - } - } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "description": "Creates a new credential definition.", - "tags": [ - "Credential Definitions" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "properties": { - "endorserDid": { - "type": "string" - }, - "endorse": { - "type": "boolean" - }, - "tag": { - "type": "string" - }, - "schemaId": { - "$ref": "#/components/schemas/SchemaId" - }, - "issuerId": { - "type": "string" - } - }, - "required": [ - "tag", - "schemaId", - "issuerId" - ], - "type": "object" - } - } - } - } - } - }, - "/schemas/{schemaId}": { - "get": { - "operationId": "GetSchemaById", - "responses": { - "200": { - "description": "Schema", - "content": { - "application/json": { - "schema": {}, - "examples": { - "Example 1": { - "value": { - "ver": "1.0", - "id": "WgWxqztrNooG92RXvxSTWv:2:schema_name:1.0", - "name": "schema", - "version": "1.0", - "attrNames": [ - "string" - ], - "seqNo": 351936 - } - } - } - } - } - }, - "400": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "reason": { - "type": "string" - } - }, - "required": [ - "reason" - ], - "type": "object" - } - } - } - }, - "403": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "reason": { - "type": "string" - } - }, - "required": [ - "reason" - ], - "type": "object" - } - } - } - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "reason": { - "type": "string" - } - }, - "required": [ - "reason" - ], - "type": "object" - } - } - } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "description": "Retrieve schema by schema id", - "tags": [ - "Schemas" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [ - { - "in": "path", - "name": "schemaId", - "required": true, - "schema": { - "$ref": "#/components/schemas/SchemaId" - } - } - ] - } - }, - "/schemas": { - "post": { - "operationId": "CreateSchema", - "responses": { - "200": { - "description": "schema", - "content": { - "application/json": { - "schema": {}, - "examples": { - "Example 1": { - "value": { - "ver": "1.0", - "id": "WgWxqztrNooG92RXvxSTWv:2:schema_name:1.0", - "name": "schema", - "version": "1.0", - "attrNames": [ - "string" - ], - "seqNo": 351936 - } - } - } - } - } - }, - "400": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "reason": { - "type": "string" - } - }, - "required": [ - "reason" - ], - "type": "object" - } - } - } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "description": "Creates a new schema and registers schema on ledger", - "tags": [ - "Schemas" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "properties": { - "endorserDid": { - "type": "string" - }, - "endorse": { - "type": "boolean" - }, - "attributes": { - "items": { - "type": "string" - }, - "type": "array" - }, - "version": { - "$ref": "#/components/schemas/Version" - }, - "name": { - "type": "string" - }, - "issuerId": { - "type": "string" - } - }, - "required": [ - "attributes", - "version", - "name", - "issuerId" - ], - "type": "object" - } - } - } - } - } - }, - "/dids/{did}": { - "get": { - "operationId": "GetDidRecordByDid", - "responses": { - "200": { - "description": "DidResolutionResult", - "content": { - "application/json": { - "schema": { - "anyOf": [ - { - "properties": { - "importDid": {} - }, - "required": [ - "importDid" - ], - "type": "object" - }, - { - "properties": { - "importDid": {}, - "didDocumentMetadata": { - "$ref": "#/components/schemas/DIDDocumentMetadata" - }, - "didResolutionMetadata": { - "$ref": "#/components/schemas/DidResolutionMetadata" - }, - "didDocument": { - "$ref": "#/components/schemas/Record_string.any_" - } - }, - "required": [ - "didDocumentMetadata", - "didResolutionMetadata", - "didDocument" - ], - "type": "object" - } - ] - }, - "examples": { - "Example 1": { - "value": { - "didDocument": { - "@context": [ - "https://w3id.org/did/v1", - "https://w3id.org/security/suites/ed25519-2018/v1", - "https://w3id.org/security/suites/x25519-2019/v1" - ], - "id": "did:key:z6Mkk7yqnGF3YwTrLpqrW6PGsKci7dNqh1CjnvMbzrMerSeL", - "verificationMethod": [ - { - "id": "did:key:z6Mkk7yqnGF3YwTrLpqrW6PGsKci7dNqh1CjnvMbzrMerSeL#z6Mkk7yqnGF3YwTrLpqrW6PGsKci7dNqh1CjnvMbzrMerSeL", - "type": "Ed25519VerificationKey2018", - "controller": "did:key:z6Mkk7yqnGF3YwTrLpqrW6PGsKci7dNqh1CjnvMbzrMerSeL", - "publicKeyBase58": "6fioC1zcDPyPEL19pXRS2E4iJ46zH7xP6uSgAaPdwDrx" - } - ], - "authentication": [ - "did:key:z6Mkk7yqnGF3YwTrLpqrW6PGsKci7dNqh1CjnvMbzrMerSeL#z6Mkk7yqnGF3YwTrLpqrW6PGsKci7dNqh1CjnvMbzrMerSeL" - ], - "assertionMethod": [ - "did:key:z6Mkk7yqnGF3YwTrLpqrW6PGsKci7dNqh1CjnvMbzrMerSeL#z6Mkk7yqnGF3YwTrLpqrW6PGsKci7dNqh1CjnvMbzrMerSeL" - ], - "capabilityInvocation": [ - "did:key:z6Mkk7yqnGF3YwTrLpqrW6PGsKci7dNqh1CjnvMbzrMerSeL#z6Mkk7yqnGF3YwTrLpqrW6PGsKci7dNqh1CjnvMbzrMerSeL" - ], - "capabilityDelegation": [ - "did:key:z6Mkk7yqnGF3YwTrLpqrW6PGsKci7dNqh1CjnvMbzrMerSeL#z6Mkk7yqnGF3YwTrLpqrW6PGsKci7dNqh1CjnvMbzrMerSeL" - ], - "keyAgreement": [ - { - "id": "did:key:z6Mkk7yqnGF3YwTrLpqrW6PGsKci7dNqh1CjnvMbzrMerSeL#z6LSrdqo4M24WRDJj1h2hXxgtDTyzjjKCiyapYVgrhwZAySn", - "type": "X25519KeyAgreementKey2019", - "controller": "did:key:z6Mkk7yqnGF3YwTrLpqrW6PGsKci7dNqh1CjnvMbzrMerSeL", - "publicKeyBase58": "FxfdY3DCQxVZddKGAtSjZdFW9bCCW7oRwZn1NFJ2Tbg2" - } - ] - }, - "didDocumentMetadata": {}, - "didResolutionMetadata": { - "contentType": "application/did+ld+json" - } - } - } - } - } - } - } - }, - "description": "Resolves did and returns did resolution result", - "tags": [ - "Dids" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [ - { - "description": "Decentralized Identifier", - "in": "path", - "name": "did", - "required": true, - "schema": { - "$ref": "#/components/schemas/Did" - } - } - ] - } - }, - "/dids/write": { - "post": { - "operationId": "WriteDid", - "responses": { - "200": { - "description": "DidResolutionResult", - "content": { - "application/json": { - "schema": {} - } - } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "description": "Did nym registration", - "tags": [ - "Dids" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/DidCreate" - } - } - } - } - } - }, - "/dids": { - "get": { - "operationId": "GetDids", - "responses": { - "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": {} - } - } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "tags": [ - "Dids" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [] - } - }, - "/multi-tenancy/create-tenant": { - "post": { - "operationId": "CreateTenant", - "responses": { - "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": {} - } - } - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "reason": { - "type": "string" - } - }, - "required": [ - "reason" - ], - "type": "object" - } - } - } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "tags": [ - "MultiTenancy" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CreateTenantOptions" - } - } - } - } - } - }, - "/multi-tenancy/create-did/{tenantId}": { - "post": { - "operationId": "CreateDid", - "responses": { - "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": {} - } - } - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "reason": { - "type": "string" - } - }, - "required": [ - "reason" - ], - "type": "object" - } - } - } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "tags": [ - "MultiTenancy" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [ - { - "in": "path", - "name": "tenantId", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/DidCreate" - } - } - } - } - } - }, - "/multi-tenancy/dids/{tenantId}": { - "get": { - "operationId": "GetDids", - "responses": { - "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": {} - } - } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "tags": [ - "MultiTenancy" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [ - { - "in": "path", - "name": "tenantId", - "required": true, - "schema": { - "type": "string" - } - } - ] - } - }, - "/multi-tenancy/transactions/set-endorser-role/{tenantId}": { - "post": { - "operationId": "DidNymTransaction", - "responses": { - "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": {} - } - } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "tags": [ - "MultiTenancy" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [ - { - "in": "path", - "name": "tenantId", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/DidNymTransaction" - } - } - } - } - } - }, - "/multi-tenancy/transactions/endorse/{tenantId}": { - "post": { - "operationId": "EndorserTransaction", - "responses": { - "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": {} - } - } - }, - "400": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "reason": { - "type": "string" - } - }, - "required": [ - "reason" - ], - "type": "object" - } - } - } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } + "method": { + "type": "string" + }, + "role": { + "type": "string" + }, + "endorserDid": { + "type": "string" + }, + "did": { + "type": "string" } }, - "tags": [ - "MultiTenancy" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [ - { - "in": "path", - "name": "tenantId", - "required": true, - "schema": { - "type": "string" - } - } + "required": [ + "config" ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/EndorserTransaction" - } - } - } - } + "type": "object", + "additionalProperties": false + } + }, + "securitySchemes": { + "apiKey": { + "type": "apiKey", + "name": "Authorization", + "in": "header" + }, + "jwt": { + "type": "http", + "scheme": "bearer", + "bearerFormat": "JWT" } + } + }, + "info": { + "title": "@aries-framework/rest", + "version": "0.9.4", + "description": "Rest endpoint wrapper for using your agent over HTTP", + "license": { + "name": "Apache-2.0" }, - "/multi-tenancy/connections/{connectionId}/{tenantId}": { + "contact": {} + }, + "paths": { + "/question-answer": { "get": { - "operationId": "GetConnectionById", + "operationId": "GetQuestionAnswerRecords", "responses": { "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": {}, - "examples": { - "Example 1": { - "value": { - "_tags": { - "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", - "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", - "invitationKey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz", - "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d", - "verkey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz" - }, - "metadata": {}, - "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", - "createdAt": "2022-01-01T00:00:00.000Z", - "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", - "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", - "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d" - } - } - } - } - } - }, - "404": { - "description": "", + "description": "QuestionAnswerRecord[]", "content": { "application/json": { "schema": { - "properties": { - "reason": { - "type": "string" - } + "items": { + "$ref": "#/components/schemas/Record_string.unknown_" }, - "required": [ - "reason" - ], - "type": "object" + "type": "array" } } } } }, + "description": "Retrieve question and answer records by query", "tags": [ - "MultiTenancy" + "Question Answer" ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [ { - "in": "path", - "name": "tenantId", - "required": true, + "description": "Connection identifier", + "in": "query", + "name": "connectionId", + "required": false, "schema": { "type": "string" } }, { - "in": "path", - "name": "connectionId", - "required": true, + "description": "Role of the question", + "in": "query", + "name": "role", + "required": false, "schema": { - "$ref": "#/components/schemas/RecordId" - } - } - ] - } - }, - "/multi-tenancy/create-invitation/{tenantId}": { - "post": { - "operationId": "CreateInvitation", - "responses": { - "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": {} - } + "$ref": "#/components/schemas/QuestionAnswerRole" } }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "tags": [ - "MultiTenancy" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [ { - "in": "path", - "name": "tenantId", - "required": true, + "description": "State of the question", + "in": "query", + "name": "state", + "required": false, "schema": { - "type": "string" - } - } - ], - "requestBody": { - "required": false, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Omit_CreateOutOfBandInvitationConfig.routing-or-appendedAttachments-or-messages_" - } - } - } - } - } - }, - "/multi-tenancy/create-legacy-invitation/{tenantId}": { - "post": { - "operationId": "CreateLegacyInvitation", - "responses": { - "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": {} - } + "$ref": "#/components/schemas/QuestionAnswerState" } }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "tags": [ - "MultiTenancy" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [ { - "in": "path", - "name": "tenantId", - "required": true, + "description": "Thread identifier", + "in": "query", + "name": "threadId", + "required": false, "schema": { "type": "string" } } - ], - "requestBody": { - "required": false, - "content": { - "application/json": { - "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/Omit_CreateOutOfBandInvitationConfig.routing-or-appendedAttachments-or-messages_" - }, - { - "$ref": "#/components/schemas/RecipientKeyOption" - } - ] - } - } - } - } + ] } }, - "/multi-tenancy/receive-invitation/{tenantId}": { + "/question-answer/question/{connectionId}": { "post": { - "operationId": "ReceiveInvitation", + "operationId": "SendQuestion", "responses": { "200": { "description": "Ok", @@ -4696,6 +1672,24 @@ } } }, + "404": { + "description": "", + "content": { + "application/json": { + "schema": { + "properties": { + "reason": { + "type": "string" + } + }, + "required": [ + "reason" + ], + "type": "object" + } + } + } + }, "500": { "description": "", "content": { @@ -4715,21 +1709,23 @@ } } }, + "description": "Send a question to a connection", "tags": [ - "MultiTenancy" + "Question Answer" ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [ { + "description": "Connection identifier", "in": "path", - "name": "tenantId", + "name": "connectionId", "required": true, "schema": { - "type": "string" + "$ref": "#/components/schemas/RecordId" } } ], @@ -4738,16 +1734,34 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ReceiveInvitationProps" + "properties": { + "detail": { + "type": "string" + }, + "validResponses": { + "items": { + "$ref": "#/components/schemas/ValidResponse" + }, + "type": "array" + }, + "question": { + "type": "string" + } + }, + "required": [ + "validResponses", + "question" + ], + "type": "object" } } } } } }, - "/multi-tenancy/receive-invitation-url/{tenantId}": { + "/question-answer/answer/{id}": { "post": { - "operationId": "ReceiveInvitationFromUrl", + "operationId": "SendAnswer", "responses": { "200": { "description": "Ok", @@ -4757,66 +1771,23 @@ } } }, - "500": { + "404": { "description": "", "content": { "application/json": { "schema": { "properties": { - "message": { + "reason": { "type": "string" } }, "required": [ - "message" + "reason" ], "type": "object" } } } - } - }, - "tags": [ - "MultiTenancy" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [ - { - "in": "path", - "name": "tenantId", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ReceiveInvitationByUrlProps" - } - } - } - } - } - }, - "/multi-tenancy/oob/{invitationId}/{tenantId}": { - "get": { - "operationId": "GetAllOutOfBandRecords", - "responses": { - "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": {} - } - } }, "500": { "description": "", @@ -4837,58 +1808,62 @@ } } }, + "description": "Send a answer to question", "tags": [ - "MultiTenancy" + "Question Answer" ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [ { + "description": "The id of the question answer record", "in": "path", - "name": "tenantId", + "name": "id", "required": true, "schema": { - "type": "string" + "$ref": "#/components/schemas/RecordId" } - }, - { - "in": "path", - "name": "invitationId", - "required": true, - "schema": { - "type": "string" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Record_response.string_" + } } } - ] + } } }, - "/multi-tenancy/connections/{tenantId}": { + "/question-answer/{id}": { "get": { - "operationId": "GetAllConnections", + "operationId": "GetQuestionAnswerRecordById", "responses": { "200": { - "description": "Ok", + "description": "ConnectionRecord", "content": { "application/json": { "schema": {} } } }, - "500": { + "404": { "description": "", "content": { "application/json": { "schema": { "properties": { - "message": { + "reason": { "type": "string" } }, "required": [ - "message" + "reason" ], "type": "object" } @@ -4896,122 +1871,73 @@ } } }, + "description": "Retrieve question answer record by id", "tags": [ - "MultiTenancy" + "Question Answer" ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [ { "in": "path", - "name": "tenantId", + "name": "id", "required": true, "schema": { - "type": "string" - } - }, - { - "in": "query", - "name": "outOfBandId", - "required": false, - "schema": { - "type": "string" - } - }, - { - "in": "query", - "name": "alias", - "required": false, - "schema": { - "type": "string" - } - }, - { - "in": "query", - "name": "state", - "required": false, - "schema": { - "$ref": "#/components/schemas/DidExchangeState" - } - }, - { - "in": "query", - "name": "myDid", - "required": false, - "schema": { - "type": "string" - } - }, - { - "in": "query", - "name": "theirDid", - "required": false, - "schema": { - "type": "string" - } - }, - { - "in": "query", - "name": "theirLabel", - "required": false, - "schema": { - "type": "string" + "$ref": "#/components/schemas/RecordId" } } ] } }, - "/multi-tenancy/url/{tenantId}/{invitationId}": { + "/proofs": { "get": { - "operationId": "GetInvitation", + "operationId": "GetAllProofs", "responses": { "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": {} - } - } - }, - "404": { - "description": "", + "description": "ProofRecord[]", "content": { "application/json": { "schema": { - "properties": { - "reason": { - "type": "string" - } + "items": { + "$ref": "#/components/schemas/Record_string.unknown_" }, - "required": [ - "reason" - ], - "type": "object" + "type": "array" + }, + "examples": { + "Example 1": { + "value": [ + { + "metadata": {}, + "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", + "createdAt": "2022-01-01T00:00:00.000Z", + "connectionId": "2aecf74c-3073-4f98-9acb-92415d096834", + "threadId": "0019d466-5eea-4269-8c40-031b4896c5b7", + "protocolVersion": "v1" + } + ] + } } } } } }, + "description": "Retrieve all proof records", "tags": [ - "MultiTenancy" + "Proofs" ], - "security": [], - "parameters": [ + "security": [ { - "in": "path", - "name": "invitationId", - "required": true, - "schema": { - "type": "string" - } - }, + "jwt": [] + } + ], + "parameters": [ { - "in": "path", - "name": "tenantId", - "required": true, + "in": "query", + "name": "threadId", + "required": false, "schema": { "type": "string" } @@ -5019,19 +1945,31 @@ ] } }, - "/multi-tenancy/schema/{tenantId}": { - "post": { - "operationId": "CreateSchema", + "/proofs/{proofRecordId}": { + "get": { + "operationId": "GetProofById", "responses": { "200": { - "description": "Ok", + "description": "ProofRecord", "content": { "application/json": { - "schema": {} + "schema": {}, + "examples": { + "Example 1": { + "value": { + "metadata": {}, + "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", + "createdAt": "2022-01-01T00:00:00.000Z", + "connectionId": "2aecf74c-3073-4f98-9acb-92415d096834", + "threadId": "0019d466-5eea-4269-8c40-031b4896c5b7", + "protocolVersion": "v1" + } + } + } } } }, - "400": { + "404": { "description": "", "content": { "application/json": { @@ -5068,74 +2006,66 @@ } } }, + "description": "Retrieve proof record by proof record id", "tags": [ - "MultiTenancy" + "Proofs" ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [ { "in": "path", - "name": "tenantId", + "name": "proofRecordId", "required": true, "schema": { - "type": "string" - } - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "properties": { - "endorserDid": { - "type": "string" - }, - "endorse": { - "type": "boolean" - }, - "attributes": { - "items": { - "type": "string" - }, - "type": "array" - }, - "version": { - "$ref": "#/components/schemas/Version" - }, - "name": { - "type": "string" - }, - "issuerId": { - "type": "string" - } - }, - "required": [ - "attributes", - "version", - "name", - "issuerId" - ], - "type": "object" - } + "$ref": "#/components/schemas/RecordId" } } - } + ] } }, - "/multi-tenancy/polygon-wc3/schema/{tenantId}": { + "/proofs/propose-proof": { "post": { - "operationId": "CreatePolygonW3CSchema", + "operationId": "ProposeProof", "responses": { "200": { - "description": "Ok", + "description": "ProofRecord", "content": { "application/json": { - "schema": {} + "schema": {}, + "examples": { + "Example 1": { + "value": { + "metadata": {}, + "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", + "createdAt": "2022-01-01T00:00:00.000Z", + "connectionId": "2aecf74c-3073-4f98-9acb-92415d096834", + "threadId": "0019d466-5eea-4269-8c40-031b4896c5b7", + "protocolVersion": "v1" + } + } + } + } + } + }, + "404": { + "description": "", + "content": { + "application/json": { + "schema": { + "properties": { + "reason": { + "type": "string" + } + }, + "required": [ + "reason" + ], + "type": "object" + } } } }, @@ -5158,84 +2088,53 @@ } } }, + "description": "Initiate a new presentation exchange as prover by sending a presentation proposal request\nto the connection with the specified connection id.", "tags": [ - "MultiTenancy" + "Proofs" ], "security": [ { - "apiKey": [] - } - ], - "parameters": [ - { - "in": "path", - "name": "tenantId", - "required": true, - "schema": { - "type": "string" - } + "jwt": [] } ], + "parameters": [], "requestBody": { "required": true, "content": { "application/json": { "schema": { - "properties": { - "schema": { - "additionalProperties": false, - "type": "object" - }, - "schemaName": { - "type": "string" - }, - "did": { - "type": "string" - } - }, - "required": [ - "schema", - "schemaName", - "did" - ], - "type": "object" + "$ref": "#/components/schemas/RequestProofProposalOptions" } } } } } }, - "/multi-tenancy/polygon-wc3/schema/{did}/{schemaId}/{tenantId}": { - "get": { - "operationId": "GetPolygonW3CSchemaById", + "/proofs/{proofRecordId}/accept-proposal": { + "post": { + "operationId": "AcceptProposal", "responses": { "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": {} - } - } - }, - "400": { - "description": "", + "description": "ProofRecord", "content": { "application/json": { - "schema": { - "properties": { - "reason": { - "type": "string" + "schema": {}, + "examples": { + "Example 1": { + "value": { + "metadata": {}, + "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", + "createdAt": "2022-01-01T00:00:00.000Z", + "connectionId": "2aecf74c-3073-4f98-9acb-92415d096834", + "threadId": "0019d466-5eea-4269-8c40-031b4896c5b7", + "protocolVersion": "v1" } - }, - "required": [ - "reason" - ], - "type": "object" + } } } } }, - "401": { + "404": { "description": "", "content": { "application/json": { @@ -5272,55 +2171,53 @@ } } }, + "description": "Accept a presentation proposal as verifier by sending an accept proposal message\nto the connection associated with the proof record.", "tags": [ - "MultiTenancy" + "Proofs" ], "security": [ { - "apiKey": [] + "jwt": [] } ], - "parameters": [ - { - "in": "path", - "name": "tenantId", - "required": true, - "schema": { - "type": "string" - } - }, - { - "in": "path", - "name": "did", - "required": true, - "schema": { - "type": "string" - } - }, - { - "in": "path", - "name": "schemaId", - "required": true, - "schema": { - "type": "string" + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AcceptProofProposal" + } } } - ] + } } }, - "/multi-tenancy/transactions/write/{tenantId}": { + "/proofs/request-proof": { "post": { - "operationId": "WriteSchemaAndCredDefOnLedger", + "operationId": "RequestProof", "responses": { "200": { "description": "Ok", "content": { "application/json": { - "schema": {} + "schema": {}, + "examples": { + "Example 1": { + "value": { + "metadata": {}, + "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", + "createdAt": "2022-01-01T00:00:00.000Z", + "connectionId": "2aecf74c-3073-4f98-9acb-92415d096834", + "threadId": "0019d466-5eea-4269-8c40-031b4896c5b7", + "protocolVersion": "v1" + } + } + } } } }, - "400": { + "404": { "description": "", "content": { "application/json": { @@ -5358,38 +2255,29 @@ } }, "tags": [ - "MultiTenancy" + "Proofs" ], "security": [ { - "apiKey": [] - } - ], - "parameters": [ - { - "in": "path", - "name": "tenantId", - "required": true, - "schema": { - "type": "string" - } + "jwt": [] } ], + "parameters": [], "requestBody": { "required": true, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/WriteTransaction" + "$ref": "#/components/schemas/RequestProofOptions" } } } } } }, - "/multi-tenancy/schema/{schemaId}/{tenantId}": { - "get": { - "operationId": "GetSchemaById", + "/proofs/create-request-oob": { + "post": { + "operationId": "CreateRequest", "responses": { "200": { "description": "Ok", @@ -5399,38 +2287,66 @@ } } }, - "400": { + "500": { "description": "", "content": { "application/json": { "schema": { "properties": { - "reason": { + "message": { "type": "string" } }, "required": [ - "reason" + "message" ], "type": "object" } } } - }, - "403": { - "description": "", + } + }, + "tags": [ + "Proofs" + ], + "security": [ + { + "jwt": [] + } + ], + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateProofRequestOobOptions" + } + } + } + } + } + }, + "/proofs/{proofRecordId}/accept-request": { + "post": { + "operationId": "AcceptRequest", + "responses": { + "200": { + "description": "ProofRecord", "content": { "application/json": { - "schema": { - "properties": { - "reason": { - "type": "string" + "schema": {}, + "examples": { + "Example 1": { + "value": { + "metadata": {}, + "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", + "createdAt": "2022-01-01T00:00:00.000Z", + "connectionId": "2aecf74c-3073-4f98-9acb-92415d096834", + "threadId": "0019d466-5eea-4269-8c40-031b4896c5b7", + "protocolVersion": "v1" } - }, - "required": [ - "reason" - ], - "type": "object" + } } } } @@ -5472,43 +2388,69 @@ } } }, + "description": "Accept a presentation request as prover by sending an accept request message\nto the connection associated with the proof record.", "tags": [ - "MultiTenancy" + "Proofs" ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [ { "in": "path", - "name": "schemaId", - "required": true, - "schema": { - "$ref": "#/components/schemas/SchemaId" - } - }, - { - "in": "path", - "name": "tenantId", + "name": "proofRecordId", "required": true, "schema": { "type": "string" } } - ] + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "properties": { + "comment": { + "type": "string" + }, + "filterByNonRevocationRequirements": { + "type": "boolean" + }, + "filterByPresentationPreview": { + "type": "boolean" + } + }, + "type": "object" + } + } + } + } } }, - "/multi-tenancy/credential-definition/{tenantId}": { + "/proofs/{proofRecordId}/accept-presentation": { "post": { - "operationId": "CreateCredentialDefinition", + "operationId": "AcceptPresentation", "responses": { "200": { - "description": "Ok", + "description": "ProofRecord", "content": { "application/json": { - "schema": {} + "schema": {}, + "examples": { + "Example 1": { + "value": { + "metadata": {}, + "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", + "createdAt": "2022-01-01T00:00:00.000Z", + "connectionId": "2aecf74c-3073-4f98-9acb-92415d096834", + "threadId": "0019d466-5eea-4269-8c40-031b4896c5b7", + "protocolVersion": "v1" + } + } + } } } }, @@ -5549,84 +2491,47 @@ } } }, + "description": "Accept a presentation as prover by sending an accept presentation message\nto the connection associated with the proof record.", "tags": [ - "MultiTenancy" + "Proofs" ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [ { "in": "path", - "name": "tenantId", + "name": "proofRecordId", "required": true, "schema": { "type": "string" } } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "properties": { - "endorserDid": { - "type": "string" - }, - "endorse": { - "type": "boolean" - }, - "tag": { - "type": "string" - }, - "schemaId": { - "type": "string" - }, - "issuerId": { - "type": "string" - } - }, - "required": [ - "tag", - "schemaId", - "issuerId" - ], - "type": "object" - } - } - } - } + ] } }, - "/multi-tenancy/credential-definition/{credentialDefinitionId}/{tenantId}": { + "/proofs/{proofRecordId}/form-data": { "get": { - "operationId": "GetCredentialDefinitionById", + "operationId": "ProofFormData", "responses": { "200": { "description": "Ok", "content": { "application/json": { - "schema": {} - } - } - }, - "400": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "reason": { - "type": "string" + "schema": {}, + "examples": { + "Example 1": { + "value": { + "metadata": {}, + "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", + "createdAt": "2022-01-01T00:00:00.000Z", + "connectionId": "2aecf74c-3073-4f98-9acb-92415d096834", + "threadId": "0019d466-5eea-4269-8c40-031b4896c5b7", + "protocolVersion": "v1" } - }, - "required": [ - "reason" - ], - "type": "object" + } } } } @@ -5669,25 +2574,17 @@ } }, "tags": [ - "MultiTenancy" + "Proofs" ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [ { "in": "path", - "name": "credentialDefinitionId", - "required": true, - "schema": { - "$ref": "#/components/schemas/CredentialDefinitionId" - } - }, - { - "in": "path", - "name": "tenantId", + "name": "proofRecordId", "required": true, "schema": { "type": "string" @@ -5696,15 +2593,33 @@ ] } }, - "/multi-tenancy/credentials/create-offer/{tenantId}": { + "/polygon/create-keys": { "post": { - "operationId": "CreateOffer", + "operationId": "CreateKeyPair", "responses": { "200": { - "description": "Ok", + "description": "Secp256k1KeyPair", "content": { "application/json": { - "schema": {} + "schema": { + "properties": { + "address": { + "type": "string" + }, + "publicKeyBase58": { + "type": "string" + }, + "privateKey": { + "type": "string" + } + }, + "required": [ + "address", + "publicKeyBase58", + "privateKey" + ], + "type": "object" + } } } }, @@ -5727,48 +2642,48 @@ } } }, + "description": "Create Secp256k1 key pair for polygon DID", "tags": [ - "MultiTenancy" + "Polygon" ], "security": [ { - "apiKey": [] - } - ], - "parameters": [ - { - "in": "path", - "name": "tenantId", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CreateOfferOptions" - } - } + "jwt": [] } - } + ], + "parameters": [] } }, - "/multi-tenancy/credentials/create-offer-oob/{tenantId}": { + "/polygon/create-schema": { "post": { - "operationId": "CreateOfferOob", + "operationId": "CreateSchema", "responses": { "200": { - "description": "Ok", + "description": "Schema JSON", "content": { "application/json": { "schema": {} } } }, + "400": { + "description": "", + "content": { + "application/json": { + "schema": { + "properties": { + "reason": { + "type": "string" + } + }, + "required": [ + "reason" + ], + "type": "object" + } + } + } + }, "500": { "description": "", "content": { @@ -5788,49 +2703,58 @@ } } }, + "description": "Create polygon based W3C schema", "tags": [ - "MultiTenancy" + "Polygon" ], "security": [ { - "apiKey": [] - } - ], - "parameters": [ - { - "in": "path", - "name": "tenantId", - "required": true, - "schema": { - "type": "string" - } + "jwt": [] } ], + "parameters": [], "requestBody": { "required": true, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/CreateOfferOobOptions" + "properties": { + "schema": { + "additionalProperties": false, + "type": "object" + }, + "schemaName": { + "type": "string" + }, + "did": { + "type": "string" + } + }, + "required": [ + "schema", + "schemaName", + "did" + ], + "type": "object" } } } } } }, - "/multi-tenancy/credentials/accept-offer/{tenantId}": { + "/polygon/estimate-transaction": { "post": { - "operationId": "AcceptOffer", + "operationId": "EstimateTransaction", "responses": { "200": { - "description": "Ok", + "description": "Transaction Object", "content": { "application/json": { "schema": {} } } }, - "404": { + "400": { "description": "", "content": { "application/json": { @@ -5867,49 +2791,49 @@ } } }, + "description": "Estimate transaction", "tags": [ - "MultiTenancy" + "Polygon" ], "security": [ { - "apiKey": [] - } - ], - "parameters": [ - { - "in": "path", - "name": "tenantId", - "required": true, - "schema": { - "type": "string" - } + "jwt": [] } ], + "parameters": [], "requestBody": { "required": true, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/AcceptCredentialOfferOptions" + "properties": { + "transaction": {}, + "operation": {} + }, + "required": [ + "transaction", + "operation" + ], + "type": "object" } } } } } }, - "/multi-tenancy/credentials/{credentialRecordId}/{tenantId}": { + "/polygon/{did}/{schemaId}": { "get": { - "operationId": "GetCredentialById", + "operationId": "GetSchemaById", "responses": { "200": { - "description": "Ok", + "description": "Schema Object", "content": { "application/json": { "schema": {} } } }, - "404": { + "401": { "description": "", "content": { "application/json": { @@ -5946,26 +2870,27 @@ } } }, + "description": "Fetch schema details", "tags": [ - "MultiTenancy" + "Polygon" ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [ { "in": "path", - "name": "credentialRecordId", + "name": "did", "required": true, "schema": { - "$ref": "#/components/schemas/RecordId" + "type": "string" } }, { "in": "path", - "name": "tenantId", + "name": "schemaId", "required": true, "schema": { "type": "string" @@ -5974,125 +2899,191 @@ ] } }, - "/multi-tenancy/credentials/{tenantId}": { + "/oob": { "get": { - "operationId": "GetAllCredentials", + "operationId": "GetAllOutOfBandRecords", "responses": { "200": { - "description": "Ok", + "description": "OutOfBandRecord[]", "content": { "application/json": { - "schema": {} + "schema": { + "items": { + "$ref": "#/components/schemas/Record_string.unknown_" + }, + "type": "array" + }, + "examples": { + "Example 1": { + "value": [ + { + "_tags": { + "invitationId": "1cbd22e4-1906-41e9-8807-83d84437f978", + "state": "await-response", + "role": "sender", + "recipientKeyFingerprints": [ + "z6MktUCPZjfRJXD4GMcYuXiqX2qZ8vBw6UAYpDFiHEUfwuLj" + ] + }, + "outOfBandInvitation": { + "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.1/invitation", + "@id": "d6472943-e5d0-4d95-8b48-790ed5a41931", + "label": "Aries Test Agent", + "accept": [ + "didcomm/aip1", + "didcomm/aip2;env=rfc19" + ], + "handshake_protocols": [ + "https://didcomm.org/didexchange/1.0", + "https://didcomm.org/connections/1.0" + ], + "services": [ + { + "id": "#inline-0", + "serviceEndpoint": "https://6b77-89-20-162-146.ngrok.io", + "type": "did-communication", + "recipientKeys": [ + "did:key:z6MkmTBHTWrvLPN8pBmUj7Ye5ww9GiacXCYMNVvpScSpf1DM" + ], + "routingKeys": [] + } + ] + }, + "metadata": {}, + "id": "42a95528-0e30-4f86-a462-0efb02178b53", + "createdAt": "2022-01-01T00:00:00.000Z", + "reusable": false + } + ] + } + } } } } }, + "description": "Retrieve all out of band records", "tags": [ - "MultiTenancy" + "Out Of Band" ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [ { - "in": "path", - "name": "tenantId", - "required": true, - "schema": { - "type": "string" - } - }, - { - "in": "query", - "name": "threadId", - "required": false, - "schema": { - "type": "string" - } - }, - { + "description": "invitation identifier", "in": "query", - "name": "connectionId", + "name": "invitationId", "required": false, "schema": { - "type": "string" + "$ref": "#/components/schemas/RecordId" } - }, - { - "in": "query", - "name": "state", - "required": false, - "schema": { - "$ref": "#/components/schemas/CredentialState" + } + ] + } + }, + "/oob/{outOfBandId}": { + "get": { + "operationId": "GetOutOfBandRecordById", + "responses": { + "200": { + "description": "OutOfBandRecord", + "content": { + "application/json": { + "schema": {}, + "examples": { + "Example 1": { + "value": { + "_tags": { + "invitationId": "1cbd22e4-1906-41e9-8807-83d84437f978", + "state": "await-response", + "role": "sender", + "recipientKeyFingerprints": [ + "z6MktUCPZjfRJXD4GMcYuXiqX2qZ8vBw6UAYpDFiHEUfwuLj" + ] + }, + "outOfBandInvitation": { + "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.1/invitation", + "@id": "d6472943-e5d0-4d95-8b48-790ed5a41931", + "label": "Aries Test Agent", + "accept": [ + "didcomm/aip1", + "didcomm/aip2;env=rfc19" + ], + "handshake_protocols": [ + "https://didcomm.org/didexchange/1.0", + "https://didcomm.org/connections/1.0" + ], + "services": [ + { + "id": "#inline-0", + "serviceEndpoint": "https://6b77-89-20-162-146.ngrok.io", + "type": "did-communication", + "recipientKeys": [ + "did:key:z6MkmTBHTWrvLPN8pBmUj7Ye5ww9GiacXCYMNVvpScSpf1DM" + ], + "routingKeys": [] + } + ] + }, + "metadata": {}, + "id": "42a95528-0e30-4f86-a462-0efb02178b53", + "createdAt": "2022-01-01T00:00:00.000Z", + "reusable": false + } + } + } + } } - } - ] - } - }, - "/multi-tenancy/proofs/{tenantId}": { - "get": { - "operationId": "GetAllProofs", - "responses": { - "200": { - "description": "Ok", + }, + "404": { + "description": "", "content": { "application/json": { - "schema": {} + "schema": { + "properties": { + "reason": { + "type": "string" + } + }, + "required": [ + "reason" + ], + "type": "object" + } } } } }, + "description": "Retrieve an out of band record by id", "tags": [ - "MultiTenancy" + "Out Of Band" ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [ { "in": "path", - "name": "tenantId", + "name": "outOfBandId", "required": true, "schema": { - "type": "string" - } - }, - { - "in": "query", - "name": "threadId", - "required": false, - "schema": { - "type": "string" + "$ref": "#/components/schemas/RecordId" } } ] - } - }, - "/multi-tenancy/form-data/{tenantId}/{proofRecordId}": { - "get": { - "operationId": "ProofFormData", + }, + "delete": { + "operationId": "DeleteOutOfBandRecord", "responses": { "200": { "description": "Ok", "content": { "application/json": { - "schema": {}, - "examples": { - "Example 1": { - "value": { - "metadata": {}, - "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", - "createdAt": "2022-01-01T00:00:00.000Z", - "connectionId": "2aecf74c-3073-4f98-9acb-92415d096834", - "threadId": "0019d466-5eea-4269-8c40-031b4896c5b7", - "protocolVersion": "v1" - } - } - } + "schema": {} } } }, @@ -6133,76 +3124,109 @@ } } }, + "description": "Deletes an out of band record from the repository.", "tags": [ - "MultiTenancy" + "Out Of Band" ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [ { + "description": "Record identifier", "in": "path", - "name": "proofRecordId", - "required": true, - "schema": { - "type": "string" - } - }, - { - "in": "path", - "name": "tenantId", + "name": "outOfBandId", "required": true, "schema": { - "type": "string" + "$ref": "#/components/schemas/RecordId" } } ] } }, - "/multi-tenancy/proofs/request-proof/{tenantId}": { + "/oob/create-invitation": { "post": { - "operationId": "RequestProof", + "operationId": "CreateInvitation", "responses": { "200": { - "description": "Ok", + "description": "Out of band record", "content": { "application/json": { "schema": {}, "examples": { "Example 1": { "value": { - "metadata": {}, - "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", - "createdAt": "2022-01-01T00:00:00.000Z", - "connectionId": "2aecf74c-3073-4f98-9acb-92415d096834", - "threadId": "0019d466-5eea-4269-8c40-031b4896c5b7", - "protocolVersion": "v1" + "invitationUrl": "string", + "invitation": { + "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.1/invitation", + "@id": "d6472943-e5d0-4d95-8b48-790ed5a41931", + "label": "Aries Test Agent", + "accept": [ + "didcomm/aip1", + "didcomm/aip2;env=rfc19" + ], + "handshake_protocols": [ + "https://didcomm.org/didexchange/1.0", + "https://didcomm.org/connections/1.0" + ], + "services": [ + { + "id": "#inline-0", + "serviceEndpoint": "https://6b77-89-20-162-146.ngrok.io", + "type": "did-communication", + "recipientKeys": [ + "did:key:z6MkmTBHTWrvLPN8pBmUj7Ye5ww9GiacXCYMNVvpScSpf1DM" + ], + "routingKeys": [] + } + ] + }, + "outOfBandRecord": { + "_tags": { + "invitationId": "1cbd22e4-1906-41e9-8807-83d84437f978", + "state": "await-response", + "role": "sender", + "recipientKeyFingerprints": [ + "z6MktUCPZjfRJXD4GMcYuXiqX2qZ8vBw6UAYpDFiHEUfwuLj" + ] + }, + "outOfBandInvitation": { + "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.1/invitation", + "@id": "d6472943-e5d0-4d95-8b48-790ed5a41931", + "label": "Aries Test Agent", + "accept": [ + "didcomm/aip1", + "didcomm/aip2;env=rfc19" + ], + "handshake_protocols": [ + "https://didcomm.org/didexchange/1.0", + "https://didcomm.org/connections/1.0" + ], + "services": [ + { + "id": "#inline-0", + "serviceEndpoint": "https://6b77-89-20-162-146.ngrok.io", + "type": "did-communication", + "recipientKeys": [ + "did:key:z6MkmTBHTWrvLPN8pBmUj7Ye5ww9GiacXCYMNVvpScSpf1DM" + ], + "routingKeys": [] + } + ] + }, + "metadata": {}, + "id": "42a95528-0e30-4f86-a462-0efb02178b53", + "createdAt": "2022-01-01T00:00:00.000Z", + "reusable": false + } } } } } } }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "reason": { - "type": "string" - } - }, - "required": [ - "reason" - ], - "type": "object" - } - } - } - }, "500": { "description": "", "content": { @@ -6222,45 +3246,107 @@ } } }, + "description": "Creates an outbound out-of-band record containing out-of-band invitation message defined in\nAries RFC 0434: Out-of-Band Protocol 1.1.", "tags": [ - "MultiTenancy" + "Out Of Band" ], "security": [ { - "apiKey": [] - } - ], - "parameters": [ - { - "in": "path", - "name": "tenantId", - "required": true, - "schema": { - "type": "string" - } + "jwt": [] } ], + "parameters": [], "requestBody": { + "description": "configuration of how out-of-band invitation should be created", "required": true, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/RequestProofOptions" + "$ref": "#/components/schemas/CreateInvitationOptions", + "description": "configuration of how out-of-band invitation should be created" } } } } } }, - "/multi-tenancy/proofs/create-request-oob/{tenantId}": { + "/oob/create-legacy-invitation": { "post": { - "operationId": "CreateRequest", + "operationId": "CreateLegacyInvitation", "responses": { "200": { - "description": "Ok", + "description": "out-of-band record and invitation", "content": { "application/json": { - "schema": {} + "schema": {}, + "examples": { + "Example 1": { + "value": { + "invitation": { + "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.1/invitation", + "@id": "d6472943-e5d0-4d95-8b48-790ed5a41931", + "label": "Aries Test Agent", + "accept": [ + "didcomm/aip1", + "didcomm/aip2;env=rfc19" + ], + "handshake_protocols": [ + "https://didcomm.org/didexchange/1.0", + "https://didcomm.org/connections/1.0" + ], + "services": [ + { + "id": "#inline-0", + "serviceEndpoint": "https://6b77-89-20-162-146.ngrok.io", + "type": "did-communication", + "recipientKeys": [ + "did:key:z6MkmTBHTWrvLPN8pBmUj7Ye5ww9GiacXCYMNVvpScSpf1DM" + ], + "routingKeys": [] + } + ] + }, + "outOfBandRecord": { + "_tags": { + "invitationId": "1cbd22e4-1906-41e9-8807-83d84437f978", + "state": "await-response", + "role": "sender", + "recipientKeyFingerprints": [ + "z6MktUCPZjfRJXD4GMcYuXiqX2qZ8vBw6UAYpDFiHEUfwuLj" + ] + }, + "outOfBandInvitation": { + "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.1/invitation", + "@id": "d6472943-e5d0-4d95-8b48-790ed5a41931", + "label": "Aries Test Agent", + "accept": [ + "didcomm/aip1", + "didcomm/aip2;env=rfc19" + ], + "handshake_protocols": [ + "https://didcomm.org/didexchange/1.0", + "https://didcomm.org/connections/1.0" + ], + "services": [ + { + "id": "#inline-0", + "serviceEndpoint": "https://6b77-89-20-162-146.ngrok.io", + "type": "did-communication", + "recipientKeys": [ + "did:key:z6MkmTBHTWrvLPN8pBmUj7Ye5ww9GiacXCYMNVvpScSpf1DM" + ], + "routingKeys": [] + } + ] + }, + "metadata": {}, + "id": "42a95528-0e30-4f86-a462-0efb02178b53", + "createdAt": "2022-01-01T00:00:00.000Z", + "reusable": false + } + } + } + } } } }, @@ -6283,54 +3369,54 @@ } } }, + "description": "Creates an outbound out-of-band record in the same way how `createInvitation` method does it,\nbut it also converts out-of-band invitation message to an \"legacy\" invitation message defined\nin RFC 0160: Connection Protocol and returns it together with out-of-band record.", "tags": [ - "MultiTenancy" + "Out Of Band" ], "security": [ { - "apiKey": [] - } - ], - "parameters": [ - { - "in": "path", - "name": "tenantId", - "required": true, - "schema": { - "type": "string" - } + "jwt": [] } ], + "parameters": [], "requestBody": { - "required": true, + "description": "configuration of how a invitation should be created", + "required": false, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/CreateProofRequestOobOptions" + "allOf": [ + { + "$ref": "#/components/schemas/Omit_CreateLegacyInvitationConfig.routing_" + }, + { + "$ref": "#/components/schemas/RecipientKeyOption" + } + ], + "description": "configuration of how a invitation should be created" } } } } } }, - "/multi-tenancy/proofs/{proofRecordId}/accept-request/{tenantId}": { + "/oob/create-legacy-connectionless-invitation": { "post": { - "operationId": "AcceptRequest", + "operationId": "CreateLegacyConnectionlessInvitation", "responses": { "200": { - "description": "Ok", + "description": "a message and a invitationUrl", "content": { "application/json": { "schema": {}, "examples": { "Example 1": { "value": { - "metadata": {}, - "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", - "createdAt": "2022-01-01T00:00:00.000Z", - "connectionId": "2aecf74c-3073-4f98-9acb-92415d096834", - "threadId": "0019d466-5eea-4269-8c40-031b4896c5b7", - "protocolVersion": "v1" + "message": { + "@id": "eac4ff4e-b4fb-4c1d-aef3-b29c89d1cc00", + "@type": "https://didcomm.org/connections/1.0/invitation" + }, + "invitationUrl": "http://example.com/invitation_url" } } } @@ -6374,97 +3460,229 @@ } } }, + "description": "Creates a new connectionless legacy invitation.", "tags": [ - "MultiTenancy" + "Out Of Band" ], "security": [ { - "apiKey": [] - } - ], - "parameters": [ - { - "in": "path", - "name": "tenantId", - "required": true, - "schema": { - "type": "string" - } - }, - { - "in": "path", - "name": "proofRecordId", - "required": true, - "schema": { - "type": "string" - } + "jwt": [] } ], + "parameters": [], "requestBody": { + "description": "configuration of how a connection invitation should be created", "required": true, "content": { "application/json": { "schema": { "properties": { - "comment": { + "domain": { "type": "string" }, - "filterByNonRevocationRequirements": { - "type": "boolean" + "message": { + "$ref": "#/components/schemas/AgentMessageType" }, - "filterByPresentationPreview": { - "type": "boolean" + "recordId": { + "type": "string" } }, - "type": "object" + "required": [ + "domain", + "message", + "recordId" + ], + "type": "object", + "description": "configuration of how a connection invitation should be created" } } } } } }, - "/multi-tenancy/proofs/{proofRecordId}/accept-presentation/{tenantId}": { + "/oob/receive-invitation": { "post": { - "operationId": "AcceptPresentation", + "operationId": "ReceiveInvitation", "responses": { "200": { - "description": "Ok", + "description": "out-of-band record and connection record if one has been created.", "content": { "application/json": { "schema": {}, "examples": { "Example 1": { "value": { - "metadata": {}, - "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", - "createdAt": "2022-01-01T00:00:00.000Z", - "connectionId": "2aecf74c-3073-4f98-9acb-92415d096834", - "threadId": "0019d466-5eea-4269-8c40-031b4896c5b7", - "protocolVersion": "v1" + "outOfBandRecord": { + "_tags": { + "invitationId": "1cbd22e4-1906-41e9-8807-83d84437f978", + "state": "await-response", + "role": "sender", + "recipientKeyFingerprints": [ + "z6MktUCPZjfRJXD4GMcYuXiqX2qZ8vBw6UAYpDFiHEUfwuLj" + ] + }, + "outOfBandInvitation": { + "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.1/invitation", + "@id": "d6472943-e5d0-4d95-8b48-790ed5a41931", + "label": "Aries Test Agent", + "accept": [ + "didcomm/aip1", + "didcomm/aip2;env=rfc19" + ], + "handshake_protocols": [ + "https://didcomm.org/didexchange/1.0", + "https://didcomm.org/connections/1.0" + ], + "services": [ + { + "id": "#inline-0", + "serviceEndpoint": "https://6b77-89-20-162-146.ngrok.io", + "type": "did-communication", + "recipientKeys": [ + "did:key:z6MkmTBHTWrvLPN8pBmUj7Ye5ww9GiacXCYMNVvpScSpf1DM" + ], + "routingKeys": [] + } + ] + }, + "metadata": {}, + "id": "42a95528-0e30-4f86-a462-0efb02178b53", + "createdAt": "2022-01-01T00:00:00.000Z", + "reusable": false + }, + "connectionRecord": { + "_tags": { + "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", + "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", + "invitationKey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz", + "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d", + "verkey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz" + }, + "metadata": {}, + "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", + "createdAt": "2022-01-01T00:00:00.000Z", + "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", + "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", + "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d" + } + } + } + } + } + } + }, + "500": { + "description": "", + "content": { + "application/json": { + "schema": { + "properties": { + "message": { + "type": "string" + } + }, + "required": [ + "message" + ], + "type": "object" + } + } + } + } + }, + "description": "Creates inbound out-of-band record and assigns out-of-band invitation message to it if the\nmessage is valid.", + "tags": [ + "Out Of Band" + ], + "security": [ + { + "jwt": [] + } + ], + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ReceiveInvitationProps" + } + } + } + } + } + }, + "/oob/receive-invitation-url": { + "post": { + "operationId": "ReceiveInvitationFromUrl", + "responses": { + "200": { + "description": "out-of-band record and connection record if one has been created.", + "content": { + "application/json": { + "schema": {}, + "examples": { + "Example 1": { + "value": { + "outOfBandRecord": { + "_tags": { + "invitationId": "1cbd22e4-1906-41e9-8807-83d84437f978", + "state": "await-response", + "role": "sender", + "recipientKeyFingerprints": [ + "z6MktUCPZjfRJXD4GMcYuXiqX2qZ8vBw6UAYpDFiHEUfwuLj" + ] + }, + "outOfBandInvitation": { + "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.1/invitation", + "@id": "d6472943-e5d0-4d95-8b48-790ed5a41931", + "label": "Aries Test Agent", + "accept": [ + "didcomm/aip1", + "didcomm/aip2;env=rfc19" + ], + "handshake_protocols": [ + "https://didcomm.org/didexchange/1.0", + "https://didcomm.org/connections/1.0" + ], + "services": [ + { + "id": "#inline-0", + "serviceEndpoint": "https://6b77-89-20-162-146.ngrok.io", + "type": "did-communication", + "recipientKeys": [ + "did:key:z6MkmTBHTWrvLPN8pBmUj7Ye5ww9GiacXCYMNVvpScSpf1DM" + ], + "routingKeys": [] + } + ] + }, + "metadata": {}, + "id": "42a95528-0e30-4f86-a462-0efb02178b53", + "createdAt": "2022-01-01T00:00:00.000Z", + "reusable": false + }, + "connectionRecord": { + "_tags": { + "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", + "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", + "invitationKey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz", + "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d", + "verkey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz" + }, + "metadata": {}, + "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", + "createdAt": "2022-01-01T00:00:00.000Z", + "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", + "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", + "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d" + } } } } } } }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "reason": { - "type": "string" - } - }, - "required": [ - "reason" - ], - "type": "object" - } - } - } - }, "500": { "description": "", "content": { @@ -6484,37 +3702,31 @@ } } }, + "description": "Creates inbound out-of-band record and assigns out-of-band invitation message to it if the\nmessage is valid.", "tags": [ - "MultiTenancy" + "Out Of Band" ], "security": [ { - "apiKey": [] + "jwt": [] } ], - "parameters": [ - { - "in": "path", - "name": "tenantId", - "required": true, - "schema": { - "type": "string" - } - }, - { - "in": "path", - "name": "proofRecordId", - "required": true, - "schema": { - "type": "string" + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ReceiveInvitationByUrlProps" + } } } - ] + } } }, - "/multi-tenancy/proofs/{proofRecordId}/{tenantId}": { - "get": { - "operationId": "GetProofById", + "/oob/{outOfBandId}/accept-invitation": { + "post": { + "operationId": "AcceptInvitation", "responses": { "200": { "description": "Ok", @@ -6524,12 +3736,59 @@ "examples": { "Example 1": { "value": { - "metadata": {}, - "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", - "createdAt": "2022-01-01T00:00:00.000Z", - "connectionId": "2aecf74c-3073-4f98-9acb-92415d096834", - "threadId": "0019d466-5eea-4269-8c40-031b4896c5b7", - "protocolVersion": "v1" + "outOfBandRecord": { + "_tags": { + "invitationId": "1cbd22e4-1906-41e9-8807-83d84437f978", + "state": "await-response", + "role": "sender", + "recipientKeyFingerprints": [ + "z6MktUCPZjfRJXD4GMcYuXiqX2qZ8vBw6UAYpDFiHEUfwuLj" + ] + }, + "outOfBandInvitation": { + "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.1/invitation", + "@id": "d6472943-e5d0-4d95-8b48-790ed5a41931", + "label": "Aries Test Agent", + "accept": [ + "didcomm/aip1", + "didcomm/aip2;env=rfc19" + ], + "handshake_protocols": [ + "https://didcomm.org/didexchange/1.0", + "https://didcomm.org/connections/1.0" + ], + "services": [ + { + "id": "#inline-0", + "serviceEndpoint": "https://6b77-89-20-162-146.ngrok.io", + "type": "did-communication", + "recipientKeys": [ + "did:key:z6MkmTBHTWrvLPN8pBmUj7Ye5ww9GiacXCYMNVvpScSpf1DM" + ], + "routingKeys": [] + } + ] + }, + "metadata": {}, + "id": "42a95528-0e30-4f86-a462-0efb02178b53", + "createdAt": "2022-01-01T00:00:00.000Z", + "reusable": false + }, + "connectionRecord": { + "_tags": { + "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", + "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", + "invitationKey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz", + "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d", + "verkey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz" + }, + "metadata": {}, + "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", + "createdAt": "2022-01-01T00:00:00.000Z", + "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", + "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", + "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d" + } } } } @@ -6573,106 +3832,177 @@ } } }, + "description": "Accept a connection invitation as invitee (by sending a connection request message) for the connection with the specified connection id.\nThis is not needed when auto accepting of connections is enabled.", "tags": [ - "MultiTenancy" + "Out Of Band" ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [ { "in": "path", - "name": "tenantId", - "required": true, - "schema": { - "type": "string" - } - }, - { - "in": "path", - "name": "proofRecordId", + "name": "outOfBandId", "required": true, "schema": { "$ref": "#/components/schemas/RecordId" } } - ] + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AcceptInvitationConfig" + } + } + } + } } }, - "/multi-tenancy/{tenantId}": { - "delete": { - "operationId": "DeleteTenantById", + "/agent/info": { + "get": { + "operationId": "GetAgentInfo", "responses": { "200": { "description": "Ok", "content": { "application/json": { - "schema": {} + "schema": { + "$ref": "#/components/schemas/AgentInfo" + } } } - }, - "404": { - "description": "", + } + }, + "description": "Retrieve basic agent information", + "tags": [ + "Agent" + ], + "security": [ + { + "jwt": [] + } + ], + "parameters": [] + } + }, + "/agent/token": { + "post": { + "operationId": "GetAgentToken", + "responses": { + "200": { + "description": "Ok", "content": { "application/json": { "schema": { - "properties": { - "reason": { + "anyOf": [ + { + "$ref": "#/components/schemas/AgentToken" + }, + { "type": "string" } - }, - "required": [ - "reason" - ], - "type": "object" + ] } } } - }, - "500": { - "description": "", + } + }, + "description": "Retrieve agent token", + "tags": [ + "Agent" + ], + "security": [ + { + "apiKey": [] + } + ], + "parameters": [] + } + }, + "/agent/wallet": { + "delete": { + "operationId": "DeleteWallet", + "responses": { + "204": { + "description": "No content" + } + }, + "description": "Delete wallet", + "tags": [ + "Agent" + ], + "security": [ + { + "jwt": [] + } + ], + "parameters": [] + } + }, + "/basic-messages/{connectionId}": { + "get": { + "operationId": "GetBasicMessages", + "responses": { + "200": { + "description": "BasicMessageRecord[]", "content": { "application/json": { "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" + "items": { + "$ref": "#/components/schemas/BasicMessageRecord" + }, + "type": "array" + }, + "examples": { + "Example 1": { + "value": [ + { + "_tags": { + "role": "sender", + "connectionId": "2aecf74c-3073-4f98-9acb-92415d096834" + }, + "metadata": {}, + "id": "74bcf865-1fdc-45b4-b517-9def02dfd25f", + "createdAt": "2022-08-18T08:38:40.216Z", + "content": "string", + "sentTime": "2022-08-18T08:38:40.216Z", + "connectionId": "2aecf74c-3073-4f98-9acb-92415d096834" + } + ] + } } } } } }, + "description": "Retrieve basic messages by connection id", "tags": [ - "MultiTenancy" + "Basic Messages" ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [ { + "description": "Connection identifier", "in": "path", - "name": "tenantId", + "name": "connectionId", "required": true, "schema": { - "type": "string" + "$ref": "#/components/schemas/RecordId" } } ] - } - }, - "/multi-tenancy/did/web/{tenantId}": { + }, "post": { - "operationId": "CreateDidWeb", + "operationId": "SendMessage", "responses": { "200": { "description": "Ok", @@ -6682,66 +4012,23 @@ } } }, - "500": { + "404": { "description": "", "content": { "application/json": { "schema": { "properties": { - "message": { + "reason": { "type": "string" } }, "required": [ - "message" + "reason" ], "type": "object" } } } - } - }, - "tags": [ - "MultiTenancy" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [ - { - "in": "path", - "name": "tenantId", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/DidCreate" - } - } - } - } - } - }, - "/multi-tenancy/did/key{tenantId}": { - "post": { - "operationId": "CreateDidKey", - "responses": { - "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": {} - } - } }, "500": { "description": "", @@ -6762,21 +4049,23 @@ } } }, + "description": "Send a basic message to a connection", "tags": [ - "MultiTenancy" + "Basic Messages" ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [ { + "description": "Connection identifier", "in": "path", - "name": "tenantId", + "name": "connectionId", "required": true, "schema": { - "type": "string" + "$ref": "#/components/schemas/RecordId" } } ], @@ -6785,81 +4074,105 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/DidCreate" + "$ref": "#/components/schemas/Record_content.string_" } } } } } }, - "/multi-tenancy/question-answer/{tenantId}": { + "/connections": { "get": { - "operationId": "GetQuestionAnswerRecords", + "operationId": "GetAllConnections", "responses": { "200": { - "description": "QuestionAnswerRecord[]", + "description": "ConnectionRecord[]", "content": { "application/json": { - "schema": { - "items": { - "$ref": "#/components/schemas/Record_string.unknown_" - }, - "type": "array" + "schema": {}, + "examples": { + "Example 1": { + "value": [ + { + "_tags": { + "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", + "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", + "invitationKey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz", + "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d", + "verkey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz" + }, + "metadata": {}, + "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", + "createdAt": "2022-01-01T00:00:00.000Z", + "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", + "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", + "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d" + } + ] + } } } } } }, - "description": "Retrieve question and answer records by query", + "description": "Retrieve all connections records", "tags": [ - "MultiTenancy" + "Connections" ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [ { - "description": "Tenant identifier", - "in": "path", - "name": "tenantId", - "required": true, + "in": "query", + "name": "outOfBandId", + "required": false, "schema": { "type": "string" } }, { - "description": "Connection identifier", + "description": "Alias", "in": "query", - "name": "connectionId", + "name": "alias", "required": false, "schema": { "type": "string" } }, { - "description": "Role of the question", + "description": "Connection state", "in": "query", - "name": "role", + "name": "state", "required": false, "schema": { - "$ref": "#/components/schemas/QuestionAnswerRole" + "$ref": "#/components/schemas/DidExchangeState" } }, { - "description": "State of the question", + "description": "My DID", "in": "query", - "name": "state", + "name": "myDid", "required": false, "schema": { - "$ref": "#/components/schemas/QuestionAnswerState" + "type": "string" } }, { - "description": "Thread identifier", + "description": "Their DID", "in": "query", - "name": "threadId", + "name": "theirDid", + "required": false, + "schema": { + "type": "string" + } + }, + { + "description": "Their label", + "in": "query", + "name": "theirLabel", "required": false, "schema": { "type": "string" @@ -6868,15 +4181,34 @@ ] } }, - "/multi-tenancy/question-answer/question/{connectionId}/{tenantId}": { - "post": { - "operationId": "SendQuestion", + "/connections/{connectionId}": { + "get": { + "operationId": "GetConnectionById", "responses": { "200": { - "description": "Ok", + "description": "ConnectionRecord", "content": { "application/json": { - "schema": {} + "schema": {}, + "examples": { + "Example 1": { + "value": { + "_tags": { + "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", + "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", + "invitationKey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz", + "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d", + "verkey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz" + }, + "metadata": {}, + "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", + "createdAt": "2022-01-01T00:00:00.000Z", + "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", + "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", + "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d" + } + } + } } } }, @@ -6897,33 +4229,15 @@ } } } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } } }, - "description": "Send a question to a connection", + "description": "Retrieve connection record by connection id", "tags": [ - "MultiTenancy" + "Connections" ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [ @@ -6931,54 +4245,15 @@ "description": "Connection identifier", "in": "path", "name": "connectionId", - "required": true, - "schema": { - "$ref": "#/components/schemas/RecordId" - } - }, - { - "description": "Tenant identifier", - "in": "path", - "name": "tenantId", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "properties": { - "detail": { - "type": "string" - }, - "validResponses": { - "items": { - "$ref": "#/components/schemas/ValidResponse" - }, - "type": "array" - }, - "question": { - "type": "string" - } - }, - "required": [ - "validResponses", - "question" - ], - "type": "object" - } + "required": true, + "schema": { + "$ref": "#/components/schemas/RecordId" } } - } - } - }, - "/multi-tenancy/question-answer/answer/{id}/{tenantId}": { - "post": { - "operationId": "SendAnswer", + ] + }, + "delete": { + "operationId": "DeleteConnection", "responses": { "200": { "description": "Ok", @@ -7025,56 +4300,56 @@ } } }, - "description": "Send a answer to question", + "description": "Deletes a connection record from the connection repository.", "tags": [ - "MultiTenancy" + "Connections" ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [ { - "description": "Question Answer Record identifier", + "description": "Connection identifier", "in": "path", - "name": "id", + "name": "connectionId", "required": true, "schema": { "$ref": "#/components/schemas/RecordId" } - }, - { - "description": "Tenant identifier", - "in": "path", - "name": "tenantId", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Record_response.string_" - } - } } - } + ] } }, - "/multi-tenancy/question-answer/{id}/{tenantId}": { - "get": { - "operationId": "GetQuestionAnswerRecordById", + "/connections/{connectionId}/accept-request": { + "post": { + "operationId": "AcceptRequest", "responses": { "200": { "description": "ConnectionRecord", "content": { "application/json": { - "schema": {} + "schema": {}, + "examples": { + "Example 1": { + "value": { + "_tags": { + "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", + "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", + "invitationKey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz", + "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d", + "verkey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz" + }, + "metadata": {}, + "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", + "createdAt": "2022-01-01T00:00:00.000Z", + "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", + "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", + "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d" + } + } + } } } }, @@ -7095,110 +4370,73 @@ } } } - } - }, - "description": "Retrieve question answer record by id", - "tags": [ - "MultiTenancy" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [ - { - "description": "Question Answer Record identifier", - "in": "path", - "name": "id", - "required": true, - "schema": { - "$ref": "#/components/schemas/RecordId" - } }, - { - "description": "Tenant identifier", - "in": "path", - "name": "tenantId", - "required": true, - "schema": { - "type": "string" - } - } - ] - } - }, - "/proofs": { - "get": { - "operationId": "GetAllProofs", - "responses": { - "200": { - "description": "ProofRecord[]", + "500": { + "description": "", "content": { "application/json": { "schema": { - "items": { - "$ref": "#/components/schemas/Record_string.unknown_" + "properties": { + "message": { + "type": "string" + } }, - "type": "array" - }, - "examples": { - "Example 1": { - "value": [ - { - "metadata": {}, - "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", - "createdAt": "2022-01-01T00:00:00.000Z", - "connectionId": "2aecf74c-3073-4f98-9acb-92415d096834", - "threadId": "0019d466-5eea-4269-8c40-031b4896c5b7", - "protocolVersion": "v1" - } - ] - } + "required": [ + "message" + ], + "type": "object" } } } } }, - "description": "Retrieve all proof records", + "description": "Accept a connection request as inviter by sending a connection response message\nfor the connection with the specified connection id.\n\nThis is not needed when auto accepting of connection is enabled.", "tags": [ - "Proofs" + "Connections" ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [ { - "in": "query", - "name": "threadId", - "required": false, + "description": "Connection identifier", + "in": "path", + "name": "connectionId", + "required": true, "schema": { - "type": "string" + "$ref": "#/components/schemas/RecordId" } } ] } }, - "/proofs/{proofRecordId}": { - "get": { - "operationId": "GetProofById", + "/connections/{connectionId}/accept-response": { + "post": { + "operationId": "AcceptResponse", "responses": { "200": { - "description": "ProofRecord", + "description": "ConnectionRecord", "content": { "application/json": { "schema": {}, "examples": { "Example 1": { "value": { + "_tags": { + "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", + "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", + "invitationKey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz", + "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d", + "verkey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz" + }, "metadata": {}, "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", "createdAt": "2022-01-01T00:00:00.000Z", - "connectionId": "2aecf74c-3073-4f98-9acb-92415d096834", - "threadId": "0019d466-5eea-4269-8c40-031b4896c5b7", - "protocolVersion": "v1" + "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", + "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", + "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d" } } } @@ -7242,19 +4480,20 @@ } } }, - "description": "Retrieve proof record by proof record id", + "description": "Accept a connection response as invitee by sending a trust ping message\nfor the connection with the specified connection id.\n\nThis is not needed when auto accepting of connection is enabled.", "tags": [ - "Proofs" + "Connections" ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [ { + "description": "Connection identifier", "in": "path", - "name": "proofRecordId", + "name": "connectionId", "required": true, "schema": { "$ref": "#/components/schemas/RecordId" @@ -7263,27 +4502,15 @@ ] } }, - "/proofs/propose-proof": { - "post": { - "operationId": "ProposeProof", + "/url/{invitationId}": { + "get": { + "operationId": "GetInvitation", "responses": { "200": { - "description": "ProofRecord", + "description": "Ok", "content": { "application/json": { - "schema": {}, - "examples": { - "Example 1": { - "value": { - "metadata": {}, - "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", - "createdAt": "2022-01-01T00:00:00.000Z", - "connectionId": "2aecf74c-3073-4f98-9acb-92415d096834", - "threadId": "0019d466-5eea-4269-8c40-031b4896c5b7", - "protocolVersion": "v1" - } - } - } + "schema": {} } } }, @@ -7324,48 +4551,84 @@ } } }, - "description": "Initiate a new presentation exchange as prover by sending a presentation proposal request\nto the connection with the specified connection id.", "tags": [ - "Proofs" + "Connections" ], - "security": [ + "security": [], + "parameters": [ { - "apiKey": [] + "in": "path", + "name": "invitationId", + "required": true, + "schema": { + "type": "string" + } } - ], - "parameters": [], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/RequestProofProposalOptions" + ] + } + }, + "/credential-definitions/{credentialDefinitionId}": { + "get": { + "operationId": "GetCredentialDefinitionById", + "responses": { + "200": { + "description": "CredDef", + "content": { + "application/json": { + "schema": {}, + "examples": { + "Example 1": { + "value": { + "ver": "1.0", + "id": "WgWxqztrNooG92RXvxSTWv:3:CL:20:tag", + "schemaId": "351936", + "type": "CL", + "tag": "definition", + "value": { + "primary": { + "n": "string", + "s": "string", + "r": { + "master_secret": "string", + "string": "string" + }, + "rctxt": "string", + "z": "string" + }, + "revocation": { + "g": "1 string", + "g_dash": "string", + "h": "string", + "h0": "string", + "h1": "string", + "h2": "string", + "htilde": "string", + "h_cap": "string", + "u": "string", + "pk": "string", + "y": "string" + } + } + } + } + } } } - } - } - } - }, - "/proofs/{proofRecordId}/accept-proposal": { - "post": { - "operationId": "AcceptProposal", - "responses": { - "200": { - "description": "ProofRecord", + }, + "400": { + "description": "", "content": { "application/json": { - "schema": {}, - "examples": { - "Example 1": { - "value": { - "metadata": {}, - "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", - "createdAt": "2022-01-01T00:00:00.000Z", - "connectionId": "2aecf74c-3073-4f98-9acb-92415d096834", - "threadId": "0019d466-5eea-4269-8c40-031b4896c5b7", - "protocolVersion": "v1" + "schema": { + "properties": { + "reason": { + "type": "string" } - } + }, + "required": [ + "reason" + ], + "type": "object" } } } @@ -7407,46 +4670,69 @@ } } }, - "description": "Accept a presentation proposal as verifier by sending an accept proposal message\nto the connection associated with the proof record.", + "description": "Retrieve credential definition by credential definition id", "tags": [ - "Proofs" + "Credential Definitions" ], "security": [ { - "apiKey": [] + "jwt": [] } ], - "parameters": [], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/AcceptProofProposal" - } + "parameters": [ + { + "in": "path", + "name": "credentialDefinitionId", + "required": true, + "schema": { + "$ref": "#/components/schemas/CredentialDefinitionId" } } - } + ] } }, - "/proofs/request-proof": { + "/credential-definitions": { "post": { - "operationId": "RequestProof", + "operationId": "CreateCredentialDefinition", "responses": { "200": { - "description": "Ok", + "description": "CredDef", "content": { "application/json": { "schema": {}, "examples": { "Example 1": { "value": { - "metadata": {}, - "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", - "createdAt": "2022-01-01T00:00:00.000Z", - "connectionId": "2aecf74c-3073-4f98-9acb-92415d096834", - "threadId": "0019d466-5eea-4269-8c40-031b4896c5b7", - "protocolVersion": "v1" + "ver": "1.0", + "id": "WgWxqztrNooG92RXvxSTWv:3:CL:20:tag", + "schemaId": "351936", + "type": "CL", + "tag": "definition", + "value": { + "primary": { + "n": "string", + "s": "string", + "r": { + "master_secret": "string", + "string": "string" + }, + "rctxt": "string", + "z": "string" + }, + "revocation": { + "g": "1 string", + "g_dash": "string", + "h": "string", + "h0": "string", + "h1": "string", + "h2": "string", + "htilde": "string", + "h_cap": "string", + "u": "string", + "pk": "string", + "y": "string" + } + } } } } @@ -7490,12 +4776,13 @@ } } }, + "description": "Creates a new credential definition.", "tags": [ - "Proofs" + "Credential Definitions" ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [], @@ -7504,85 +4791,93 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/RequestProofOptions" + "properties": { + "endorserDid": { + "type": "string" + }, + "endorse": { + "type": "boolean" + }, + "tag": { + "type": "string" + }, + "schemaId": { + "$ref": "#/components/schemas/SchemaId" + }, + "issuerId": { + "type": "string" + } + }, + "required": [ + "tag", + "schemaId", + "issuerId" + ], + "type": "object" } } } } } }, - "/proofs/create-request-oob": { - "post": { - "operationId": "CreateRequest", + "/schemas/{schemaId}": { + "get": { + "operationId": "GetSchemaById", "responses": { "200": { - "description": "Ok", + "description": "Schema", "content": { "application/json": { - "schema": {} + "schema": {}, + "examples": { + "Example 1": { + "value": { + "ver": "1.0", + "id": "WgWxqztrNooG92RXvxSTWv:2:schema_name:1.0", + "name": "schema", + "version": "1.0", + "attrNames": [ + "string" + ], + "seqNo": 351936 + } + } + } } } }, - "500": { + "400": { "description": "", "content": { "application/json": { "schema": { "properties": { - "message": { + "reason": { "type": "string" } }, "required": [ - "message" + "reason" ], "type": "object" } } } - } - }, - "tags": [ - "Proofs" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CreateProofRequestOobOptions" - } - } - } - } - } - }, - "/proofs/{proofRecordId}/accept-request": { - "post": { - "operationId": "AcceptRequest", - "responses": { - "200": { - "description": "ProofRecord", + }, + "403": { + "description": "", "content": { "application/json": { - "schema": {}, - "examples": { - "Example 1": { - "value": { - "metadata": {}, - "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", - "createdAt": "2022-01-01T00:00:00.000Z", - "connectionId": "2aecf74c-3073-4f98-9acb-92415d096834", - "threadId": "0019d466-5eea-4269-8c40-031b4896c5b7", - "protocolVersion": "v1" + "schema": { + "properties": { + "reason": { + "type": "string" } - } + }, + "required": [ + "reason" + ], + "type": "object" } } } @@ -7624,73 +4919,54 @@ } } }, - "description": "Accept a presentation request as prover by sending an accept request message\nto the connection associated with the proof record.", + "description": "Retrieve schema by schema id", "tags": [ - "Proofs" + "Schemas" ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [ { "in": "path", - "name": "proofRecordId", + "name": "schemaId", "required": true, "schema": { - "type": "string" - } - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "properties": { - "comment": { - "type": "string" - }, - "filterByNonRevocationRequirements": { - "type": "boolean" - }, - "filterByPresentationPreview": { - "type": "boolean" - } - }, - "type": "object" - } + "$ref": "#/components/schemas/SchemaId" } } - } + ] } }, - "/proofs/{proofRecordId}/accept-presentation": { + "/schemas": { "post": { - "operationId": "AcceptPresentation", + "operationId": "CreateSchema", "responses": { "200": { - "description": "ProofRecord", + "description": "schema", "content": { "application/json": { "schema": {}, "examples": { "Example 1": { "value": { - "metadata": {}, - "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", - "createdAt": "2022-01-01T00:00:00.000Z", - "connectionId": "2aecf74c-3073-4f98-9acb-92415d096834", - "threadId": "0019d466-5eea-4269-8c40-031b4896c5b7", - "protocolVersion": "v1" + "ver": "1.0", + "id": "WgWxqztrNooG92RXvxSTWv:2:schema_name:1.0", + "name": "schema", + "version": "1.0", + "attrNames": [ + "string" + ], + "seqNo": 351936 } } } } } }, - "404": { + "400": { "description": "", "content": { "application/json": { @@ -7727,68 +5003,234 @@ } } }, - "description": "Accept a presentation as prover by sending an accept presentation message\nto the connection associated with the proof record.", + "description": "Creates a new schema and registers schema on ledger", "tags": [ - "Proofs" + "Schemas" ], "security": [ { - "apiKey": [] + "jwt": [] } ], - "parameters": [ - { - "in": "path", - "name": "proofRecordId", - "required": true, - "schema": { - "type": "string" + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "properties": { + "endorserDid": { + "type": "string" + }, + "endorse": { + "type": "boolean" + }, + "attributes": { + "items": { + "type": "string" + }, + "type": "array" + }, + "version": { + "$ref": "#/components/schemas/Version" + }, + "name": { + "type": "string" + }, + "issuerId": { + "type": "string" + } + }, + "required": [ + "attributes", + "version", + "name", + "issuerId" + ], + "type": "object" + } } } - ] + } } }, - "/proofs/{proofRecordId}/form-data": { + "/dids/{did}": { "get": { - "operationId": "ProofFormData", + "operationId": "GetDidRecordByDid", "responses": { "200": { - "description": "Ok", + "description": "DidResolutionResult", "content": { "application/json": { - "schema": {}, + "schema": { + "anyOf": [ + { + "properties": { + "importDid": {} + }, + "required": [ + "importDid" + ], + "type": "object" + }, + { + "properties": { + "importDid": {}, + "didDocumentMetadata": { + "$ref": "#/components/schemas/DIDDocumentMetadata" + }, + "didResolutionMetadata": { + "$ref": "#/components/schemas/DidResolutionMetadata" + }, + "didDocument": { + "$ref": "#/components/schemas/Record_string.any_" + } + }, + "required": [ + "didDocumentMetadata", + "didResolutionMetadata", + "didDocument" + ], + "type": "object" + } + ] + }, "examples": { "Example 1": { "value": { - "metadata": {}, - "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", - "createdAt": "2022-01-01T00:00:00.000Z", - "connectionId": "2aecf74c-3073-4f98-9acb-92415d096834", - "threadId": "0019d466-5eea-4269-8c40-031b4896c5b7", - "protocolVersion": "v1" + "didDocument": { + "@context": [ + "https://w3id.org/did/v1", + "https://w3id.org/security/suites/ed25519-2018/v1", + "https://w3id.org/security/suites/x25519-2019/v1" + ], + "id": "did:key:z6Mkk7yqnGF3YwTrLpqrW6PGsKci7dNqh1CjnvMbzrMerSeL", + "verificationMethod": [ + { + "id": "did:key:z6Mkk7yqnGF3YwTrLpqrW6PGsKci7dNqh1CjnvMbzrMerSeL#z6Mkk7yqnGF3YwTrLpqrW6PGsKci7dNqh1CjnvMbzrMerSeL", + "type": "Ed25519VerificationKey2018", + "controller": "did:key:z6Mkk7yqnGF3YwTrLpqrW6PGsKci7dNqh1CjnvMbzrMerSeL", + "publicKeyBase58": "6fioC1zcDPyPEL19pXRS2E4iJ46zH7xP6uSgAaPdwDrx" + } + ], + "authentication": [ + "did:key:z6Mkk7yqnGF3YwTrLpqrW6PGsKci7dNqh1CjnvMbzrMerSeL#z6Mkk7yqnGF3YwTrLpqrW6PGsKci7dNqh1CjnvMbzrMerSeL" + ], + "assertionMethod": [ + "did:key:z6Mkk7yqnGF3YwTrLpqrW6PGsKci7dNqh1CjnvMbzrMerSeL#z6Mkk7yqnGF3YwTrLpqrW6PGsKci7dNqh1CjnvMbzrMerSeL" + ], + "capabilityInvocation": [ + "did:key:z6Mkk7yqnGF3YwTrLpqrW6PGsKci7dNqh1CjnvMbzrMerSeL#z6Mkk7yqnGF3YwTrLpqrW6PGsKci7dNqh1CjnvMbzrMerSeL" + ], + "capabilityDelegation": [ + "did:key:z6Mkk7yqnGF3YwTrLpqrW6PGsKci7dNqh1CjnvMbzrMerSeL#z6Mkk7yqnGF3YwTrLpqrW6PGsKci7dNqh1CjnvMbzrMerSeL" + ], + "keyAgreement": [ + { + "id": "did:key:z6Mkk7yqnGF3YwTrLpqrW6PGsKci7dNqh1CjnvMbzrMerSeL#z6LSrdqo4M24WRDJj1h2hXxgtDTyzjjKCiyapYVgrhwZAySn", + "type": "X25519KeyAgreementKey2019", + "controller": "did:key:z6Mkk7yqnGF3YwTrLpqrW6PGsKci7dNqh1CjnvMbzrMerSeL", + "publicKeyBase58": "FxfdY3DCQxVZddKGAtSjZdFW9bCCW7oRwZn1NFJ2Tbg2" + } + ] + }, + "didDocumentMetadata": {}, + "didResolutionMetadata": { + "contentType": "application/did+ld+json" + } } } } } } + } + }, + "description": "Resolves did and returns did resolution result", + "tags": [ + "Dids" + ], + "security": [ + { + "jwt": [] + } + ], + "parameters": [ + { + "description": "Decentralized Identifier", + "in": "path", + "name": "did", + "required": true, + "schema": { + "$ref": "#/components/schemas/Did" + } + } + ] + } + }, + "/dids/write": { + "post": { + "operationId": "WriteDid", + "responses": { + "200": { + "description": "DidResolutionResult", + "content": { + "application/json": { + "schema": {} + } + } }, - "404": { + "500": { "description": "", "content": { "application/json": { "schema": { "properties": { - "reason": { + "message": { "type": "string" } }, "required": [ - "reason" + "message" ], "type": "object" } } } + } + }, + "description": "Did nym registration", + "tags": [ + "Dids" + ], + "security": [ + { + "jwt": [] + } + ], + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DidCreate" + } + } + } + } + } + }, + "/dids": { + "get": { + "operationId": "GetDids", + "responses": { + "200": { + "description": "Ok", + "content": { + "application/json": { + "schema": {} + } + } }, "500": { "description": "", @@ -7810,23 +5252,14 @@ } }, "tags": [ - "Proofs" + "Dids" ], "security": [ { - "apiKey": [] + "jwt": [] } ], - "parameters": [ - { - "in": "path", - "name": "proofRecordId", - "required": true, - "schema": { - "type": "string" - } - } - ] + "parameters": [] } }, "/transactions/endorse": { @@ -7883,7 +5316,7 @@ ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [], @@ -7935,7 +5368,7 @@ ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [], @@ -8005,7 +5438,7 @@ ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [], @@ -8071,7 +5504,7 @@ ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [ @@ -8125,7 +5558,7 @@ ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [] @@ -8151,7 +5584,7 @@ ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [ @@ -8245,7 +5678,7 @@ ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [ @@ -8339,7 +5772,7 @@ ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [], @@ -8434,7 +5867,7 @@ ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [], @@ -8511,7 +5944,7 @@ ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [], @@ -8563,7 +5996,7 @@ ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [], @@ -8658,7 +6091,7 @@ ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [], @@ -8753,7 +6186,7 @@ ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [], @@ -8848,7 +6281,7 @@ ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [], @@ -8864,247 +6297,19 @@ } } }, - "/polygon/create-keys": { - "post": { - "operationId": "CreateKeyPair", - "responses": { - "200": { - "description": "Secp256k1KeyPair", - "content": { - "application/json": { - "schema": { - "properties": { - "address": { - "type": "string" - }, - "publicKeyBase58": { - "type": "string" - }, - "privateKey": { - "type": "string" - } - }, - "required": [ - "address", - "publicKeyBase58", - "privateKey" - ], - "type": "object" - } - } - } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "description": "Create Secp256k1 key pair for polygon DID", - "tags": [ - "Polygon" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [] - } - }, - "/polygon/create-schema": { - "post": { - "operationId": "CreateSchema", - "responses": { - "200": { - "description": "Schema JSON", - "content": { - "application/json": { - "schema": {} - } - } - }, - "400": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "reason": { - "type": "string" - } - }, - "required": [ - "reason" - ], - "type": "object" - } - } - } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "description": "Create polygon based W3C schema", - "tags": [ - "Polygon" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "properties": { - "schema": { - "additionalProperties": false, - "type": "object" - }, - "schemaName": { - "type": "string" - }, - "did": { - "type": "string" - } - }, - "required": [ - "schema", - "schemaName", - "did" - ], - "type": "object" - } - } - } - } - } - }, - "/polygon/estimate-transaction": { + "/test-endpoint/multi-tenant/create-tenant": { "post": { - "operationId": "EstimateTransaction", - "responses": { - "200": { - "description": "Transaction Object", - "content": { - "application/json": { - "schema": {} - } - } - }, - "400": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "reason": { - "type": "string" - } - }, - "required": [ - "reason" - ], - "type": "object" - } - } - } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "description": "Estimate transaction", - "tags": [ - "Polygon" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "properties": { - "transaction": {}, - "operation": {} - }, - "required": [ - "transaction", - "operation" - ], - "type": "object" - } - } - } - } - } - }, - "/polygon/{did}/{schemaId}": { - "get": { - "operationId": "GetSchemaById", + "operationId": "CreateTenant", "responses": { "200": { - "description": "Schema Object", + "description": "Ok", "content": { "application/json": { "schema": {} } } }, - "401": { + "404": { "description": "", "content": { "application/json": { @@ -9141,38 +6346,32 @@ } } }, - "description": "Fetch schema details", "tags": [ - "Polygon" + "Multi Tenant" ], "security": [ { - "apiKey": [] + "jwt": [ + "multi-tenant" + ] } ], - "parameters": [ - { - "in": "path", - "name": "did", - "required": true, - "schema": { - "type": "string" - } - }, - { - "in": "path", - "name": "schemaId", - "required": true, - "schema": { - "type": "string" + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateTenantOptions" + } } } - ] + } } }, - "/test-endpoint/multi-tenant/create-tenant": { + "/test-endpoint/multi-tenant/get-token/{tenantId}": { "post": { - "operationId": "CreateTenant", + "operationId": "GetTenantToken", "responses": { "200": { "description": "Ok", @@ -9224,20 +6423,21 @@ ], "security": [ { - "jwt": [] + "jwt": [ + "multi-tenant" + ] } ], - "parameters": [], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CreateTenantOptions" - } + "parameters": [ + { + "in": "path", + "name": "tenantId", + "required": true, + "schema": { + "type": "string" } } - } + ] } }, "/test-endpoint/multi-tenant/{tenantId}": { @@ -9619,7 +6819,10 @@ "description": "OutOfBandRecord[]", "content": { "application/json": { - "schema": {}, + "schema": { + "items": {}, + "type": "array" + }, "examples": { "Example 1": { "value": [ @@ -9784,76 +6987,79 @@ ] } }, - "/question-answer": { - "get": { - "operationId": "GetQuestionAnswerRecords", + "/multi-tenancy/create-tenant": { + "post": { + "operationId": "CreateTenant", "responses": { "200": { - "description": "QuestionAnswerRecord[]", + "description": "Ok", + "content": { + "application/json": { + "schema": {} + } + } + }, + "404": { + "description": "", "content": { "application/json": { "schema": { - "items": { - "$ref": "#/components/schemas/Record_string.unknown_" + "properties": { + "reason": { + "type": "string" + } }, - "type": "array" + "required": [ + "reason" + ], + "type": "object" + } + } + } + }, + "500": { + "description": "", + "content": { + "application/json": { + "schema": { + "properties": { + "message": { + "type": "string" + } + }, + "required": [ + "message" + ], + "type": "object" } } } } }, - "description": "Retrieve question and answer records by query", "tags": [ - "Question Answer" + "MultiTenancy" ], "security": [ { - "apiKey": [] + "jwt": [] } ], - "parameters": [ - { - "description": "Connection identifier", - "in": "query", - "name": "connectionId", - "required": false, - "schema": { - "type": "string" - } - }, - { - "description": "Role of the question", - "in": "query", - "name": "role", - "required": false, - "schema": { - "$ref": "#/components/schemas/QuestionAnswerRole" - } - }, - { - "description": "State of the question", - "in": "query", - "name": "state", - "required": false, - "schema": { - "$ref": "#/components/schemas/QuestionAnswerState" - } - }, - { - "description": "Thread identifier", - "in": "query", - "name": "threadId", - "required": false, - "schema": { - "type": "string" + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateTenantOptions" + } } } - ] + } } }, - "/question-answer/question/{connectionId}": { - "post": { - "operationId": "SendQuestion", + "/multi-tenancy/{tenantId}": { + "get": { + "operationId": "GetTenantById", "responses": { "200": { "description": "Ok", @@ -9900,9 +7106,8 @@ } } }, - "description": "Send a question to a connection", "tags": [ - "Question Answer" + "MultiTenancy" ], "security": [ { @@ -9911,48 +7116,17 @@ ], "parameters": [ { - "description": "Connection identifier", "in": "path", - "name": "connectionId", + "name": "tenantId", "required": true, "schema": { - "$ref": "#/components/schemas/RecordId" - } - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "properties": { - "detail": { - "type": "string" - }, - "validResponses": { - "items": { - "$ref": "#/components/schemas/ValidResponse" - }, - "type": "array" - }, - "question": { - "type": "string" - } - }, - "required": [ - "validResponses", - "question" - ], - "type": "object" - } + "type": "string" } } - } - } - }, - "/question-answer/answer/{id}": { - "post": { - "operationId": "SendAnswer", + ] + }, + "delete": { + "operationId": "DeleteTenantById", "responses": { "200": { "description": "Ok", @@ -9999,44 +7173,32 @@ } } }, - "description": "Send a answer to question", "tags": [ - "Question Answer" + "MultiTenancy" ], "security": [ { - "apiKey": [] + "jwt": [] } ], "parameters": [ { - "description": "The id of the question answer record", "in": "path", - "name": "id", + "name": "tenantId", "required": true, "schema": { - "$ref": "#/components/schemas/RecordId" - } - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Record_response.string_" - } + "type": "string" } } - } + ] } }, - "/question-answer/{id}": { - "get": { - "operationId": "GetQuestionAnswerRecordById", + "/multi-tenancy/get-token/{tenantId}": { + "post": { + "operationId": "GetTenantToken", "responses": { "200": { - "description": "ConnectionRecord", + "description": "Ok", "content": { "application/json": { "schema": {} @@ -10060,24 +7222,43 @@ } } } + }, + "500": { + "description": "", + "content": { + "application/json": { + "schema": { + "properties": { + "message": { + "type": "string" + } + }, + "required": [ + "message" + ], + "type": "object" + } + } + } } }, - "description": "Retrieve question answer record by id", "tags": [ - "Question Answer" + "MultiTenancy" ], "security": [ { - "apiKey": [] + "jwt": [ + "multi-tenant" + ] } ], "parameters": [ { "in": "path", - "name": "id", + "name": "tenantId", "required": true, "schema": { - "$ref": "#/components/schemas/RecordId" + "type": "string" } } ] diff --git a/src/server.ts b/src/server.ts index 87958f19..18e00265 100644 --- a/src/server.ts +++ b/src/server.ts @@ -36,11 +36,7 @@ export const setupServer = async ( config: ServerConfig, apiKey?: string ) => { - // export const setupServer = async (agent: Agent, config: ServerConfig, apiKey?: string) => { - // let NewAgent: RestMultiTenantAgentModules | RestAgentModules - // container.register(NewAgent, newAgent) container.registerInstance(Agent, agent as Agent) - console.log('Reached here. This is Agent::::', agent) const app = config.app ?? express() if (config.cors) app.use(cors()) @@ -81,12 +77,11 @@ export const setupServer = async ( app.use(securityMiddleware.use) RegisterRoutes(app) - // app.use(async (req, _, next) => { - // // End tenant session if active - // console.log('Ended tenant session using app.use') - // await endTenantSessionIfActive(req) - // next() - // }) + app.use(async (req, _, next) => { + // End tenant session if active + await endTenantSessionIfActive(req) + next() + }) app.use((req, res, next) => { if (req.url == '/') { @@ -103,8 +98,7 @@ export const setupServer = async ( next: NextFunction ): Promise { // End tenant session if active - // console.log('Ended tenant session in [errorHandler]') - // await endTenantSessionIfActive(req) + await endTenantSessionIfActive(req) if (err instanceof ValidateError) { agent.config.logger.warn(`Caught Validation Error for ${req.path}:`, err.fields) @@ -147,12 +141,12 @@ export const setupServer = async ( return app } -// async function endTenantSessionIfActive(request: ExRequest) { -// if ('agent' in request) { -// const agent = request?.agent -// if (agent instanceof TenantAgent) { -// agent.config.logger.debug('Ending tenant session') -// await agent.endSession() -// } -// } -// } +async function endTenantSessionIfActive(request: ExRequest) { + if ('agent' in request) { + const agent = request?.agent + if (agent instanceof TenantAgent) { + agent.config.logger.debug('Ending tenant session') + await agent.endSession() + } + } +} From 1dc1c56dd9258f653f286b8279732d6d8dbfdf56 Mon Sep 17 00:00:00 2001 From: Krishna Date: Mon, 6 May 2024 18:48:17 +0530 Subject: [PATCH 13/16] fix: scopes and error handling Signed-off-by: Krishna --- src/authentication.ts | 47 +++++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/src/authentication.ts b/src/authentication.ts index 3e10109c..1a86e3d2 100644 --- a/src/authentication.ts +++ b/src/authentication.ts @@ -17,33 +17,18 @@ let dynamicApiKey: string = 'api_key' // Initialize with a default value export async function expressAuthentication( request: Request, securityName: string, - secMethod?: { [key: string]: any }, - scopes?: string + scopes?: string[] + // secMethod?: string // eslint-disable-next-line @typescript-eslint/no-unused-vars // agent?: Agent ) { const logger = new TsLogger(LogLevel.info) const agent = container.resolve(Agent) - logger.info(`secMethod::: ${JSON.stringify(secMethod)}`) - logger.info(`securityName::: ${JSON.stringify(securityName)}`) - logger.info(`scopes::: ${JSON.stringify(scopes)}`) + logger.info(`securityName::: ${securityName}`) + logger.info(`scopes::: ${scopes}`) - const routePath = request.path - const requestMethod = request.method - - // List of paths for which authentication should be skipped - const pathsToSkipAuthentication = [ - // { path: '/url/', method: 'GET' }, - { path: '/multi-tenancy/url/', method: 'GET' }, - // { path: '/agent', method: 'GET' }, - ] - - const skipAuthentication = pathsToSkipAuthentication.some( - ({ path, method }) => routePath.includes(path) && requestMethod === method - ) - - if (skipAuthentication || secMethod?.includes('skip')) { + if (scopes && scopes?.includes('skip')) { // Skip authentication for this route or controller // for skipped authentication there are two ways to handle request['agent'] = agent @@ -57,8 +42,6 @@ export async function expressAuthentication( return Promise.reject(new StatusException(ErrorMessages.Unauthorized, 401)) } - // add additional logic to get the token from wallet for validating the passed - if (securityName === 'apiKey') { // Auth: For BW/Dedicated agent to GET their token if (apiKeyHeader) { @@ -87,7 +70,8 @@ export async function expressAuthentication( } if (role === AgentRole.RestTenantAgent) { // Logic if the token is of tenant agent - if (reqPath.includes('/multi-tenant/')) { + if (reqPath.includes('/multi-tenancy/')) { + // if (scopes?.includes('multi-tenant/')) { // return false //'Tenants cannot manage tenants' logger.debug('Tenants cannot manage tenants') return Promise.reject(new StatusException(ErrorMessages.Unauthorized, 401)) @@ -105,6 +89,8 @@ export async function expressAuthentication( } const verified = await verifyToken(tenantAgent, token) + // With the below implementation, secretkey will be stored and received from BaseWallet + // const verified = await verifyToken(agent, token) // Failed to verify token if (!verified) { @@ -122,10 +108,11 @@ export async function expressAuthentication( const verified = await verifyToken(agent!, token) // Base wallet cant access any endpoints apart from multi-tenant endpoint - if (!reqPath.includes('/multi-tenant/') && !reqPath.includes('/multi-tenancy/')) { - logger.error('Basewallet can only manage tenants and can`t perform other operations') - return Promise.reject(new StatusException(ErrorMessages.Unauthorized, 401)) - } + // To do: Implement the authorization part using scopes, instead of url + // if (!reqPath.includes('/multi-tenancy/')) { + // logger.error('Basewallet can only manage tenants and can`t perform other operations') + // return Promise.reject(new StatusException(ErrorMessages.Unauthorized, 401)) + // } // if (!scopes?.includes('multi-tenant')) { // logger.error('Basewallet can only manage tenants') @@ -149,10 +136,12 @@ export async function expressAuthentication( } else { // Auth: dedicated agent - if (reqPath.includes('/multi-tenant/')) return false + if (reqPath.includes('/multi-tenancy/')) + return Promise.reject(new StatusException(ErrorMessages.Unauthorized, 401)) const verified = await verifyToken(agent!, token) - if (!verified) return false + if (!verified) return Promise.reject(new StatusException(ErrorMessages.Unauthorized, 401)) + //return false request['agent'] = agent return true From 2d4a473d719b176af3b4218f25ef603a968a9ac5 Mon Sep 17 00:00:00 2001 From: Krishna Date: Mon, 6 May 2024 18:48:42 +0530 Subject: [PATCH 14/16] fix: scopes Signed-off-by: Krishna --- src/controllers/connections/ConnectionController.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/controllers/connections/ConnectionController.ts b/src/controllers/connections/ConnectionController.ts index 15f154e6..fadad179 100644 --- a/src/controllers/connections/ConnectionController.ts +++ b/src/controllers/connections/ConnectionController.ts @@ -183,6 +183,7 @@ export class ConnectionController extends Controller { } } + @Security('jwt', ['skip']) @Get('/url/:invitationId') public async getInvitation( @Request() request: Req, From 70b380288dec1817bd65b9d0b3d100158004b3c1 Mon Sep 17 00:00:00 2001 From: Krishna Date: Tue, 7 May 2024 12:30:47 +0530 Subject: [PATCH 15/16] fix: add/remove comments Signed-off-by: Krishna --- src/authentication.ts | 35 +-- .../additional-endpoint/context.Controller.ts | 277 ------------------ .../multitenant.Controller.ts | 159 ---------- src/controllers/agent/AgentController.ts | 59 ---- .../multi-tenancy/MultiTenancyController.ts | 30 +- 5 files changed, 30 insertions(+), 530 deletions(-) delete mode 100644 src/controllers/additional-endpoint/context.Controller.ts delete mode 100644 src/controllers/additional-endpoint/multitenant.Controller.ts diff --git a/src/authentication.ts b/src/authentication.ts index 1a86e3d2..68963ea4 100644 --- a/src/authentication.ts +++ b/src/authentication.ts @@ -14,14 +14,7 @@ import { TsLogger } from './utils/logger' let dynamicApiKey: string = 'api_key' // Initialize with a default value -export async function expressAuthentication( - request: Request, - securityName: string, - scopes?: string[] - // secMethod?: string - // eslint-disable-next-line @typescript-eslint/no-unused-vars - // agent?: Agent -) { +export async function expressAuthentication(request: Request, securityName: string, scopes?: string[]) { const logger = new TsLogger(LogLevel.info) const agent = container.resolve(Agent) @@ -30,7 +23,6 @@ export async function expressAuthentication( if (scopes && scopes?.includes('skip')) { // Skip authentication for this route or controller - // for skipped authentication there are two ways to handle request['agent'] = agent return true } @@ -71,8 +63,8 @@ export async function expressAuthentication( if (role === AgentRole.RestTenantAgent) { // Logic if the token is of tenant agent if (reqPath.includes('/multi-tenancy/')) { - // if (scopes?.includes('multi-tenant/')) { - // return false //'Tenants cannot manage tenants' + // Note: Include the below logic for path detection instead of url + // if (scopes && scopes?.includes('multi-tenant')) { logger.debug('Tenants cannot manage tenants') return Promise.reject(new StatusException(ErrorMessages.Unauthorized, 401)) } else { @@ -89,7 +81,7 @@ export async function expressAuthentication( } const verified = await verifyToken(tenantAgent, token) - // With the below implementation, secretkey will be stored and received from BaseWallet + // Note: logic to store generate token for tenant using BW's secertKey // const verified = await verifyToken(agent, token) // Failed to verify token @@ -108,12 +100,12 @@ export async function expressAuthentication( const verified = await verifyToken(agent!, token) // Base wallet cant access any endpoints apart from multi-tenant endpoint - // To do: Implement the authorization part using scopes, instead of url // if (!reqPath.includes('/multi-tenancy/')) { // logger.error('Basewallet can only manage tenants and can`t perform other operations') // return Promise.reject(new StatusException(ErrorMessages.Unauthorized, 401)) // } + // Note: Implement the authorization part using scopes(below), instead of url(above) // if (!scopes?.includes('multi-tenant')) { // logger.error('Basewallet can only manage tenants') // return Promise.reject(new StatusException(ErrorMessages.Unauthorized, 401)) @@ -150,15 +142,6 @@ export async function expressAuthentication( } // return false return Promise.reject(new StatusException(ErrorMessages.Unauthorized, 401)) - // } catch (error) { - // const logger = new TsLogger(LogLevel.error) - // if (error instanceof Error) { - // console.log('log 8.0') - // logger.error('Error in Authentication', error) - // response?.status(401) - // } - // return false - // } } async function verifyToken(agent: Agent | TenantAgent, token: string): Promise { @@ -179,14 +162,6 @@ async function getSecretKey( return secretKey } -// async function getTenantAgent( -// agent: Agent, -// tenantId: string -// ): Promise> { -// const tenantAgent = await agent.modules.tenants.getTenantAgent({ tenantId }) -// return tenantAgent -// } - export function setDynamicApiKey(newApiKey: string) { dynamicApiKey = newApiKey } diff --git a/src/controllers/additional-endpoint/context.Controller.ts b/src/controllers/additional-endpoint/context.Controller.ts deleted file mode 100644 index bcf67cf2..00000000 --- a/src/controllers/additional-endpoint/context.Controller.ts +++ /dev/null @@ -1,277 +0,0 @@ -import type { OutOfBandInvitationProps, OutOfBandRecordWithInvitationProps } from '../examples' -// eslint-disable-next-line import/order -import type { RecipientKeyOption } from '../types' // AgentMessageType, -// import type { ConnectionRecordProps, CreateLegacyInvitationConfig, Routing } from '@aries-framework/core' - -import type { ConnectionRecordProps, CreateLegacyInvitationConfig, Routing } from '@aries-framework/core' - -import { Key, KeyType } from '@aries-framework/core' -import { Request as Req } from 'express' -import { injectable } from 'tsyringe' - -// import { ConnectionRecordExample, outOfBandInvitationExample, outOfBandRecordExample, RecordId } from '../examples' -// import { -// AcceptInvitationConfig, -// ReceiveInvitationByUrlProps, -// ReceiveInvitationProps, -// CreateInvitationOptions, -// } from '../types' - -import { ConnectionRecordExample, outOfBandInvitationExample, outOfBandRecordExample, RecordId } from '../examples' -import { ReceiveInvitationByUrlProps } from '../types' - -import { - Body, - Controller, - // Delete, - Example, - Post, - // Query, - Res, - Route, - Tags, - TsoaResponse, - Security, - Request, - Get, - Path, - Query, -} from 'tsoa' - -@Tags('Test Connection') -// @Security('authorization') -@Security('jwt') -@Route('/test-endpoint') -@injectable() -export class ContextController extends Controller { - // private agent: Agent - // public constructor(private readonly agent: Agent) { - // super() - // this.agent = agent - // } - // @Get('/get-token') - // public async getAgentToken(): Promise { - // const agentDetails = await this.agent.genericRecords.getAll() - // return agentDetails - // } - // This is multi-tenant invitation endpoint - // @Security('apiKey') - // @Post('/create-legacy-invitation/:tenantId') - // public async createLegacyInvitation( - // @Res() internalServerError: TsoaResponse<500, { message: string }>, - // @Path('tenantId') tenantId: string, - // @Body() - // config?: Omit & RecipientKeyOption // props removed because of issues with serialization - // ) { - // let getInvitation - // try { - // let routing: Routing - // await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - // if (config?.recipientKey) { - // routing = { - // endpoints: tenantAgent.config.endpoints, - // routingKeys: [], - // recipientKey: Key.fromPublicKeyBase58(config.recipientKey, KeyType.Ed25519), - // mediatorId: undefined, - // } - // } else { - // routing = await tenantAgent.mediationRecipient.getRouting({}) - // } - // const { outOfBandRecord, invitation } = await tenantAgent.oob.createLegacyInvitation({ ...config, routing }) - // getInvitation = { - // invitationUrl: invitation.toUrl({ - // domain: this.agent.config.endpoints[0], - // useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, - // }), - // invitation: invitation.toJSON({ - // useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, - // }), - // outOfBandRecord: outOfBandRecord.toJSON(), - // ...(config?.recipientKey ? {} : { recipientKey: routing.recipientKey.publicKeyBase58 }), - // } - // }) - // return getInvitation - // } catch (error) { - // return internalServerError(500, { message: `something went wrong: ${error}` }) - // } - // } - // This is dedicated agent invitation endpoint - /** - * Creates an outbound out-of-band record in the same way how `createInvitation` method does it, - * but it also converts out-of-band invitation message to an "legacy" invitation message defined - * in RFC 0160: Connection Protocol and returns it together with out-of-band record. - * - * @param config configuration of how a invitation should be created - * @returns out-of-band record and invitation - */ - // @Example<{ invitation: OutOfBandInvitationProps; outOfBandRecord: OutOfBandRecordWithInvitationProps }>({ - // invitation: outOfBandInvitationExample, - // outOfBandRecord: outOfBandRecordExample, - // }) - // @Post('/create-legacy-invitation') - // public async createLegacyInvitation( - // @Res() internalServerError: TsoaResponse<500, { message: string }>, - // @Body() config?: Omit & RecipientKeyOption - // ) { - // try { - // let routing: Routing - // if (config?.recipientKey) { - // routing = { - // endpoints: this.agent.config.endpoints, - // routingKeys: [], - // recipientKey: Key.fromPublicKeyBase58(config.recipientKey, KeyType.Ed25519), - // mediatorId: undefined, - // } - // } else { - // routing = await this.agent.mediationRecipient.getRouting({}) - // } - // const { outOfBandRecord, invitation } = await this.agent.oob.createLegacyInvitation({ - // ...config, - // routing, - // }) - // return { - // invitationUrl: invitation.toUrl({ - // domain: this.agent.config.endpoints[0], - // useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, - // }), - // invitation: invitation.toJSON({ - // useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed, - // }), - // outOfBandRecord: outOfBandRecord.toJSON(), - // ...(config?.recipientKey ? {} : { recipientKey: routing.recipientKey.publicKeyBase58 }), - // } - // } catch (error) { - // return internalServerError(500, { message: `something went wrong: ${error}` }) - // } - // } - // Create a common function that calls createLegacyInvitation - /** - * Creates an outbound out-of-band record in the same way how `createInvitation` method does it, - * but it also converts out-of-band invitation message to an "legacy" invitation message defined - * in RFC 0160: Connection Protocol and returns it together with out-of-band record. - * - * @param config configuration of how a invitation should be created - * @returns out-of-band record and invitation - */ - @Example<{ invitation: OutOfBandInvitationProps; outOfBandRecord: OutOfBandRecordWithInvitationProps }>({ - invitation: outOfBandInvitationExample, - outOfBandRecord: outOfBandRecordExample, - }) - @Post('/create-legacy-invitation') - public async createLegacyInvitation( - // Request implementation - @Request() request: Req, - @Res() internalServerError: TsoaResponse<500, { message: string }>, - @Body() config?: Omit & RecipientKeyOption - ) { - try { - let routing: Routing - if (config?.recipientKey) { - routing = { - endpoints: request.agent.config.endpoints, - routingKeys: [], - recipientKey: Key.fromPublicKeyBase58(config.recipientKey, KeyType.Ed25519), - mediatorId: undefined, - } - } else { - routing = await request.agent.mediationRecipient.getRouting({}) - } - - const { outOfBandRecord, invitation } = await request.agent.oob.createLegacyInvitation({ - ...config, - routing, - }) - - return { - invitationUrl: invitation.toUrl({ - domain: request.agent.config.endpoints[0], - useDidSovPrefixWhereAllowed: request.agent.config.useDidSovPrefixWhereAllowed, - }), - invitation: invitation.toJSON({ - useDidSovPrefixWhereAllowed: request.agent.config.useDidSovPrefixWhereAllowed, - }), - outOfBandRecord: outOfBandRecord.toJSON(), - ...(config?.recipientKey ? {} : { recipientKey: routing.recipientKey.publicKeyBase58 }), - } - } catch (error) { - return internalServerError(500, { message: `something went wrong: ${error}` }) - } - } - - /** - * Creates inbound out-of-band record and assigns out-of-band invitation message to it if the - * message is valid. - * - * @param invitationUrl invitation url - * @param config config for handling of invitation - * @returns out-of-band record and connection record if one has been created. - */ - @Example<{ outOfBandRecord: OutOfBandRecordWithInvitationProps; connectionRecord: ConnectionRecordProps }>({ - outOfBandRecord: outOfBandRecordExample, - connectionRecord: ConnectionRecordExample, - }) - @Post('/receive-invitation-url') - public async receiveInvitationFromUrl( - // Request implementation - @Request() request: Req, - @Body() invitationRequest: ReceiveInvitationByUrlProps, - @Res() internalServerError: TsoaResponse<500, { message: string }> - ) { - const { invitationUrl, ...config } = invitationRequest - - try { - const linkSecretIds = await request.agent.modules.anoncreds.getLinkSecretIds() - if (linkSecretIds.length === 0) { - await request.agent.modules.anoncreds.createLinkSecret() - } - const { outOfBandRecord, connectionRecord } = await request.agent.oob.receiveInvitationFromUrl( - invitationUrl, - config - ) - return { - outOfBandRecord: outOfBandRecord.toJSON(), - connectionRecord: connectionRecord?.toJSON(), - } - } catch (error) { - return internalServerError(500, { message: `something went wrong: ${error}` }) - } - } - - /** - * Retrieve all out of band records - * @param invitationId invitation identifier - * @returns OutOfBandRecord[] - */ - @Example([outOfBandRecordExample]) - @Get() - public async getAllOutOfBandRecords(@Request() request: Req, @Query('invitationId') invitationId?: RecordId) { - let outOfBandRecords = await request.agent.oob.getAll() - - if (invitationId) - outOfBandRecords = outOfBandRecords.filter( - (o: { outOfBandInvitation: { id: string } }) => o.outOfBandInvitation.id === invitationId - ) - - return outOfBandRecords.map((c: { toJSON: () => any }) => c.toJSON()) - } - - /** - * Retrieve an out of band record by id - * @param recordId record identifier - * @returns OutOfBandRecord - */ - @Example(outOfBandRecordExample) - @Get('/:outOfBandId') - public async getOutOfBandRecordById( - @Request() request: Req, - @Path('outOfBandId') outOfBandId: RecordId, - @Res() notFoundError: TsoaResponse<404, { reason: string }> - ) { - const outOfBandRecord = await request.agent.oob.findById(outOfBandId) - - if (!outOfBandRecord) - return notFoundError(404, { reason: `Out of band record with id "${outOfBandId}" not found.` }) - - return outOfBandRecord.toJSON() - } -} diff --git a/src/controllers/additional-endpoint/multitenant.Controller.ts b/src/controllers/additional-endpoint/multitenant.Controller.ts deleted file mode 100644 index ceca8acc..00000000 --- a/src/controllers/additional-endpoint/multitenant.Controller.ts +++ /dev/null @@ -1,159 +0,0 @@ -import type { RestMultiTenantAgentModules } from '../../cliAgent' -import type { Agent } from '@aries-framework/core' -import type { TenantRecord } from '@aries-framework/tenants' - -import { JsonTransformer, RecordNotFoundError, injectable } from '@aries-framework/core' -import { Request as Req } from 'express' -import jwt from 'jsonwebtoken' - -import { AgentRole } from '../../enums/enum' -import { generateSecretKey } from '../../utils/common.service' -import { CreateTenantOptions } from '../types' - -// import { AgentRole } from 'src/enums/enum' -import { Body, Controller, Get, Path, Post, Request, Res, Route, Security, Tags, TsoaResponse } from 'tsoa' - -@Tags('Multi Tenant') -@Security('jwt') -@Route('/test-endpoint/multi-tenant') -// @Security('NewAuth') -@injectable() -export class MultiTenantController extends Controller { - // @Security('RootAuthorization') - @Security('jwt', ['multi-tenant']) - @Post('/create-tenant') - public async createTenant( - @Request() request: Req, - @Body() createTenantOptions: CreateTenantOptions, - @Res() notFoundError: TsoaResponse<404, { reason: string }>, - @Res() internalServerError: TsoaResponse<500, { message: string }> - ) { - const { config } = createTenantOptions - try { - const agent = request.agent as unknown as Agent - const tenantRecord: TenantRecord = await agent.modules.tenants?.createTenant({ config }) - const token = await this.createToken(agent, tenantRecord.id) - const withToken = { token, ...tenantRecord } - return withToken - } catch (error) { - if (error instanceof RecordNotFoundError) { - return notFoundError(404, { - reason: `Tenant not created`, - }) - } - - return internalServerError(500, { message: `Something went wrong: ${error}` }) - } - } - - @Security('jwt', ['multi-tenant']) - @Post('/get-token/:tenantId') - public async getTenantToken( - @Request() request: Req, - @Path('tenantId') tenantId: string, - @Res() notFoundError: TsoaResponse<404, { reason: string }>, - @Res() internalServerError: TsoaResponse<500, { message: string }> - ) { - try { - const agent = request.agent as unknown as Agent - let secretKey - await agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - const genericRecord = await tenantAgent.genericRecords.getAll() - const records = genericRecord.find((record) => record?.content?.secretKey !== undefined) - secretKey = records?.content.secretKey as string - }) - - if (!secretKey) { - throw new RecordNotFoundError('secretKey does not exist in wallet', { recordType: 'debug', cause: undefined }) - } - - const token = await this.createToken(agent, tenantId, secretKey) - - return { token: token } - } catch (error) { - if (error instanceof RecordNotFoundError) { - return notFoundError(404, { - reason: `SecretKey not found`, - }) - } - - return internalServerError(500, { message: `Something went wrong: ${error}` }) - } - } - - @Security('apiKey') - @Get(':tenantId') - public async getTenantById( - @Request() request: Req, - @Path('tenantId') tenantId: string, - @Res() notFoundError: TsoaResponse<404, { reason: string }>, - @Res() internalServerError: TsoaResponse<500, { message: string }> - ) { - try { - const agent = request.agent as unknown as Agent - const getTenant = await agent.modules.tenants.getTenantById(tenantId) - return JsonTransformer.toJSON(getTenant) - } catch (error) { - if (error instanceof RecordNotFoundError) { - return notFoundError(404, { - reason: `Tenant with id: ${tenantId} not found.`, - }) - } - return internalServerError(500, { message: `Something went wrong: ${error}` }) - } - } - - @Security('jwt') - @Post('/connection-invitation/') - public async createInvitation( - @Request() request: Req, - @Res() notFoundError: TsoaResponse<404, { reason: string }>, - @Res() internalServerError: TsoaResponse<500, { message: string }> - ) { - try { - const outOfBandRecord = await request.agent.oob.createInvitation() - return outOfBandRecord - } catch (error) { - if (error instanceof RecordNotFoundError) { - return notFoundError(404, { - reason: `Tenant not found.`, - }) - } - return internalServerError(500, { message: `Something went wrong: ${error}` }) - } - } - - private async createToken(agent: Agent, tenantId: string, secretKey?: string) { - let key: string - if (!secretKey) { - key = await generateSecretKey() - await agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - tenantAgent.genericRecords.save({ - content: { - secretKey: key, - }, - }) - }) - } else { - key = secretKey - } - const token = jwt.sign({ role: AgentRole.RestTenantAgent, tenantId }, key) - return token - } - - private async saveTokenAndSecretKey( - agent: Agent, - token: string, - secretKey: string, - tenantId: string - ) { - await agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => { - tenantAgent.genericRecords.save({ - content: { - secretKey: secretKey, - token, - }, - }) - }) - } -} diff --git a/src/controllers/agent/AgentController.ts b/src/controllers/agent/AgentController.ts index 5d118be7..70fe4fd6 100644 --- a/src/controllers/agent/AgentController.ts +++ b/src/controllers/agent/AgentController.ts @@ -41,14 +41,6 @@ export class AgentController extends Controller { @Post('/token') @Security('apiKey') public async getAgentToken(@Request() request: Req): Promise { - // const details = await request.agent.genericRecords.getAll() - // const genericRecord = await request.agent.genericRecords.getAll() - // console.log('genericRecord:::::', genericRecord) - // const recordWithToken = genericRecord.find((record) => record?.content?.token !== undefined) - // const token = recordWithToken?.content.token as string - // return { - // token: token, - // } let token const genericRecords = await request.agent.genericRecords.getAll() const secretKeyInfo = genericRecords.find((record) => record?.content?.secretKey !== undefined) @@ -56,57 +48,6 @@ export class AgentController extends Controller { throw new Error('secretKeyInfo not found') } const secretKey = secretKeyInfo.content.secretKey as string - // const recordsWithToken = genericRecord.some((record) => record?.content?.token) - // const recordWithToken = genericRecords.find((record) => record?.content?.token !== undefined) - // const token = recordWithToken?.content.token as string - // if (!genericRecords.length || !recordWithToken) { - // // Call the async function - - // // Already get the secretKey from the genericRecords - - // // Check if the secretKey already exist in the genericRecords - - // // if already exist - then don't generate the secret key again - // // Check if the JWT token already available in genericRecords - if yes, and also don't generate the JWT token - // // instead use the existin JWT token - // // if JWT token is not found, create/generate a new token and save in genericRecords - // // next time, the same token should be used - instead of creating a new token on every restart event of the agent - - // // if already exist - then don't generate the secret key again - // // Check if the JWT token already available in genericRecords - if yes, and also don't generate the JWT token - // // instead use the existin JWT token - // // if JWT token is not found, create/generate a new token and save in genericRecords - // // next time, the same token should be used - instead of creating a new token on every restart event of the agent - - // // Krish: Should add agent role and tenant id in case of tenants - // // token = jwt.sign({ agentInfo: 'agentInfo' }, secretKeyInfo) - - // // agent role set for dedicated agent and base-wallet respectively - // if (!('tenants' in this.agent.modules)) { - // token = jwt.sign({ role: AgentRole.RestRootAgent }, secretKey) - // } else { - // token = jwt.sign({ role: AgentRole.RestRootAgentWithTenants }, secretKey) - // } - - // // Krish: there should be no need to store the token if it is a refresh token. It's okay to save it for now and return it in the additional endpoint - // console.log('--------------if---------------', token) - // await this.agent.genericRecords.save({ - // content: { - // // apiKey, - // // secretKey: secretKeyInfo, - // token, - // }, - // }) - // } else { - // // const recordWithToken = genericRecords.find((record) => record?.content?.token !== undefined) - // if (!('tenants' in this.agent.modules)) { - // token = jwt.sign({ role: AgentRole.RestRootAgent }, secretKey) - // } else { - // token = jwt.sign({ role: AgentRole.RestRootAgentWithTenants }, secretKey) - // } - // token = recordWithToken?.content.token as string - // console.log('--------------else---------------', token) - // } if (!('tenants' in request.agent.modules)) { token = jwt.sign({ role: AgentRole.RestRootAgent }, secretKey) } else { diff --git a/src/controllers/multi-tenancy/MultiTenancyController.ts b/src/controllers/multi-tenancy/MultiTenancyController.ts index 3aec4d7c..ba51dbd7 100644 --- a/src/controllers/multi-tenancy/MultiTenancyController.ts +++ b/src/controllers/multi-tenancy/MultiTenancyController.ts @@ -19,7 +19,7 @@ import { Body, Controller, Delete, Post, Res, Route, Tags, TsoaResponse, Path, S export class MultiTenancyController extends Controller { //create wallet // @Security('apiKey') - @Security('jwt') + @Security('jwt', ['multi-tenant']) @Post('/create-tenant') public async createTenant( @Request() request: Req, @@ -31,7 +31,11 @@ export class MultiTenancyController extends Controller { try { const agent = request.agent as Agent const tenantRecord: TenantRecord = await agent.modules.tenants.createTenant({ config }) - return tenantRecord + // Note: logic to store generate token for tenant using BW's secertKey + // Here no need to change the logic, here only change the logic in 'createToken' + const token = await this.createToken(agent, tenantRecord.id) + const withToken = { token, ...tenantRecord } + return withToken } catch (error) { if (error instanceof RecordNotFoundError) { return notFoundError(404, { @@ -43,7 +47,8 @@ export class MultiTenancyController extends Controller { } } - @Security('apiKey') + // @Security('apiKey') + @Security('jwt', ['multi-tenant']) @Get(':tenantId') public async getTenantById( @Request() request: Req, @@ -65,6 +70,7 @@ export class MultiTenancyController extends Controller { } } + // @Security('apiKey') @Security('jwt', ['multi-tenant']) @Post('/get-token/:tenantId') public async getTenantToken( @@ -82,8 +88,13 @@ export class MultiTenancyController extends Controller { secretKey = records?.content.secretKey as string }) + // Note: logic to store generate token for tenant using BW's secertKey + // const genericRecord = await agent.genericRecords.getAll() + // const records = genericRecord.find((record) => record?.content?.secretKey !== undefined) + // const secretKey = records?.content.secretKey as string + if (!secretKey) { - throw new RecordNotFoundError('secretKey does not exist in wallet', { recordType: 'debug', cause: undefined }) + throw new Error('secretKey does not exist in wallet') } const token = await this.createToken(agent, tenantId, secretKey) @@ -1647,7 +1658,7 @@ export class MultiTenancyController extends Controller { // } // @Security('apiKey') - @Security('jwt') + @Security('jwt', ['multi-tenant']) @Delete(':tenantId') public async deleteTenantById( @Request() request: Req, @@ -1898,6 +1909,15 @@ export class MultiTenancyController extends Controller { }, }) }) + + // Note: logic to store generate token for tenant using BW's secertKey + // const genericRecord = await agent.genericRecords.getAll() + // const recordWithToken = genericRecord.find((record) => record?.content?.secretKey !== undefined) + // const key = recordWithToken?.content.secretKey as string + + if (!key) { + throw new Error('SecretKey does not exist for basewallet') + } } else { key = secretKey } From f189e0ba7eb037d63f37d372798a94f79d6f337b Mon Sep 17 00:00:00 2001 From: Krishna Date: Tue, 7 May 2024 12:33:23 +0530 Subject: [PATCH 16/16] fix: add routes Signed-off-by: Krishna --- src/routes/routes.ts | 277 +--------------- src/routes/swagger.json | 718 ++-------------------------------------- 2 files changed, 24 insertions(+), 971 deletions(-) diff --git a/src/routes/routes.ts b/src/routes/routes.ts index f948d17d..e503c38e 100644 --- a/src/routes/routes.ts +++ b/src/routes/routes.ts @@ -27,10 +27,6 @@ import { EndorserTransactionController } from './../controllers/endorser-transac // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa import { CredentialController } from './../controllers/credentials/CredentialController'; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa -import { MultiTenantController } from './../controllers/additional-endpoint/multitenant.Controller'; -// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa -import { ContextController } from './../controllers/additional-endpoint/context.Controller'; -// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa import { MultiTenancyController } from './../controllers/multi-tenancy/MultiTenancyController'; import { expressAuthentication } from './../authentication'; // @ts-ignore - no great way to install types from subpackage @@ -1947,6 +1943,7 @@ export function RegisterRoutes(app: Router) { }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.get('/url/:invitationId', + authenticateMiddleware([{"jwt":["skip"]}]), ...(fetchMiddlewares(ConnectionController)), ...(fetchMiddlewares(ConnectionController.prototype.getInvitation)), @@ -2683,274 +2680,8 @@ export function RegisterRoutes(app: Router) { } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/test-endpoint/multi-tenant/create-tenant', - authenticateMiddleware([{"jwt":["multi-tenant"]}]), - ...(fetchMiddlewares(MultiTenantController)), - ...(fetchMiddlewares(MultiTenantController.prototype.createTenant)), - - async function MultiTenantController_createTenant(request: any, response: any, next: any) { - const args = { - request: {"in":"request","name":"request","required":true,"dataType":"object"}, - createTenantOptions: {"in":"body","name":"createTenantOptions","required":true,"ref":"CreateTenantOptions"}, - notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(MultiTenantController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.createTenant.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/test-endpoint/multi-tenant/get-token/:tenantId', - authenticateMiddleware([{"jwt":["multi-tenant"]}]), - ...(fetchMiddlewares(MultiTenantController)), - ...(fetchMiddlewares(MultiTenantController.prototype.getTenantToken)), - - async function MultiTenantController_getTenantToken(request: any, response: any, next: any) { - const args = { - request: {"in":"request","name":"request","required":true,"dataType":"object"}, - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, - notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(MultiTenantController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.getTenantToken.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/test-endpoint/multi-tenant/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), - ...(fetchMiddlewares(MultiTenantController)), - ...(fetchMiddlewares(MultiTenantController.prototype.getTenantById)), - - async function MultiTenantController_getTenantById(request: any, response: any, next: any) { - const args = { - request: {"in":"request","name":"request","required":true,"dataType":"object"}, - tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, - notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(MultiTenantController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.getTenantById.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/test-endpoint/multi-tenant/connection-invitation', - authenticateMiddleware([{"jwt":[]}]), - ...(fetchMiddlewares(MultiTenantController)), - ...(fetchMiddlewares(MultiTenantController.prototype.createInvitation)), - - async function MultiTenantController_createInvitation(request: any, response: any, next: any) { - const args = { - request: {"in":"request","name":"request","required":true,"dataType":"object"}, - notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(MultiTenantController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.createInvitation.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/test-endpoint/create-legacy-invitation', - authenticateMiddleware([{"jwt":[]}]), - ...(fetchMiddlewares(ContextController)), - ...(fetchMiddlewares(ContextController.prototype.createLegacyInvitation)), - - async function ContextController_createLegacyInvitation(request: any, response: any, next: any) { - const args = { - request: {"in":"request","name":"request","required":true,"dataType":"object"}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - config: {"in":"body","name":"config","dataType":"intersection","subSchemas":[{"ref":"Omit_CreateLegacyInvitationConfig.routing_"},{"ref":"RecipientKeyOption"}]}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(ContextController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.createLegacyInvitation.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/test-endpoint/receive-invitation-url', - authenticateMiddleware([{"jwt":[]}]), - ...(fetchMiddlewares(ContextController)), - ...(fetchMiddlewares(ContextController.prototype.receiveInvitationFromUrl)), - - async function ContextController_receiveInvitationFromUrl(request: any, response: any, next: any) { - const args = { - request: {"in":"request","name":"request","required":true,"dataType":"object"}, - invitationRequest: {"in":"body","name":"invitationRequest","required":true,"ref":"ReceiveInvitationByUrlProps"}, - internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(ContextController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.receiveInvitationFromUrl.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/test-endpoint', - authenticateMiddleware([{"jwt":[]}]), - ...(fetchMiddlewares(ContextController)), - ...(fetchMiddlewares(ContextController.prototype.getAllOutOfBandRecords)), - - async function ContextController_getAllOutOfBandRecords(request: any, response: any, next: any) { - const args = { - request: {"in":"request","name":"request","required":true,"dataType":"object"}, - invitationId: {"in":"query","name":"invitationId","ref":"RecordId"}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(ContextController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.getAllOutOfBandRecords.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.get('/test-endpoint/:outOfBandId', - authenticateMiddleware([{"jwt":[]}]), - ...(fetchMiddlewares(ContextController)), - ...(fetchMiddlewares(ContextController.prototype.getOutOfBandRecordById)), - - async function ContextController_getOutOfBandRecordById(request: any, response: any, next: any) { - const args = { - request: {"in":"request","name":"request","required":true,"dataType":"object"}, - outOfBandId: {"in":"path","name":"outOfBandId","required":true,"ref":"RecordId"}, - notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = getValidatedArgs(args, request, response); - - const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; - - const controller: any = await container.get(ContextController); - if (typeof controller['setStatus'] === 'function') { - controller.setStatus(undefined); - } - - - const promise = controller.getOutOfBandRecordById.apply(controller, validatedArgs as any); - promiseHandler(controller, promise, response, undefined, next); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.post('/multi-tenancy/create-tenant', - authenticateMiddleware([{"jwt":[]}]), + authenticateMiddleware([{"jwt":["multi-tenant"]}]), ...(fetchMiddlewares(MultiTenancyController)), ...(fetchMiddlewares(MultiTenancyController.prototype.createTenant)), @@ -2984,7 +2715,7 @@ export function RegisterRoutes(app: Router) { }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.get('/multi-tenancy/:tenantId', - authenticateMiddleware([{"apiKey":[]}]), + authenticateMiddleware([{"jwt":["multi-tenant"]}]), ...(fetchMiddlewares(MultiTenancyController)), ...(fetchMiddlewares(MultiTenancyController.prototype.getTenantById)), @@ -3052,7 +2783,7 @@ export function RegisterRoutes(app: Router) { }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.delete('/multi-tenancy/:tenantId', - authenticateMiddleware([{"jwt":[]}]), + authenticateMiddleware([{"jwt":["multi-tenant"]}]), ...(fetchMiddlewares(MultiTenancyController)), ...(fetchMiddlewares(MultiTenancyController.prototype.deleteTenantById)), diff --git a/src/routes/swagger.json b/src/routes/swagger.json index 909b96f0..0014092c 100644 --- a/src/routes/swagger.json +++ b/src/routes/swagger.json @@ -4554,7 +4554,13 @@ "tags": [ "Connections" ], - "security": [], + "security": [ + { + "jwt": [ + "skip" + ] + } + ], "parameters": [ { "in": "path", @@ -6297,7 +6303,7 @@ } } }, - "/test-endpoint/multi-tenant/create-tenant": { + "/multi-tenancy/create-tenant": { "post": { "operationId": "CreateTenant", "responses": { @@ -6347,7 +6353,7 @@ } }, "tags": [ - "Multi Tenant" + "MultiTenancy" ], "security": [ { @@ -6369,9 +6375,9 @@ } } }, - "/test-endpoint/multi-tenant/get-token/{tenantId}": { - "post": { - "operationId": "GetTenantToken", + "/multi-tenancy/{tenantId}": { + "get": { + "operationId": "GetTenantById", "responses": { "200": { "description": "Ok", @@ -6419,7 +6425,7 @@ } }, "tags": [ - "Multi Tenant" + "MultiTenancy" ], "security": [ { @@ -6438,80 +6444,9 @@ } } ] - } - }, - "/test-endpoint/multi-tenant/{tenantId}": { - "get": { - "operationId": "GetTenantById", - "responses": { - "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": {} - } - } - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "reason": { - "type": "string" - } - }, - "required": [ - "reason" - ], - "type": "object" - } - } - } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "tags": [ - "Multi Tenant" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [ - { - "in": "path", - "name": "tenantId", - "required": true, - "schema": { - "type": "string" - } - } - ] - } - }, - "/test-endpoint/multi-tenant/connection-invitation": { - "post": { - "operationId": "CreateInvitation", + }, + "delete": { + "operationId": "DeleteTenantById", "responses": { "200": { "description": "Ok", @@ -6559,626 +6494,13 @@ } }, "tags": [ - "Multi Tenant" - ], - "security": [ - { - "jwt": [] - } - ], - "parameters": [] - } - }, - "/test-endpoint/create-legacy-invitation": { - "post": { - "operationId": "CreateLegacyInvitation", - "responses": { - "200": { - "description": "out-of-band record and invitation", - "content": { - "application/json": { - "schema": {}, - "examples": { - "Example 1": { - "value": { - "invitation": { - "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.1/invitation", - "@id": "d6472943-e5d0-4d95-8b48-790ed5a41931", - "label": "Aries Test Agent", - "accept": [ - "didcomm/aip1", - "didcomm/aip2;env=rfc19" - ], - "handshake_protocols": [ - "https://didcomm.org/didexchange/1.0", - "https://didcomm.org/connections/1.0" - ], - "services": [ - { - "id": "#inline-0", - "serviceEndpoint": "https://6b77-89-20-162-146.ngrok.io", - "type": "did-communication", - "recipientKeys": [ - "did:key:z6MkmTBHTWrvLPN8pBmUj7Ye5ww9GiacXCYMNVvpScSpf1DM" - ], - "routingKeys": [] - } - ] - }, - "outOfBandRecord": { - "_tags": { - "invitationId": "1cbd22e4-1906-41e9-8807-83d84437f978", - "state": "await-response", - "role": "sender", - "recipientKeyFingerprints": [ - "z6MktUCPZjfRJXD4GMcYuXiqX2qZ8vBw6UAYpDFiHEUfwuLj" - ] - }, - "outOfBandInvitation": { - "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.1/invitation", - "@id": "d6472943-e5d0-4d95-8b48-790ed5a41931", - "label": "Aries Test Agent", - "accept": [ - "didcomm/aip1", - "didcomm/aip2;env=rfc19" - ], - "handshake_protocols": [ - "https://didcomm.org/didexchange/1.0", - "https://didcomm.org/connections/1.0" - ], - "services": [ - { - "id": "#inline-0", - "serviceEndpoint": "https://6b77-89-20-162-146.ngrok.io", - "type": "did-communication", - "recipientKeys": [ - "did:key:z6MkmTBHTWrvLPN8pBmUj7Ye5ww9GiacXCYMNVvpScSpf1DM" - ], - "routingKeys": [] - } - ] - }, - "metadata": {}, - "id": "42a95528-0e30-4f86-a462-0efb02178b53", - "createdAt": "2022-01-01T00:00:00.000Z", - "reusable": false - } - } - } - } - } - } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "description": "Creates an outbound out-of-band record in the same way how `createInvitation` method does it,\nbut it also converts out-of-band invitation message to an \"legacy\" invitation message defined\nin RFC 0160: Connection Protocol and returns it together with out-of-band record.", - "tags": [ - "Test Connection" + "MultiTenancy" ], "security": [ { - "jwt": [] - } - ], - "parameters": [], - "requestBody": { - "description": "configuration of how a invitation should be created", - "required": false, - "content": { - "application/json": { - "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/Omit_CreateLegacyInvitationConfig.routing_" - }, - { - "$ref": "#/components/schemas/RecipientKeyOption" - } - ], - "description": "configuration of how a invitation should be created" - } - } - } - } - } - }, - "/test-endpoint/receive-invitation-url": { - "post": { - "operationId": "ReceiveInvitationFromUrl", - "responses": { - "200": { - "description": "out-of-band record and connection record if one has been created.", - "content": { - "application/json": { - "schema": {}, - "examples": { - "Example 1": { - "value": { - "outOfBandRecord": { - "_tags": { - "invitationId": "1cbd22e4-1906-41e9-8807-83d84437f978", - "state": "await-response", - "role": "sender", - "recipientKeyFingerprints": [ - "z6MktUCPZjfRJXD4GMcYuXiqX2qZ8vBw6UAYpDFiHEUfwuLj" - ] - }, - "outOfBandInvitation": { - "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.1/invitation", - "@id": "d6472943-e5d0-4d95-8b48-790ed5a41931", - "label": "Aries Test Agent", - "accept": [ - "didcomm/aip1", - "didcomm/aip2;env=rfc19" - ], - "handshake_protocols": [ - "https://didcomm.org/didexchange/1.0", - "https://didcomm.org/connections/1.0" - ], - "services": [ - { - "id": "#inline-0", - "serviceEndpoint": "https://6b77-89-20-162-146.ngrok.io", - "type": "did-communication", - "recipientKeys": [ - "did:key:z6MkmTBHTWrvLPN8pBmUj7Ye5ww9GiacXCYMNVvpScSpf1DM" - ], - "routingKeys": [] - } - ] - }, - "metadata": {}, - "id": "42a95528-0e30-4f86-a462-0efb02178b53", - "createdAt": "2022-01-01T00:00:00.000Z", - "reusable": false - }, - "connectionRecord": { - "_tags": { - "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", - "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", - "invitationKey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz", - "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d", - "verkey": "9HG4rJFpLiWf56MWxHj9rgdpErFzim2zEpHuxy1dw7oz" - }, - "metadata": {}, - "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", - "createdAt": "2022-01-01T00:00:00.000Z", - "did": "did:peer:1zQmfQh1T3rSqarP2FZ37uKjdQHPKFdVyo2mGiAPHZ8Ep7hv", - "invitationDid": "did:peer:2.SeyJzIjoiaHR0cHM6Ly9kYTIzLTg5LTIwLTE2Mi0xNDYubmdyb2suaW8iLCJ0IjoiZGlkLWNvbW11bmljYXRpb24iLCJwcmlvcml0eSI6MCwicmVjaXBpZW50S2V5cyI6WyJkaWQ6a2V5Ono2TWtualg3U1lXRmdHMThCYkNEZHJnemhuQnA0UlhyOGVITHZxQ3FvRXllckxiTiN6Nk1rbmpYN1NZV0ZnRzE4QmJDRGRyZ3pobkJwNFJYcjhlSEx2cUNxb0V5ZXJMYk4iXSwiciI6W119", - "outOfBandId": "edbc89fe-785f-4774-a288-46012486881d" - } - } - } - } - } - } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "description": "Creates inbound out-of-band record and assigns out-of-band invitation message to it if the\nmessage is valid.", - "tags": [ - "Test Connection" - ], - "security": [ - { - "jwt": [] - } - ], - "parameters": [], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ReceiveInvitationByUrlProps" - } - } - } - } - } - }, - "/test-endpoint": { - "get": { - "operationId": "GetAllOutOfBandRecords", - "responses": { - "200": { - "description": "OutOfBandRecord[]", - "content": { - "application/json": { - "schema": { - "items": {}, - "type": "array" - }, - "examples": { - "Example 1": { - "value": [ - { - "_tags": { - "invitationId": "1cbd22e4-1906-41e9-8807-83d84437f978", - "state": "await-response", - "role": "sender", - "recipientKeyFingerprints": [ - "z6MktUCPZjfRJXD4GMcYuXiqX2qZ8vBw6UAYpDFiHEUfwuLj" - ] - }, - "outOfBandInvitation": { - "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.1/invitation", - "@id": "d6472943-e5d0-4d95-8b48-790ed5a41931", - "label": "Aries Test Agent", - "accept": [ - "didcomm/aip1", - "didcomm/aip2;env=rfc19" - ], - "handshake_protocols": [ - "https://didcomm.org/didexchange/1.0", - "https://didcomm.org/connections/1.0" - ], - "services": [ - { - "id": "#inline-0", - "serviceEndpoint": "https://6b77-89-20-162-146.ngrok.io", - "type": "did-communication", - "recipientKeys": [ - "did:key:z6MkmTBHTWrvLPN8pBmUj7Ye5ww9GiacXCYMNVvpScSpf1DM" - ], - "routingKeys": [] - } - ] - }, - "metadata": {}, - "id": "42a95528-0e30-4f86-a462-0efb02178b53", - "createdAt": "2022-01-01T00:00:00.000Z", - "reusable": false - } - ] - } - } - } - } - } - }, - "description": "Retrieve all out of band records", - "tags": [ - "Test Connection" - ], - "security": [ - { - "jwt": [] - } - ], - "parameters": [ - { - "description": "invitation identifier", - "in": "query", - "name": "invitationId", - "required": false, - "schema": { - "$ref": "#/components/schemas/RecordId" - } - } - ] - } - }, - "/test-endpoint/{outOfBandId}": { - "get": { - "operationId": "GetOutOfBandRecordById", - "responses": { - "200": { - "description": "OutOfBandRecord", - "content": { - "application/json": { - "schema": {}, - "examples": { - "Example 1": { - "value": { - "_tags": { - "invitationId": "1cbd22e4-1906-41e9-8807-83d84437f978", - "state": "await-response", - "role": "sender", - "recipientKeyFingerprints": [ - "z6MktUCPZjfRJXD4GMcYuXiqX2qZ8vBw6UAYpDFiHEUfwuLj" - ] - }, - "outOfBandInvitation": { - "@type": "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.1/invitation", - "@id": "d6472943-e5d0-4d95-8b48-790ed5a41931", - "label": "Aries Test Agent", - "accept": [ - "didcomm/aip1", - "didcomm/aip2;env=rfc19" - ], - "handshake_protocols": [ - "https://didcomm.org/didexchange/1.0", - "https://didcomm.org/connections/1.0" - ], - "services": [ - { - "id": "#inline-0", - "serviceEndpoint": "https://6b77-89-20-162-146.ngrok.io", - "type": "did-communication", - "recipientKeys": [ - "did:key:z6MkmTBHTWrvLPN8pBmUj7Ye5ww9GiacXCYMNVvpScSpf1DM" - ], - "routingKeys": [] - } - ] - }, - "metadata": {}, - "id": "42a95528-0e30-4f86-a462-0efb02178b53", - "createdAt": "2022-01-01T00:00:00.000Z", - "reusable": false - } - } - } - } - } - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "reason": { - "type": "string" - } - }, - "required": [ - "reason" - ], - "type": "object" - } - } - } - } - }, - "description": "Retrieve an out of band record by id", - "tags": [ - "Test Connection" - ], - "security": [ - { - "jwt": [] - } - ], - "parameters": [ - { - "in": "path", - "name": "outOfBandId", - "required": true, - "schema": { - "$ref": "#/components/schemas/RecordId" - } - } - ] - } - }, - "/multi-tenancy/create-tenant": { - "post": { - "operationId": "CreateTenant", - "responses": { - "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": {} - } - } - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "reason": { - "type": "string" - } - }, - "required": [ - "reason" - ], - "type": "object" - } - } - } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "tags": [ - "MultiTenancy" - ], - "security": [ - { - "jwt": [] - } - ], - "parameters": [], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CreateTenantOptions" - } - } - } - } - } - }, - "/multi-tenancy/{tenantId}": { - "get": { - "operationId": "GetTenantById", - "responses": { - "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": {} - } - } - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "reason": { - "type": "string" - } - }, - "required": [ - "reason" - ], - "type": "object" - } - } - } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "tags": [ - "MultiTenancy" - ], - "security": [ - { - "apiKey": [] - } - ], - "parameters": [ - { - "in": "path", - "name": "tenantId", - "required": true, - "schema": { - "type": "string" - } - } - ] - }, - "delete": { - "operationId": "DeleteTenantById", - "responses": { - "200": { - "description": "Ok", - "content": { - "application/json": { - "schema": {} - } - } - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "reason": { - "type": "string" - } - }, - "required": [ - "reason" - ], - "type": "object" - } - } - } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "properties": { - "message": { - "type": "string" - } - }, - "required": [ - "message" - ], - "type": "object" - } - } - } - } - }, - "tags": [ - "MultiTenancy" - ], - "security": [ - { - "jwt": [] + "jwt": [ + "multi-tenant" + ] } ], "parameters": [