diff --git a/Dockerfile b/Dockerfile index 03459e0f..c8175271 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,48 +1,3 @@ -# FROM ubuntu:20.04 - -# ENV DEBIAN_FRONTEND noninteractive - -# RUN apt-get update -y && apt-get install -y \ -# software-properties-common \ -# apt-transport-https \ -# curl \ -# # Only needed to build indy-sdk -# build-essential - -# RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - - -# # yarn -# RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \ -# echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list - -# # install depdencies -# RUN apt-get update -y && apt-get install -y --allow-unauthenticated \ -# nodejs - -# # install depdencies -# RUN apt-get update -y && apt-get install -y --allow-unauthenticated \ -# nodejs - -# # Install yarn seperately due to `no-install-recommends` to skip nodejs install -# RUN apt-get install -y --no-install-recommends yarn - -# RUN yarn global add patch-package -# # AFJ specifc setup -# WORKDIR /www - -# COPY bin ./bin -# COPY package.json ./package.json -# COPY patches ./patches - -# RUN yarn install --production - -# COPY build ./build -# # COPY libindy_vdr.so /usr/lib/ -# # COPY libindy_vdr.so /usr/local/lib/ - -# ENTRYPOINT [ "./bin/afj-rest.js", "start" ] - - # Stage 1: Builder stage FROM node:18.19.0 AS builder @@ -55,6 +10,7 @@ COPY package.json yarn.lock ./ COPY . . # Install dependencies +RUN rm -rf node_modules RUN yarn install --frozen-lockfile RUN yarn global add patch-package @@ -75,4 +31,4 @@ COPY --from=builder /app/node_modules ./node_modules COPY --from=builder /app/patches ./patches # Set entry point -ENTRYPOINT ["node", "./bin/afj-rest.js", "start"] \ No newline at end of file +ENTRYPOINT ["node", "./bin/afj-rest.js", "start"] diff --git a/package.json b/package.json index 4c32c3e2..d4ea9547 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,7 @@ "@tsoa/runtime": "^6.0.0", "@types/node-fetch": "^2.6.4", "@types/ref-struct-di": "^1.1.9", + "@types/uuid": "^8.3.4", "@types/ws": "^8.5.4", "axios": "^1.4.0", "body-parser": "^1.20.0", @@ -86,7 +87,6 @@ "@types/ref-struct-di": "^1.1.9", "@types/supertest": "^2.0.12", "@types/swagger-ui-express": "^4.1.3", - "@types/uuid": "^8.3.4", "@typescript-eslint/eslint-plugin": "^6.19.1", "@typescript-eslint/parser": "^6.19.1", "eslint": "^7.32.0", diff --git a/src/controllers/multi-tenancy/MultiTenancyController.ts b/src/controllers/multi-tenancy/MultiTenancyController.ts index a885fb96..739463d8 100644 --- a/src/controllers/multi-tenancy/MultiTenancyController.ts +++ b/src/controllers/multi-tenancy/MultiTenancyController.ts @@ -1,3 +1,4 @@ +/* eslint-disable prettier/prettier */ import type { RestAgentModules, RestMultiTenantAgentModules } from '../../cliAgent' import type { Version } from '../examples' import type { RecipientKeyOption, SchemaMetadata } from '../types' @@ -49,7 +50,15 @@ import { QuestionAnswerRole, QuestionAnswerState } from '@credo-ts/question-answ import axios from 'axios' import * as fs from 'fs' -import { CredentialEnum, DidMethod, EndorserMode, Network, NetworkTypes, Role, SchemaError } from '../../enums/enum' +import { + CredentialEnum, + DidMethod, + EndorserMode, + Network, + NetworkTypes, + Role, + SchemaError, +} from '../../enums/enum' import ErrorHandlingService from '../../errorHandlingService' import { ENDORSER_DID_NOT_PRESENT } from '../../errorMessages' import { diff --git a/src/routes/routes.ts b/src/routes/routes.ts index 0ffd1f1c..4566e855 100644 --- a/src/routes/routes.ts +++ b/src/routes/routes.ts @@ -418,7 +418,7 @@ const models: TsoaRoute.Models = { "DidCreate": { "dataType": "refObject", "properties": { - "keyType": {"ref":"KeyType","required":true}, + "keyType": {"ref":"KeyType"}, "seed": {"dataType":"string"}, "domain": {"dataType":"string"}, "method": {"dataType":"string","required":true}, @@ -585,6 +585,7 @@ const models: TsoaRoute.Models = { "issuanceDate": {"dataType":"string","required":true}, "expirationDate": {"dataType":"string"}, "credentialSubject": {"ref":"SingleOrArray_JsonObject_","required":true}, + "prettyVc": {"dataType":"any"}, }, "additionalProperties": {"dataType":"any"}, }, @@ -1128,6 +1129,31 @@ 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 + "CredentialFormatDataMessagePayload__40_LegacyIndyCredentialFormat-or-JsonLdCredentialFormat-or-AnonCredsCredentialFormat_41_-Array.proposal_": { + "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 + "CredentialFormatDataMessagePayload__40_LegacyIndyCredentialFormat-or-JsonLdCredentialFormat-or-AnonCredsCredentialFormat_41_-Array.offer_": { + "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 + "CredentialFormatDataMessagePayload__40_LegacyIndyCredentialFormat-or-JsonLdCredentialFormat-or-AnonCredsCredentialFormat_41_-Array.request_": { + "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 + "CredentialFormatDataMessagePayload__40_LegacyIndyCredentialFormat-or-JsonLdCredentialFormat-or-AnonCredsCredentialFormat_41_-Array.credential_": { + "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 + "GetCredentialFormatDataReturn__40_LegacyIndyCredentialFormat-or-JsonLdCredentialFormat-or-AnonCredsCredentialFormat_41_-Array_": { + "dataType": "refAlias", + "type": {"dataType":"nestedObjectLiteral","nestedProperties":{"credential":{"ref":"CredentialFormatDataMessagePayload__40_LegacyIndyCredentialFormat-or-JsonLdCredentialFormat-or-AnonCredsCredentialFormat_41_-Array.credential_"},"request":{"ref":"CredentialFormatDataMessagePayload__40_LegacyIndyCredentialFormat-or-JsonLdCredentialFormat-or-AnonCredsCredentialFormat_41_-Array.request_"},"offerAttributes":{"dataType":"array","array":{"dataType":"refObject","ref":"CredentialPreviewAttributeOptions"}},"offer":{"ref":"CredentialFormatDataMessagePayload__40_LegacyIndyCredentialFormat-or-JsonLdCredentialFormat-or-AnonCredsCredentialFormat_41_-Array.offer_"},"proposal":{"ref":"CredentialFormatDataMessagePayload__40_LegacyIndyCredentialFormat-or-JsonLdCredentialFormat-or-AnonCredsCredentialFormat_41_-Array.proposal_"},"proposalAttributes":{"dataType":"array","array":{"dataType":"refObject","ref":"CredentialPreviewAttributeOptions"}}},"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":{}}, @@ -1149,11 +1175,18 @@ const templateService = new ExpressTemplateService(models, {"noImplicitAdditiona // WARNING: This 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('/proofs', authenticateMiddleware([{"apiKey":[]}]), ...(fetchMiddlewares(ProofController)), @@ -2468,7 +2501,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('/multi-tenancy/polygon-wc3/schema/:tenantId', + app.post('/multi-tenancy/polygon-w3c/schema/:tenantId', authenticateMiddleware([{"apiKey":[]}]), ...(fetchMiddlewares(MultiTenancyController)), ...(fetchMiddlewares(MultiTenancyController.prototype.createPolygonW3CSchema)), @@ -2505,7 +2538,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/polygon-wc3/schema/:did/:schemaId/:tenantId', + app.get('/multi-tenancy/polygon-w3c/schema/:did/:schemaId/:tenantId', authenticateMiddleware([{"apiKey":[]}]), ...(fetchMiddlewares(MultiTenancyController)), ...(fetchMiddlewares(MultiTenancyController.prototype.getPolygonW3CSchemaById)), @@ -2878,6 +2911,43 @@ 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/credentials/form-data/:tenantId/:credentialRecordId', + authenticateMiddleware([{"apiKey":[]}]), + ...(fetchMiddlewares(MultiTenancyController)), + ...(fetchMiddlewares(MultiTenancyController.prototype.credentialFormData)), + + async function MultiTenancyController_credentialFormData(request: ExRequest, response: ExResponse, next: any) { + const args: Record = { + tenantId: {"in":"path","name":"tenantId","required":true,"dataType":"string"}, + credentialRecordId: {"in":"path","name":"credentialRecordId","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 + + let validatedArgs: any[] = []; + try { + validatedArgs = templateService.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); + } + + await templateService.apiHandler({ + methodName: 'credentialFormData', + controller, + response, + next, + validatedArgs, + successStatus: undefined, + }); + } 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)), @@ -4234,6 +4304,42 @@ 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/form-data', + authenticateMiddleware([{"apiKey":[]}]), + ...(fetchMiddlewares(CredentialController)), + ...(fetchMiddlewares(CredentialController.prototype.credentialFormData)), + + async function CredentialController_credentialFormData(request: ExRequest, response: ExResponse, next: any) { + const args: Record = { + credentialRecordId: {"in":"path","name":"credentialRecordId","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 + + let validatedArgs: any[] = []; + try { + validatedArgs = templateService.getValidatedArgs({ args, request, response }); + + const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; + + const controller: any = await container.get(CredentialController); + if (typeof controller['setStatus'] === 'function') { + controller.setStatus(undefined); + } + + await templateService.apiHandler({ + methodName: 'credentialFormData', + controller, + response, + next, + validatedArgs, + successStatus: undefined, + }); + } 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)), @@ -4822,4 +4928,4 @@ 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 } -// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa \ No newline at end of file +// WARNING: This 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 b2137d50..8eea6fe5 100644 --- a/src/routes/swagger.json +++ b/src/routes/swagger.json @@ -941,7 +941,6 @@ } }, "required": [ - "keyType", "method" ], "type": "object", @@ -1379,7 +1378,8 @@ }, "credentialSubject": { "$ref": "#/components/schemas/SingleOrArray_JsonObject_" - } + }, + "prettyVc": {} }, "required": [ "@context", @@ -2585,6 +2585,56 @@ "type": "object", "additionalProperties": false }, + "CredentialFormatDataMessagePayload__40_LegacyIndyCredentialFormat-or-JsonLdCredentialFormat-or-AnonCredsCredentialFormat_41_-Array.proposal_": { + "properties": {}, + "type": "object", + "description": "Get the format data payload for a specific message from a list of CredentialFormat interfaces and a message\n\nFor an indy offer, this resolves to the cred abstract format as defined here:\nhttps://github.com/hyperledger/aries-rfcs/tree/b3a3942ef052039e73cd23d847f42947f8287da2/features/0592-indy-attachments#cred-abstract-format" + }, + "CredentialFormatDataMessagePayload__40_LegacyIndyCredentialFormat-or-JsonLdCredentialFormat-or-AnonCredsCredentialFormat_41_-Array.offer_": { + "properties": {}, + "type": "object", + "description": "Get the format data payload for a specific message from a list of CredentialFormat interfaces and a message\n\nFor an indy offer, this resolves to the cred abstract format as defined here:\nhttps://github.com/hyperledger/aries-rfcs/tree/b3a3942ef052039e73cd23d847f42947f8287da2/features/0592-indy-attachments#cred-abstract-format" + }, + "CredentialFormatDataMessagePayload__40_LegacyIndyCredentialFormat-or-JsonLdCredentialFormat-or-AnonCredsCredentialFormat_41_-Array.request_": { + "properties": {}, + "type": "object", + "description": "Get the format data payload for a specific message from a list of CredentialFormat interfaces and a message\n\nFor an indy offer, this resolves to the cred abstract format as defined here:\nhttps://github.com/hyperledger/aries-rfcs/tree/b3a3942ef052039e73cd23d847f42947f8287da2/features/0592-indy-attachments#cred-abstract-format" + }, + "CredentialFormatDataMessagePayload__40_LegacyIndyCredentialFormat-or-JsonLdCredentialFormat-or-AnonCredsCredentialFormat_41_-Array.credential_": { + "properties": {}, + "type": "object", + "description": "Get the format data payload for a specific message from a list of CredentialFormat interfaces and a message\n\nFor an indy offer, this resolves to the cred abstract format as defined here:\nhttps://github.com/hyperledger/aries-rfcs/tree/b3a3942ef052039e73cd23d847f42947f8287da2/features/0592-indy-attachments#cred-abstract-format" + }, + "GetCredentialFormatDataReturn__40_LegacyIndyCredentialFormat-or-JsonLdCredentialFormat-or-AnonCredsCredentialFormat_41_-Array_": { + "properties": { + "credential": { + "$ref": "#/components/schemas/CredentialFormatDataMessagePayload__40_LegacyIndyCredentialFormat-or-JsonLdCredentialFormat-or-AnonCredsCredentialFormat_41_-Array.credential_" + }, + "request": { + "$ref": "#/components/schemas/CredentialFormatDataMessagePayload__40_LegacyIndyCredentialFormat-or-JsonLdCredentialFormat-or-AnonCredsCredentialFormat_41_-Array.request_" + }, + "offerAttributes": { + "items": { + "$ref": "#/components/schemas/CredentialPreviewAttributeOptions" + }, + "type": "array" + }, + "offer": { + "$ref": "#/components/schemas/CredentialFormatDataMessagePayload__40_LegacyIndyCredentialFormat-or-JsonLdCredentialFormat-or-AnonCredsCredentialFormat_41_-Array.offer_" + }, + "proposal": { + "$ref": "#/components/schemas/CredentialFormatDataMessagePayload__40_LegacyIndyCredentialFormat-or-JsonLdCredentialFormat-or-AnonCredsCredentialFormat_41_-Array.proposal_" + }, + "proposalAttributes": { + "items": { + "$ref": "#/components/schemas/CredentialPreviewAttributeOptions" + }, + "type": "array" + } + }, + "type": "object", + "description": "Get format data return value. Each key holds a mapping of credential format key to format data." + }, "BasicMessageRecord": { "$ref": "#/components/schemas/Record_string.unknown_" }, @@ -2624,7 +2674,7 @@ }, "info": { "title": "credo-controller", - "version": "0.9.4", + "version": "2.0.0", "description": "Rest endpoint wrapper for using your agent over HTTP", "license": { "name": "Apache-2.0" @@ -2890,26 +2940,11 @@ "application/json": { "schema": { "properties": { - "recipientKey": { - "anyOf": [ - { - "properties": { - "recipientKey": {} - }, - "type": "object" - }, - { - "properties": { - "recipientKey": { - "type": "string" - } - }, - "required": [ - "recipientKey" - ], - "type": "object" - } - ] + "proofRecordThId": { + "type": "string" + }, + "invitationDid": { + "type": "string" }, "outOfBandRecord": { "$ref": "#/components/schemas/Record_string.unknown_" @@ -2922,7 +2957,8 @@ } }, "required": [ - "recipientKey", + "proofRecordThId", + "invitationDid", "outOfBandRecord", "invitation", "invitationUrl" @@ -4860,7 +4896,7 @@ } } }, - "/multi-tenancy/polygon-wc3/schema/{tenantId}": { + "/multi-tenancy/polygon-w3c/schema/{tenantId}": { "post": { "operationId": "CreatePolygonW3CSchema", "responses": { @@ -4923,7 +4959,7 @@ } } }, - "/multi-tenancy/polygon-wc3/schema/{did}/{schemaId}/{tenantId}": { + "/multi-tenancy/polygon-w3c/schema/{did}/{schemaId}/{tenantId}": { "get": { "operationId": "GetPolygonW3CSchemaById", "responses": { @@ -5392,6 +5428,47 @@ ] } }, + "/multi-tenancy/credentials/form-data/{tenantId}/{credentialRecordId}": { + "get": { + "operationId": "CredentialFormData", + "responses": { + "200": { + "description": "Ok", + "content": { + "application/json": { + "schema": {} + } + } + } + }, + "tags": [ + "MultiTenancy" + ], + "security": [ + { + "apiKey": [] + } + ], + "parameters": [ + { + "in": "path", + "name": "tenantId", + "required": true, + "schema": { + "type": "string" + } + }, + { + "in": "path", + "name": "credentialRecordId", + "required": true, + "schema": { + "type": "string" + } + } + ] + } + }, "/multi-tenancy/proofs/{tenantId}": { "get": { "operationId": "GetAllProofs", @@ -7261,26 +7338,14 @@ "application/json": { "schema": { "properties": { - "recipientKey": { - "anyOf": [ - { - "properties": { - "recipientKey": {} - }, - "type": "object" - }, - { - "properties": { - "recipientKey": { - "type": "string" - } - }, - "required": [ - "recipientKey" - ], - "type": "object" - } - ] + "invitationDid": { + "type": "string" + }, + "credentialRequestThId": { + "type": "string" + }, + "outOfBandRecordId": { + "type": "string" }, "outOfBandRecord": { "$ref": "#/components/schemas/Record_string.unknown_" @@ -7293,7 +7358,9 @@ } }, "required": [ - "recipientKey", + "invitationDid", + "credentialRequestThId", + "outOfBandRecordId", "outOfBandRecord", "invitation", "invitationUrl" @@ -7508,6 +7575,42 @@ } } }, + "/credentials/{credentialRecordId}/form-data": { + "get": { + "operationId": "CredentialFormData", + "responses": { + "200": { + "description": "credentialRecord", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetCredentialFormatDataReturn__40_LegacyIndyCredentialFormat-or-JsonLdCredentialFormat-or-AnonCredsCredentialFormat_41_-Array_" + } + } + } + } + }, + "description": "Return credentialRecord", + "tags": [ + "Credentials" + ], + "security": [ + { + "apiKey": [] + } + ], + "parameters": [ + { + "in": "path", + "name": "credentialRecordId", + "required": true, + "schema": { + "type": "string" + } + } + ] + } + }, "/connections": { "get": { "operationId": "GetAllConnections",