Skip to content

Commit cb69f50

Browse files
feat: oid4vc verification (#1501)
* feat:oid4vc verifications Signed-off-by: Tipu_Singh <[email protected]> * feat: CRU for verifier Signed-off-by: Krishna Waske <[email protected]> * fix: get verifier api Signed-off-by: Krishna Waske <[email protected]> * feat: add delete verifier Signed-off-by: Krishna Waske <[email protected]> * fix: delete verifier reselient Signed-off-by: Krishna Waske <[email protected]> * feat: oid4vc verification verifier session (#1502) * fix: verification session Signed-off-by: Krishna Waske <[email protected]> * feat: add verifier session response by id Signed-off-by: Krishna Waske <[email protected]> --------- Signed-off-by: Krishna Waske <[email protected]> * feat: verifier session post API (#1503) * feat: verifier session post API Signed-off-by: Tipu_Singh <[email protected]> * fix: delete oid4vc verifier Signed-off-by: Krishna Waske <[email protected]> * fix: change DTO example Signed-off-by: Krishna Waske <[email protected]> * fix: change CREDEBL to example Signed-off-by: Krishna Waske <[email protected]> * fix: session to presentation Signed-off-by: Krishna Waske <[email protected]> * feat: added docker file for verification Signed-off-by: Tipu_Singh <[email protected]> * fix: remove unnecessary column for oid4vp_verifier table Signed-off-by: Krishna Waske <[email protected]> --------- Signed-off-by: Tipu_Singh <[email protected]> Signed-off-by: Krishna Waske <[email protected]> Co-authored-by: Krishna Waske <[email protected]> --------- Signed-off-by: Tipu_Singh <[email protected]> Signed-off-by: Krishna Waske <[email protected]> Co-authored-by: Tipu_Singh <[email protected]>
1 parent 7ee213e commit cb69f50

File tree

28 files changed

+2095
-195
lines changed

28 files changed

+2095
-195
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Stage 1: Build the application
2+
FROM node:18-alpine as build
3+
# Install OpenSSL
4+
RUN apk add --no-cache openssl
5+
RUN npm install -g pnpm
6+
# Set the working directory
7+
WORKDIR /app
8+
9+
# Copy package.json and package-lock.json
10+
COPY package.json ./
11+
COPY pnpm-workspace.yaml ./
12+
#COPY package-lock.json ./
13+
14+
ENV PUPPETEER_SKIP_DOWNLOAD=true
15+
16+
# Install dependencies while ignoring scripts (including Puppeteer's installation)
17+
RUN pnpm i --ignore-scripts
18+
19+
# Copy the rest of the application code
20+
COPY . .
21+
# RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate
22+
RUN cd libs/prisma-service && npx prisma generate
23+
24+
# Build the oid4vc-verification service
25+
RUN npm run build oid4vc-verification
26+
27+
28+
# Stage 2: Create the final image
29+
FROM node:18-alpine
30+
# Install OpenSSL
31+
RUN apk add --no-cache openssl
32+
# RUN npm install -g pnpm
33+
# Set the working directory
34+
WORKDIR /app
35+
36+
# Copy the compiled code from the build stage
37+
COPY --from=build /app/dist/apps/oid4vc-verification/ ./dist/apps/oid4vc-verification/
38+
39+
# Copy the libs folder from the build stage
40+
COPY --from=build /app/libs/ ./libs/
41+
#COPY --from=build /app/package.json ./
42+
COPY --from=build /app/node_modules ./node_modules
43+
44+
# Set the command to run the microservice
45+
CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate && cd ../.. && node dist/apps/oid4vc-verification/main.js"]

apps/agent-service/src/agent-service.controller.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
x509CertificateDecodeDto,
3333
X509CreateCertificateOptions
3434
} from '@credebl/common/interfaces/x509.interface';
35+
import { CreateVerifier, UpdateVerifier } from '@credebl/common/interfaces/oid4vp-verification';
3536

3637
@Controller()
3738
export class AgentServiceController {
@@ -412,4 +413,41 @@ export class AgentServiceController {
412413
}): Promise<object> {
413414
return this.agentServiceService.importX509Certificate(payload.options, payload.url, payload.orgId);
414415
}
416+
417+
@MessagePattern({ cmd: 'agent-create-oid4vp-verifier' })
418+
async createOid4vpVerifier(payload: {
419+
verifierDetails: CreateVerifier;
420+
url: string;
421+
orgId: string;
422+
}): Promise<object> {
423+
return this.agentServiceService.createOid4vpVerifier(payload.verifierDetails, payload.url, payload.orgId);
424+
}
425+
426+
@MessagePattern({ cmd: 'agent-delete-oid4vp-verifier' })
427+
async deleteOid4vpVerifier(payload: { url: string; orgId: string }): Promise<object> {
428+
return this.agentServiceService.deleteOid4vpVerifier(payload.url, payload.orgId);
429+
}
430+
431+
@MessagePattern({ cmd: 'agent-update-oid4vp-verifier' })
432+
async updateOid4vpVerifier(payload: {
433+
verifierDetails: UpdateVerifier;
434+
url: string;
435+
orgId: string;
436+
}): Promise<object> {
437+
return this.agentServiceService.updateOid4vpVerifier(payload.verifierDetails, payload.url, payload.orgId);
438+
}
439+
440+
@MessagePattern({ cmd: 'agent-get-oid4vp-verifier-session' })
441+
async getOid4vpVerifierSession(payload: { url: string; orgId: string }): Promise<object> {
442+
return this.agentServiceService.getOid4vpVerifierSession(payload.url, payload.orgId);
443+
}
444+
445+
@MessagePattern({ cmd: 'agent-create-oid4vp-verification-session' })
446+
async oid4vpCreateVerificationSession(payload: {
447+
sessionRequest: object;
448+
url: string;
449+
orgId: string;
450+
}): Promise<object> {
451+
return this.agentServiceService.createOid4vpVerificationSession(payload.sessionRequest, payload.url, payload.orgId);
452+
}
415453
}

