Skip to content

Commit 6ab319f

Browse files
committed
feat: oid4vc issuance (#1455)
* feat: oidc issunace Signed-off-by: Tipu_Singh <tipu.singh@ayanworks.com> * feat:create seperate microservice for oid4vc Signed-off-by: Tipu_Singh <tipu.singh@ayanworks.com> * feat:removed logs Signed-off-by: Tipu_Singh <tipu.singh@ayanworks.com> * refactor: removed duplicate code Signed-off-by: Tipu_Singh <tipu.singh@ayanworks.com> * feat: create credential offer API Signed-off-by: Tipu_Singh <tipu.singh@ayanworks.com> * fix: missing credential details repository logic Signed-off-by: Tipu_Singh <tipu.singh@ayanworks.com> * feat: added docker file for oid4vc-issuance Signed-off-by: Tipu_Singh <tipu.singh@ayanworks.com> --------- Signed-off-by: Tipu_Singh <tipu.singh@ayanworks.com>
1 parent bfecc7a commit 6ab319f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2248
-908
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 package-lock.json ./
12+
13+
ENV PUPPETEER_SKIP_DOWNLOAD=true
14+
15+
# Install dependencies while ignoring scripts (including Puppeteer's installation)
16+
RUN pnpm i --ignore-scripts
17+
18+
# Copy the rest of the application code
19+
COPY . .
20+
# RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate
21+
RUN cd libs/prisma-service && npx prisma generate
22+
23+
# Build the issuance service
24+
RUN pnpm run build issuance
25+
26+
# Stage 2: Create the final image
27+
FROM node:18-alpine
28+
# Install OpenSSL
29+
RUN apk add --no-cache openssl
30+
# RUN npm install -g pnpm
31+
# Set the working directory
32+
WORKDIR /app
33+
34+
# Copy the compiled code from the build stage
35+
COPY --from=build /app/dist/apps/oid4vc-issuance/ ./dist/apps/oid4vc-issuance/
36+
37+
# Copy the libs folder from the build stage
38+
COPY --from=build /app/libs/ ./libs/
39+
#COPY --from=build /app/package.json ./
40+
COPY --from=build /app/node_modules ./node_modules
41+
# COPY --from=build /app/uploadedFiles ./uploadedFiles
42+
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-issuance/main.js"]

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

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -324,37 +324,60 @@ export class AgentServiceController {
324324
return this.agentServiceService.getAgentDetails(payload.orgId);
325325
}
326326

327-
@MessagePattern({ cmd: 'agent-create-oidc-issuer' })
327+
@MessagePattern({ cmd: 'agent-create-oid4vc-issuer' })
328328
// eslint-disable-next-line @typescript-eslint/no-explicit-any
329329
async oidcIssuerCreate(payload: { issuerCreation; url: string; orgId: string }): Promise<any> {
330330
return this.agentServiceService.oidcIssuerCreate(payload.issuerCreation, payload.url, payload.orgId);
331331
}
332-
@MessagePattern({ cmd: 'delete-oidc-issuer' })
333-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
334-
async oidcDeleteIssuer(payload: { url: string; orgId: string }): Promise<any> {
332+
@MessagePattern({ cmd: 'delete-oid4vc-issuer' })
333+
async oidcDeleteIssuer(payload: { url: string; orgId: string }): Promise<object | string> {
335334
return this.agentServiceService.deleteOidcIssuer(payload.url, payload.orgId);
336335
}
337-
@MessagePattern({ cmd: 'agent-create-oidc-template' })
336+
@MessagePattern({ cmd: 'agent-create-oid4vc-template' })
338337
// eslint-disable-next-line @typescript-eslint/no-explicit-any
339338
async oidcIssuerTemplate(payload: { templatePayload; url: string; orgId: string }): Promise<any> {
340339
return this.agentServiceService.oidcIssuerTemplate(payload.templatePayload, payload.url, payload.orgId);
341340
}
342-
//TODO: change message for oidc
343-
@MessagePattern({ cmd: 'oidc-get-issuer-by-id' })
341+
//TODO: change message for oid4vc
342+
@MessagePattern({ cmd: 'oid4vc-get-issuer-by-id' })
344343
// eslint-disable-next-line @typescript-eslint/no-explicit-any
345344
async oidcGetIssuerById(payload: { url: string; orgId: string }): Promise<any> {
346345
return this.agentServiceService.oidcGetIssuerById(payload.url, payload.orgId);
347346
}
348347

349-
@MessagePattern({ cmd: 'oidc-get-issuers' })
348+
@MessagePattern({ cmd: 'oid4vc-get-issuers-agent-service' })
350349
// eslint-disable-next-line @typescript-eslint/no-explicit-any
351350
async oidcGetIssuers(payload: { url: string; orgId: string }): Promise<any> {
352351
return this.agentServiceService.oidcGetIssuers(payload.url, payload.orgId);
353352
}
354353

355-
@MessagePattern({ cmd: 'agent-service-oidc-create-credential-offer' })
354+
@MessagePattern({ cmd: 'agent-service-oid4vc-create-credential-offer' })
356355
// eslint-disable-next-line @typescript-eslint/no-explicit-any
357356
async oidcCreateCredentialOffer(payload: { credentialPayload; url: string; orgId: string }): Promise<any> {
358357
return this.agentServiceService.oidcCreateCredentialOffer(payload.credentialPayload, payload.url, payload.orgId);
359358
}
359+
360+
@MessagePattern({ cmd: 'agent-service-oid4vc-update-credential-offer' })
361+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
362+
async oidcUpdateCredentialOffer(payload: { issuanceMetadata; url: string; orgId: string }): Promise<any> {
363+
return this.agentServiceService.oidcUpdateCredentialOffer(payload.issuanceMetadata, payload.url, payload.orgId);
364+
}
365+
366+
@MessagePattern({ cmd: 'agent-service-oid4vc-get-credential-offer-by-id' })
367+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
368+
async oidcGetCredentialOfferById(payload: { url: string; orgId: string; offerId: string }): Promise<any> {
369+
return this.agentServiceService.oidcGetCredentialOfferById(payload.url, payload.orgId);
370+
}
371+
372+
@MessagePattern({ cmd: 'agent-service-oid4vc-get-all-credential-offers' })
373+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
374+
async oidcGetAllCredentialOffers(payload: { url: string; orgId: string }): Promise<any> {
375+
return this.agentServiceService.oidcGetAllCredentialOffers(payload.url, payload.orgId);
376+
}
377+
378+
@MessagePattern({ cmd: 'agent-service-oid4vc-delete-credential-offer' })
379+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
380+
async oidcDeleteCredentialOffer(payload: { url: string; orgId: string }): Promise<any> {
381+
return this.agentServiceService.oidcDeleteCredentialOffer(payload.url, payload.orgId);
382+
}
360383
}

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

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,13 +1423,15 @@ export class AgentServiceService {
14231423
}
14241424
}
14251425

