Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge: DEV to QA #951

Merged
merged 23 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f01af60
Merge branch 'develop' of https://github.com/credebl/platform into de…
ganeshawle25 Aug 16, 2024
aa6e500
refactor: applied validations on issuance date (#934)
bhavanakarwade Aug 23, 2024
553743f
Merge branch 'develop' of https://github.com/credebl/platform into de…
ganeshawle25 Aug 26, 2024
976c920
fix: encrypt clientId and client secret
Aug 26, 2024
aa3528a
fix:collect reuse connection events
pallavighule Aug 26, 2024
d03e5a9
Merge pull request #938 from credebl/fix/encrypt-clientId-clientSecret
KulkarniShashank Aug 26, 2024
3ffc91a
Merge pull request #939 from credebl/fix/collect-reuse-connection-web…
pallavighule Aug 26, 2024
4050e43
feat: reuse connection usinginvitation DID (#940)
tipusinghaw Aug 26, 2024
e5e7208
fix: unable to use platform archieved schema
GHkrishna Aug 26, 2024
2132880
Merge branch 'develop' of https://github.com/credebl/platform into fi…
GHkrishna Aug 26, 2024
57da02f
fix: solved the clientId dcryption in verification email
Aug 26, 2024
f45ad30
Merge pull request #941 from credebl/fix/platform-schema-issuance
GHkrishna Aug 26, 2024
025656a
Merge pull request #942 from credebl/fix/encrypt-clientId-clientSecret
KulkarniShashank Aug 26, 2024
35a2518
feat: basic message (#848)
tipusinghaw Aug 26, 2024
04c9327
refactor: fetch proof details function (#943)
bhavanakarwade Aug 26, 2024
a96654b
fix: basic message url (#944)
tipusinghaw Aug 27, 2024
834f886
fix: add no_ledger type in seed file
Aug 27, 2024
0c0e4c1
feat: migration logic for `org_dids` and schema type (#946)
tipusinghaw Aug 27, 2024
1e71897
Merge pull request #947 from credebl/fix/add-no-ledger-type-seed
KulkarniShashank Aug 27, 2024
9bac436
fix: migration did for organization DIDs (#948)
tipusinghaw Aug 27, 2024
9ee7d2d
fix: changed message pattern for basic-message (#950)
tipusinghaw Aug 27, 2024
1246a50
feat: reuse connection for issuance (#949)
bhavanakarwade Aug 27, 2024
18d8c0a
fix: resolved conflicts
bhavanakarwade Aug 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions apps/agent-service/src/agent-service.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1812,13 +1812,13 @@ export class AgentServiceService {
}
}

async sendBasicMessage(questionPayload: IBasicMessage, url: string, orgId: string): Promise<object> {
async sendBasicMessage(messagePayload: IBasicMessage, url: string, orgId: string): Promise<object> {
try {
const getApiKey = await this.getOrgAgentApiKey(orgId);
const sendQuestionRes = await this.commonService
.httpPost(url, questionPayload, { headers: { authorization: getApiKey } })
const basicMessageRes = await this.commonService
.httpPost(url, messagePayload, { headers: { authorization: getApiKey } })
.then(async (response) => response);
return sendQuestionRes;
return basicMessageRes;
} catch (error) {
this.logger.error(`Error in sendBasicMessage in agent service : ${JSON.stringify(error)}`);
throw error;
Expand Down
2 changes: 1 addition & 1 deletion apps/api-gateway/src/connection/connection.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ export class ConnectionController {
}

@Post('/orgs/:orgId/basic-message/:connectionId')
@ApiOperation({ summary: '', description: 'send question' })
@ApiOperation({ summary: 'Send basic message', description: 'Send basic message' })
@UseGuards(AuthGuard('jwt'), OrgRolesGuard)
@Roles(OrgRoles.OWNER, OrgRoles.ADMIN, OrgRoles.ISSUER, OrgRoles.VERIFIER, OrgRoles.MEMBER, OrgRoles.HOLDER, OrgRoles.SUPER_ADMIN, OrgRoles.PLATFORM_ADMIN)
@ApiResponse({ status: HttpStatus.CREATED, description: 'Created', type: ApiResponseDto })
Expand Down
2 changes: 1 addition & 1 deletion apps/api-gateway/src/connection/connection.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class ConnectionService extends BaseService {
basicMessageDto: BasicMessageDto
): Promise<object> {
try {
return this.sendNatsMessage(this.connectionServiceProxy, 'send-basic-message', basicMessageDto);
return this.sendNatsMessage(this.connectionServiceProxy, 'send-basic-message-on-connection', basicMessageDto);
} catch (error) {
throw new RpcException(error.response);
}
Expand Down
6 changes: 6 additions & 0 deletions apps/api-gateway/src/issuance/dtos/issuance.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,12 @@ export class OOBCredentialDtoWithEmail {
@IsOptional()
credentialType: IssueCredentialType;

@ApiPropertyOptional({ default: true })
@IsOptional()
@IsNotEmpty({ message: 'please provide valid value for isReuseConnection' })
@IsBoolean({ message: 'isReuseConnection must be a boolean' })
isReuseConnection?: boolean;

imageUrl?: string;

orgId: string;
Expand Down
4 changes: 2 additions & 2 deletions apps/api-gateway/src/issuance/issuance.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -633,9 +633,9 @@ async downloadBulkIssuanceCSVTemplate(
async outOfBandCredentialOffer(
@User() user: IUserRequest,
@Body() outOfBandCredentialDto: OOBCredentialDtoWithEmail,
@Query('credentialType') credentialType: IssueCredentialType = IssueCredentialType.INDY,
@Param('orgId') orgId: string,
@Res() res: Response
@Res() res: Response,
@Query('credentialType') credentialType: IssueCredentialType = IssueCredentialType.INDY
): Promise<Response> {
outOfBandCredentialDto.orgId = orgId;
outOfBandCredentialDto.credentialType = credentialType;
Expand Down
2 changes: 1 addition & 1 deletion apps/connection/src/connection.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class ConnectionController {
return this.connectionService.deleteConnectionRecords(orgId, userDetails);
}

@MessagePattern({ cmd: 'send-basic-message' })
@MessagePattern({ cmd: 'send-basic-message-on-connection' })
async sendBasicMessage(payload: {content: string, orgId: string, connectionId: string}): Promise<object> {
return this.connectionService.sendBasicMesage(payload);
}
Expand Down
3 changes: 3 additions & 0 deletions apps/issuance/interfaces/issuance.interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export interface OutOfBandCredentialOfferPayload {
emailId?: string;
attributes?: IAttributes[];
protocolVersion?: string;
isReuseConnection?: boolean;
goalCode?: string,
parentThreadId?: string,
willConfirm?: boolean,
Expand Down Expand Up @@ -282,6 +283,7 @@ export interface SendEmailCredentialOffer {
index: number;
credentialType: IssueCredentialType;
protocolVersion: string;
isReuseConnection?: boolean;
attributes: IAttributes[];
credentialDefinitionId: string;
outOfBandCredential: OutOfBandCredentialOfferPayload;
Expand Down Expand Up @@ -341,6 +343,7 @@ export interface IQueuePayload{
certificate?: string;
size?: string;
orientation?: string;
isReuseConnection?: boolean;
}

interface FileDetails {
Expand Down
32 changes: 24 additions & 8 deletions apps/issuance/src/issuance.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,8 @@ async outOfBandCredentialOffer(outOfBandCredential: OutOfBandCredentialOfferPayl
protocolVersion,
attributes,
emailId,
credentialType
credentialType,
isReuseConnection
} = outOfBandCredential;

if (IssueCredentialType.JSONLD === credentialType) {
Expand Down Expand Up @@ -637,6 +638,7 @@ async outOfBandCredentialOffer(outOfBandCredential: OutOfBandCredentialOfferPayl
index: number;
credentialType: IssueCredentialType;
protocolVersion: string;
isReuseConnection?: boolean;
attributes: IAttributes[];
credentialDefinitionId: string;
outOfBandCredential: OutOfBandCredentialOfferPayload;
Expand All @@ -652,6 +654,7 @@ async outOfBandCredentialOffer(outOfBandCredential: OutOfBandCredentialOfferPayl
} = {
credentialType,
protocolVersion,
isReuseConnection,
attributes,
credentialDefinitionId,
outOfBandCredential,
Expand Down Expand Up @@ -735,12 +738,22 @@ async sendEmailForCredentialOffer(sendEmailCredentialOffer: SendEmailCredentialO
orgId,
organizationDetails,
platformName,
organizationLogoUrl
organizationLogoUrl,
isReuseConnection
} = sendEmailCredentialOffer;
const iterationNo = index + 1;
try {


let invitationDid: string | undefined;
if (true === isReuseConnection) {
const data: agent_invitations[] = await this.issuanceRepository.getInvitationDidByOrgId(orgId);
if (data && 0 < data.length) {
const [firstElement] = data;
invitationDid = firstElement?.invitationDid ?? undefined;
}
}

let outOfBandIssuancePayload;
if (IssueCredentialType.INDY === credentialType) {

Expand All @@ -759,7 +772,8 @@ async sendEmailForCredentialOffer(sendEmailCredentialOffer: SendEmailCredentialO
parentThreadId: outOfBandCredential.parentThreadId || undefined,
willConfirm: outOfBandCredential.willConfirm || undefined,
label: organisation?.name,
imageUrl: organisation?.logoUrl || outOfBandCredential?.imageUrl
imageUrl: organisation?.logoUrl || outOfBandCredential?.imageUrl,
invitationDid: invitationDid || undefined
};
}

Expand All @@ -779,7 +793,8 @@ async sendEmailForCredentialOffer(sendEmailCredentialOffer: SendEmailCredentialO
parentThreadId: outOfBandCredential.parentThreadId || undefined,
willConfirm: outOfBandCredential.willConfirm || undefined,
label: organisation?.name,
imageUrl: organisation?.logoUrl || outOfBandCredential?.imageUrl
imageUrl: organisation?.logoUrl || outOfBandCredential?.imageUrl,
invitationDid: invitationDid || undefined
};

const payloadAttributes = outOfBandIssuancePayload?.credentialFormats?.jsonld?.credential?.credentialSubject;
Expand Down Expand Up @@ -1519,7 +1534,6 @@ return newCacheKey;
const { orgId } = jobDetails;

const agentDetails = await this.issuanceRepository.getAgentEndPoint(orgId);

const { organisation, orgDid } = agentDetails;
let prettyVc;
let isErrorOccurred = false;
Expand All @@ -1532,7 +1546,8 @@ return newCacheKey;
label: organisation?.name,
attributes: [],
emailId: jobDetails?.credential_data?.email_identifier,
credentialType: IssueCredentialType.INDY
credentialType: IssueCredentialType.INDY,
isReuseConnection: true
};
for (const key in jobDetails?.credential_data) {

Expand All @@ -1549,8 +1564,8 @@ return newCacheKey;
schemaLedgerId,
credentialData: jobDetails.credential_data,
orgDid,
orgId

orgId,
isReuseConnection: true
};

prettyVc = {
Expand All @@ -1561,6 +1576,7 @@ return newCacheKey;

oobIssuancepayload = await createOobJsonldIssuancePayload(JsonldCredentialDetails, prettyVc);
}

const oobCredentials = await this.outOfBandCredentialOffer(
oobIssuancepayload, jobDetails?.platformName, jobDetails?.organizationLogoUrl, prettyVc);
if (oobCredentials) {
Expand Down
6 changes: 6 additions & 0 deletions apps/verification/src/verification.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,12 @@ export class VerificationService {

const verifiableCredential = verifiableCredentials[index]?.credentialSubject;

if (getProofPresentationById?.response) {
certificate =
getProofPresentationById?.response?.presentation?.presentationExchange?.verifiableCredential[0].prettyVc
?.certificate;
}

if (
requestedAttributesForPresentationExchangeFormat &&
Array.isArray(requestedAttributesForPresentationExchangeFormat)
Expand Down
5 changes: 3 additions & 2 deletions libs/common/src/cast.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ export const validateEmail = (email: string): boolean => {

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/explicit-function-return-type
export const createOobJsonldIssuancePayload = (JsonldCredentialDetails: IJsonldCredential, prettyVc: IPrettyVc) => {
const {credentialData, orgDid, orgId, schemaLedgerId, schemaName} = JsonldCredentialDetails;
const {credentialData, orgDid, orgId, schemaLedgerId, schemaName, isReuseConnection} = JsonldCredentialDetails;
const credentialSubject = { };

const proofType = (orgDid?.includes(DidMethod.POLYGON)) ? ProofType.POLYGON_PROOFTYPE : ProofType.NO_LEDGER_PROOFTYPE;
Expand Down Expand Up @@ -339,7 +339,8 @@ export const createOobJsonldIssuancePayload = (JsonldCredentialDetails: IJsonldC
'comment': 'string',
'protocolVersion': 'v2',
'credentialType': 'jsonld',
orgId
orgId,
isReuseConnection
};
};

Expand Down
1 change: 1 addition & 0 deletions libs/common/src/interfaces/issuance.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface IIssuedCredential {
credentialData: CredentialData
orgDid: string;
orgId: string;
isReuseConnection?: boolean;
}

export interface ICredentialOfferResponse {
Expand Down
10 changes: 5 additions & 5 deletions libs/prisma-service/prisma/data/credebl-master-table.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@
},
{
"name": "NA",
"networkType": "",
"poolConfig": "",
"networkType": "NA",
"poolConfig": "NA",
"isActive": true,
"networkString": "",
"nymTxnEndpoint": "",
"indyNamespace": ""
"networkString": "NA",
"nymTxnEndpoint": "NA",
"indyNamespace": "no_ledger"
}
],
"endorseData": [
Expand Down
78 changes: 77 additions & 1 deletion libs/prisma-service/prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,81 @@ const createUserRole = async (): Promise<void> => {
}
};

const migrateOrgAgentDids = async (): Promise<void> => {
try {
const orgAgents = await prisma.org_agents.findMany({
where: {
walletName: {
not: 'platform-admin'
}
}
});

const orgDids = orgAgents.map((agent) => agent.orgDid).filter((did) => null !== did && '' !== did);
const existingDids = await prisma.org_dids.findMany({
where: {
did: {
in: orgDids
}
}
});

// If there are org DIDs that do not exist in org_dids table
if (orgDids.length !== existingDids.length) {
const newOrgAgents = orgAgents.filter(
(agent) => !existingDids.some((did) => did.did === agent.orgDid)
);

const newDidRecords = newOrgAgents.map((agent) => ({
orgId: agent.orgId,
did: agent.orgDid,
didDocument: agent.didDocument,
isPrimaryDid: true,
createdBy: agent.createdBy,
lastChangedBy: agent.lastChangedBy,
orgAgentId: agent.id
}));

const didInsertResult = await prisma.org_dids.createMany({
data: newDidRecords
});

logger.log(didInsertResult);
} else {
logger.log('No new DIDs to migrate in migrateOrgAgentDids');
}
} catch (error) {
logger.error('An error occurred during migrateOrgAgentDids:', error);
}
};

const addSchemaType = async (): Promise<void> => {
try {
const emptyTypeSchemaList = await prisma.schema.findMany({
where: {
OR: [
{ type: null },
{ type: '' }
]
}
});
if (0 < emptyTypeSchemaList.length) {
const updatePromises = emptyTypeSchemaList.map((schema) => prisma.schema.update({
where: { id: schema.id },
data: { type: 'indy' }
})
);
await Promise.all(updatePromises);

logger.log('Schemas updated successfully');
} else {
logger.log('No schemas to update');
}
} catch (error) {
logger.error('An error occurred during addSchemaType:', error);
}
};

async function main(): Promise<void> {

await createPlatformConfig();
Expand All @@ -388,9 +463,10 @@ async function main(): Promise<void> {
await createEcosystemConfig();
await createLedgerConfig();
await createUserRole();
await migrateOrgAgentDids();
await addSchemaType();
}


main()
.then(async () => {
await prisma.$disconnect();
Expand Down