apps/agent-service/src/agent-service.service.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ import {
8484
x509CertificateDecodeDto,
8585
X509CreateCertificateOptions
8686
} from '@credebl/common/interfaces/x509.interface';
87+
import { CreateVerifier, UpdateVerifier } from '@credebl/common/interfaces/oid4vp-verification';
8788
@Injectable()
8889
@WebSocketGateway()
8990
export class AgentServiceService {
@@ -2270,4 +2271,66 @@ export class AgentServiceService {
22702271
throw error;
22712272
}
22722273
}
2274+
2275+
async createOid4vpVerifier(verifierDetails: CreateVerifier, url: string, orgId: string): Promise<object> {
2276+
try {
2277+
const getApiKey = await this.getOrgAgentApiKey(orgId);
2278+
const createVerifier = await this.commonService
2279+
.httpPost(url, verifierDetails, { headers: { authorization: getApiKey } })
2280+
.then(async (response) => response);
2281+
return createVerifier;
2282+
} catch (error) {
2283+
this.logger.error(`Error in creating oid4vp verifier in agent service : ${JSON.stringify(error)}`);
2284+
throw error;
2285+
}
2286+
}
2287+
2288+
async deleteOid4vpVerifier(url: string, orgId: string): Promise<object> {
2289+
try {
2290+
const getApiKey = await this.getOrgAgentApiKey(orgId);
2291+
const deleteVerifier = await this.commonService.httpDelete(url, { headers: { authorization: getApiKey } });
2292+
return deleteVerifier.data ?? deleteVerifier;
2293+
} catch (error) {
2294+
this.logger.error(`Error in deleting oid4vp verifier in agent service : ${JSON.stringify(error)}`);
2295+
throw error;
2296+
}
2297+
}
2298+
2299+
async updateOid4vpVerifier(verifierDetails: UpdateVerifier, url: string, orgId: string): Promise<object> {
2300+
try {
2301+
const getApiKey = await this.getOrgAgentApiKey(orgId);
2302+
const updateVerifier = await this.commonService
2303+
.httpPut(url, verifierDetails, { headers: { authorization: getApiKey } })
2304+
.then(async (response) => response);
2305+
return updateVerifier;
2306+
} catch (error) {
2307+
this.logger.error(`Error in updating oid4vp verifier in agent service : ${JSON.stringify(error)}`);
2308+
throw error;
2309+
}
2310+
}
2311+
2312+
async getOid4vpVerifierSession(url: string, orgId: string): Promise<object> {
2313+
try {
2314+
const agentToken = await this.getOrgAgentApiKey(orgId);
2315+
const updateVerifier = await this.commonService
2316+
.httpGet(url, { headers: { authorization: agentToken } })
2317+
.then(async (response) => response);
2318+
return updateVerifier;
2319+
} catch (error) {
2320+
this.logger.error(`Error in getting oid4vp verifier session in agent service : ${JSON.stringify(error)}`);
2321+
}
2322+
}
2323+
2324+
async createOid4vpVerificationSession(sessionRequest: object, url: string, orgId: string): Promise<object> {
2325+
try {
2326+
const getApiKey = await this.getOrgAgentApiKey(orgId);
2327+
const createSession = await this.commonService
2328+
.httpPost(url, sessionRequest, { headers: { authorization: getApiKey } })
2329+
.then(async (response) => response);
2330+
return createSession;
2331+
} catch (error) {
2332+
this.logger.error(`Error in creating oid4vp verification session in agent service : ${JSON.stringify(error)}`);
2333+
throw error;
2334+
}
2335+
}
22732336
}

apps/api-gateway/src/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { GlobalConfigModule } from '@credebl/config/global-config.module';
3232
import { ConfigModule as PlatformConfig } from '@credebl/config/config.module';
3333
import { Oid4vcIssuanceModule } from './oid4vc-issuance/oid4vc-issuance.module';
3434
import { X509Module } from './x509/x509.module';
35+
import { Oid4vpModule } from './oid4vc-verification/oid4vc-verification.module';
3536

3637
@Module({
3738
imports: [
@@ -66,6 +67,7 @@ import { X509Module } from './x509/x509.module';
6667
GeoLocationModule,
6768
CloudWalletModule,
6869
Oid4vcIssuanceModule,
70+
Oid4vpModule,
6971
X509Module
7072
],
7173
controllers: [AppController],

0 commit comments

Comments
 (0)