1426-
async deleteOidcIssuer(url: string, orgId: string): Promise<object> {
1426+
async deleteOidcIssuer(url: string, orgId: string): Promise<object | string> {
14271427
try {
14281428
const getApiKey = await this.getOrgAgentApiKey(orgId);
1429-
const data = await this.commonService
1430-
.httpDelete(url, { headers: { authorization: getApiKey } })
1431-
.then(async (response) => response);
1432-
return data;
1429+
const response = await this.commonService.httpDelete(url, {
1430+
headers: { authorization: getApiKey }
1431+
});
1432+
if (response?.status === 204) {
1433+
return 'Data deleted successfully';
1434+
}
14331435
} catch (error) {
14341436
this.logger.error(`Error in deleteOidcIssuer in agent service : ${JSON.stringify(error)}`);
14351437
throw error;
@@ -1475,6 +1477,58 @@ export class AgentServiceService {
14751477
}
14761478
}
14771479

1480+
async oidcUpdateCredentialOffer(issuanceMetadata, url: string, orgId: string): Promise<object> {
1481+
try {
1482+
const getApiKey = await this.getOrgAgentApiKey(orgId);
1483+
const data = await this.commonService
1484+
.httpPut(url, issuanceMetadata, { headers: { authorization: getApiKey } })
1485+
.then(async (response) => response);
1486+
return data;
1487+
} catch (error) {
1488+
this.logger.error(`Error in _oidcUpdateCredentialOffer in agent service : ${JSON.stringify(error)}`);
1489+
throw error;
1490+
}
1491+
}
1492+
1493+
async oidcGetCredentialOfferById(url: string, orgId: string): Promise<object> {
1494+
try {
1495+
const getApiKey = await this.getOrgAgentApiKey(orgId);
1496+
const data = await this.commonService
1497+
.httpGet(url, { headers: { authorization: getApiKey } })
1498+
.then(async (response) => response);
1499+
return data;
1500+
} catch (error) {
1501+
this.logger.error(`Error in _oidcGetCredentialOfferById in agent service : ${JSON.stringify(error)}`);
1502+
throw error;
1503+
}
1504+
}
1505+
1506+
async oidcGetAllCredentialOffers(url: string, orgId: string): Promise<object> {
1507+
try {
1508+
const getApiKey = await this.getOrgAgentApiKey(orgId);
1509+
const data = await this.commonService
1510+
.httpGet(url, { headers: { authorization: getApiKey } })
1511+
.then(async (response) => response);
1512+
return data;
1513+
} catch (error) {
1514+
this.logger.error(`Error in _oidcGetAllCredentialOffers in agent service : ${JSON.stringify(error)}`);
1515+
throw error;
1516+
}
1517+
}
1518+
1519+
async oidcDeleteCredentialOffer(url: string, orgId: string): Promise<object> {
1520+
try {
1521+
const getApiKey = await this.getOrgAgentApiKey(orgId);
1522+
const data = await this.commonService
1523+
.httpDelete(`${url}`, { headers: { authorization: getApiKey } })
1524+
.then(async (response) => response);
1525+
return data;
1526+
} catch (error) {
1527+
this.logger.error(`Error in _oidcDeleteCredentialOffer in agent service : ${JSON.stringify(error)}`);
1528+
throw error;
1529+
}
1530+
}
1531+
14781532
async oidcIssuerTemplate(templatePayload, url: string, orgId: string): Promise<object> {
14791533
try {
14801534
const getApiKey = await this.getOrgAgentApiKey(orgId);

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { ContextModule } from '@credebl/context/contextModule';
3232
import { LoggerModule } from '@credebl/logger/logger.module';
3333
import { GlobalConfigModule } from '@credebl/config/global-config.module';
3434
import { ConfigModule as PlatformConfig } from '@credebl/config/config.module';
35+
import { Oid4vcIssuanceModule } from './oid4vc-issuance/oid4vc-issuance.module';
3536

3637
@Module({
3738
imports: [
@@ -64,7 +65,8 @@ import { ConfigModule as PlatformConfig } from '@credebl/config/config.module';
6465
GlobalConfigModule,
6566
CacheModule.register({ store: redisStore, host: process.env.REDIS_HOST, port: process.env.REDIS_PORT }),
6667
GeoLocationModule,
67-
CloudWalletModule
68+
CloudWalletModule,
69+
Oid4vcIssuanceModule
6870
],
6971
controllers: [AppController],
7072
providers: [

0 commit comments

Comments
 (0)