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 #196

Merged
merged 26 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1199410
fix:added-reuse-connection-event
pallavighule Aug 26, 2024
2fa51a8
Merge pull request #176 from credebl/fix/add-reuse-connection-event
pallavighule Aug 26, 2024
6ed8375
fix: added patch for avoiding proof abandoned issue (#177)
pallavighule Aug 26, 2024
a063528
fix:added cache tenant record patch
pallavighule Aug 26, 2024
5720788
Merge pull request #178 from credebl/fix/add-cache-tenant-record-patch
pallavighule Aug 26, 2024
110ece2
fix: w3c issuance without holderDID (#179)
GHkrishna Aug 27, 2024
074365a
updated Taskdef.json
KambleSahil3 Aug 27, 2024
5eaf0a1
Merge branch 'develop' of https://github.com/credebl/credo-controller…
KambleSahil3 Aug 27, 2024
0a0f501
Merge pull request #180 from credebl/fix/taskdef-changes
KambleSahil3 Aug 27, 2024
0d86854
updated Taskdef.json
KambleSahil3 Aug 27, 2024
a7647ba
fix:added-reuse-connection-event
pallavighule Aug 26, 2024
84d0363
fix: added patch for avoiding proof abandoned issue (#177)
pallavighule Aug 26, 2024
a125fea
fix:added cache tenant record patch
pallavighule Aug 26, 2024
92b0d97
fix: w3c issuance without holderDID (#179)
GHkrishna Aug 27, 2024
a9bc74e
Update .env.sample file
KulkarniShashank Aug 16, 2024
ed663f2
merge: solve DCO
GHkrishna Aug 27, 2024
e279b0a
refactor: Implemented white labeling in taskdef.json file
KambleSahil3 Aug 27, 2024
0251133
Merge pull request #189 from credebl/fix/taskdef-changes
KambleSahil3 Aug 27, 2024
2161c20
fix: sign off develop (#190)
GHkrishna Aug 27, 2024
6095473
Merge branch 'qa' into develop
sairanjit Aug 27, 2024
3dfab3c
refactor: Updated taskdef.josn file
KambleSahil3 Aug 28, 2024
06afceb
Merge branch 'develop' of https://github.com/credebl/credo-controller…
KambleSahil3 Aug 28, 2024
da85d01
Merge pull request #194 from credebl/fix/taskdef-changes
KambleSahil3 Aug 28, 2024
7235256
feat: added reuse connection for dedicated agent (#193)
bhavanakarwade Aug 29, 2024
1db6eac
refactor: replace the bcovrin network url
KulkarniShashank Aug 29, 2024
62475d8
Merge pull request #197 from credebl/refactor/bcovrin-network-url
KulkarniShashank Aug 29, 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/node_modules/@credo-ts/core/build/modules/proofs/formats/dif-presentation-exchange/DifPresentationExchangeProofFormatService.js b/node_modules/@credo-ts/core/build/modules/proofs/formats/dif-presentation-exchange/DifPresentationExchangeProofFormatService.js
index 006d870..da56801 100644
--- a/node_modules/@credo-ts/core/build/modules/proofs/formats/dif-presentation-exchange/DifPresentationExchangeProofFormatService.js
+++ b/node_modules/@credo-ts/core/build/modules/proofs/formats/dif-presentation-exchange/DifPresentationExchangeProofFormatService.js
@@ -170,7 +170,8 @@ class DifPresentationExchangeProofFormatService {
try {
ps.validatePresentationDefinition(request.presentation_definition);
ps.validatePresentationSubmission(jsonPresentation.presentation_submission);
- ps.validatePresentation(request.presentation_definition, parsedPresentation);
+ // FIXME: Commenting validatePresentation() for now due to intermittent abandoned issue
+ //ps.validatePresentation(request.presentation_definition, parsedPresentation);
let verificationResult;
// FIXME: for some reason it won't accept the input if it doesn't know
// whether it's a JWT or JSON-LD VP even though the input is the same.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
diff --git a/node_modules/@credo-ts/core/build/modules/credentials/protocol/v2/V2CredentialProtocol.js b/node_modules/@credo-ts/core/build/modules/credentials/protocol/v2/V2CredentialProtocol.js
index fb1fb9d..260fe21 100644
index fb1fb9d..b519694 100644
--- a/node_modules/@credo-ts/core/build/modules/credentials/protocol/v2/V2CredentialProtocol.js
+++ b/node_modules/@credo-ts/core/build/modules/credentials/protocol/v2/V2CredentialProtocol.js
@@ -444,6 +444,7 @@ class V2CredentialProtocol extends BaseCredentialProtocol_1.BaseCredentialProtoc
@@ -97,7 +97,6 @@ class V2CredentialProtocol extends BaseCredentialProtocol_1.BaseCredentialProtoc
let credentialRecord = await this.findByProperties(messageContext.agentContext, {
threadId: requestMessage.threadId,
threadId: proposalMessage.threadId,
role: models_1.CredentialRole.Issuer,
+ connectionId: connection?.id
- connectionId: connection === null || connection === void 0 ? void 0 : connection.id,
});
const formatServices = this.getFormatServicesFromMessage(requestMessage.formats);
const formatServices = this.getFormatServicesFromMessage(proposalMessage.formats);
if (formatServices.length === 0) {
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
diff --git a/node_modules/@credo-ts/tenants/build/context/TenantAgentContextProvider.d.ts b/node_modules/@credo-ts/tenants/build/context/TenantAgentContextProvider.d.ts
index 91bb8f4..b4dae61 100644
--- a/node_modules/@credo-ts/tenants/build/context/TenantAgentContextProvider.d.ts
+++ b/node_modules/@credo-ts/tenants/build/context/TenantAgentContextProvider.d.ts
@@ -1,5 +1,5 @@
import type { TenantRecord } from '../repository';
-import type { AgentContextProvider, UpdateAssistantUpdateOptions } from '@credo-ts/core';
+import type { AgentContextProvider, UpdateAssistantUpdateOptions , CacheModule, InMemoryLruCache } from '@credo-ts/core';
import { AgentContext, EventEmitter, Logger } from '@credo-ts/core';
import { TenantRecordService } from '../services';
import { TenantSessionCoordinator } from './TenantSessionCoordinator';
@@ -9,7 +9,9 @@ export declare class TenantAgentContextProvider implements AgentContextProvider
private eventEmitter;
private logger;
private tenantSessionCoordinator;
- constructor(tenantRecordService: TenantRecordService, rootAgentContext: AgentContext, eventEmitter: EventEmitter, tenantSessionCoordinator: TenantSessionCoordinator, logger: Logger);
+ private cacheModule;
+ private inMemoryLruCache;
+ constructor(tenantRecordService: TenantRecordService, rootAgentContext: AgentContext, eventEmitter: EventEmitter, tenantSessionCoordinator: TenantSessionCoordinator, logger: Logger, cache: InMemoryLruCache);
getAgentContextForContextCorrelationId(contextCorrelationId: string): Promise<AgentContext>;
getContextForInboundMessage(inboundMessage: unknown, options?: {
contextCorrelationId?: string;
diff --git a/node_modules/@credo-ts/tenants/build/context/TenantAgentContextProvider.js b/node_modules/@credo-ts/tenants/build/context/TenantAgentContextProvider.js
index d491d4e..d60ec79 100644
--- a/node_modules/@credo-ts/tenants/build/context/TenantAgentContextProvider.js
+++ b/node_modules/@credo-ts/tenants/build/context/TenantAgentContextProvider.js
@@ -24,16 +24,28 @@ let TenantAgentContextProvider = class TenantAgentContextProvider {
this.eventEmitter = eventEmitter;
this.tenantSessionCoordinator = tenantSessionCoordinator;
this.logger = logger;
+ this.cache = new core_1.CacheModule({
+ cache: new core_1.InMemoryLruCache({ limit: 100 }),
+ });
// Start listener for newly created routing keys, so we can register a mapping for each new key for the tenant
this.listenForRoutingKeyCreatedEvents();
}
async getAgentContextForContextCorrelationId(contextCorrelationId) {
+ this.logger.debug('debug ========= Inside getAgentContextForContextCorrelationId')
// It could be that the root agent context is requested, in that case we return the root agent context
if (contextCorrelationId === this.rootAgentContext.contextCorrelationId) {
return this.rootAgentContext;
}
// TODO: maybe we can look at not having to retrieve the tenant record if there's already a context available.
- const tenantRecord = await this.tenantRecordService.getTenantById(this.rootAgentContext, contextCorrelationId);
+ this.logger.debug('debug ========= Get tenantRecord from cache')
+ let tenantRecord = await this.cache.config.cache.get(this.rootAgentContext, `contextCorrelationId-${contextCorrelationId}`)
+ if(!tenantRecord) {
+ // TODO: maybe we can look at not having to retrieve the tenant record if there's already a context available.
+ this.logger.debug('debug ========= TenantRecord not found in cache')
+ tenantRecord = await this.tenantRecordService.getTenantById(this.rootAgentContext, contextCorrelationId)
+ await this.cache.config.cache.set(this.rootAgentContext,`contextCorrelationId-${contextCorrelationId}`,tenantRecord)
+ this.logger.debug(`debug ========= Cached tenant agent context for tenant '${contextCorrelationId}'`)
+ }
const shouldUpdate = !(0, core_1.isStorageUpToDate)(tenantRecord.storageVersion);
// If the tenant storage is not up to date, and autoUpdate is disabled we throw an error
if (shouldUpdate && !this.rootAgentContext.config.autoUpdateStorageOnStartup) {
2 changes: 1 addition & 1 deletion samples/cliConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"indyNamespace": "indicio:demonet"
},
{
"genesisTransactions": "http://test.bcovrin.vonx.io/genesis",
"genesisTransactions": "https://raw.githubusercontent.com/bcgov/von-network/main/BCovrin/genesis_test",
"indyNamespace": "bcovrin:testnet"
}
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"family": "DEV_AGENT_SPINUP_TASKDEF",
"family": "${FAMILY}",
"containerDefinitions": [
{
"name": "e7cc1515-a197-4580-9e63-dda70c9c7f08-Platform-admin-service-ODg2YmE4ZDU3",
"name": "Platform-admin",
"image": "%REPOSITORY_URI%:CREDO_v_%BUILD_NUMBER%",
"cpu": 154,
"memory": 307,
"portMappings": [
{
"containerPort": 8004,
"hostPort": 8004,
"containerPort": 8001,
"hostPort": 8001,
"protocol": "tcp"
},
{
"containerPort": 9004,
"hostPort": 9004,
"containerPort": 9001,
"hostPort": 9001,
"protocol": "tcp"
}
],
Expand Down Expand Up @@ -59,7 +59,7 @@
{
"name": "config",
"host": {
"sourcePath": "/home/ec2-user/config/e7cc1515-a197-4580-9e63-dda70c9c7f08_Platform-admin.json"
"sourcePath": "${SourcePath}"
}
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"family": "QA-AFJ-TASKDEFINITION",
"family": "${FAMILY}",
"containerDefinitions": [
{
"name": "Platform-admin",
Expand All @@ -21,7 +21,7 @@
"command": [
"--auto-accept-connections",
"--config",
"/config/c15f48c9-1d0e-46b6-8915-b7689e255a22_Platform-admin.json"
"/config/${CONFIG_FILE}"
],
"environment": [
{
Expand All @@ -47,7 +47,7 @@
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/QA-AFJ-TASKDEFINITION",
"awslogs-group": "/ecs/${FAMILY}",
"awslogs-create-group": "true",
"awslogs-region": "ap-south-1",
"awslogs-stream-prefix": "ecs"
Expand All @@ -62,8 +62,8 @@
"requiresCompatibilities": [
"FARGATE"
],
"cpu": "2048",
"memory": "4096",
"cpu": "1024",
"memory": "2048",
"volumes": [
{
"name": "config",
Expand Down
48 changes: 37 additions & 11 deletions src/controllers/credentials/CredentialController.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
import type { RestAgentModules } from '../../cliAgent'
import type { CredentialExchangeRecordProps, CredentialProtocolVersionType, Routing } from '@credo-ts/core'
import type {
CredentialExchangeRecordProps,
CredentialProtocolVersionType,
PeerDidNumAlgo2CreateOptions,
Routing,
} from '@credo-ts/core'

import { CredentialState, Agent, W3cCredentialService, Key, KeyType, CredentialRole } from '@credo-ts/core'
import {
CredentialState,
Agent,
W3cCredentialService,
CredentialRole,
createPeerDidDocumentFromServices,
PeerDidNumAlgo,
} from '@credo-ts/core'
import { injectable } from 'tsyringe'

import ErrorHandlingService from '../../errorHandlingService'
Expand Down Expand Up @@ -165,21 +177,35 @@ export class CredentialController extends Controller {
@Post('/create-offer-oob')
public async createOfferOob(@Body() outOfBandOption: CreateOfferOobOptions) {
try {
let invitationDid: string | undefined
let routing: Routing
const linkSecretIds = await this.agent.modules.anoncreds.getLinkSecretIds()
if (linkSecretIds.length === 0) {
await this.agent.modules.anoncreds.createLinkSecret()
}
if (outOfBandOption?.recipientKey) {
routing = {
endpoints: this.agent.config.endpoints,
routingKeys: [],
recipientKey: Key.fromPublicKeyBase58(outOfBandOption.recipientKey, KeyType.Ed25519),
mediatorId: undefined,
}

if (outOfBandOption?.invitationDid) {
invitationDid = outOfBandOption?.invitationDid
} else {
routing = await this.agent.mediationRecipient.getRouting({})
const didDocument = createPeerDidDocumentFromServices([
{
id: 'didcomm',
recipientKeys: [routing.recipientKey],
routingKeys: routing.routingKeys,
serviceEndpoint: routing.endpoints[0],
},
])
const did = await this.agent.dids.create<PeerDidNumAlgo2CreateOptions>({
didDocument,
method: 'peer',
options: {
numAlgo: PeerDidNumAlgo.MultipleInceptionKeyWithoutDoc,
},
})
invitationDid = did.didState.did
}

const offerOob = await this.agent.credentials.createOffer({
protocolVersion: outOfBandOption.protocolVersion as CredentialProtocolVersionType<[]>,
credentialFormats: outOfBandOption.credentialFormats,
Expand All @@ -193,7 +219,7 @@ export class CredentialController extends Controller {
messages: [credentialMessage],
autoAcceptConnection: true,
imageUrl: outOfBandOption?.imageUrl,
routing,
invitationDid,
})
return {
invitationUrl: outOfBandRecord.outOfBandInvitation.toUrl({
Expand All @@ -203,7 +229,7 @@ export class CredentialController extends Controller {
useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed,
}),
outOfBandRecord: outOfBandRecord.toJSON(),
recipientKey: outOfBandOption?.recipientKey ? {} : { recipientKey: routing.recipientKey.publicKeyBase58 },
invitationDid: outOfBandOption?.invitationDid ? '' : invitationDid,
}
} catch (error) {
throw ErrorHandlingService.handle(error)
Expand Down
35 changes: 25 additions & 10 deletions src/controllers/proofs/ProofController.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type {
AcceptProofRequestOptions,
PeerDidNumAlgo2CreateOptions,
ProofExchangeRecordProps,
ProofsProtocolVersionType,
Routing,
} from '@credo-ts/core'

import { Agent, Key, KeyType } from '@credo-ts/core'
import { Agent, PeerDidNumAlgo, createPeerDidDocumentFromServices } from '@credo-ts/core'
import { injectable } from 'tsyringe'

import ErrorHandlingService from '../../errorHandlingService'
Expand Down Expand Up @@ -148,16 +149,30 @@ export class ProofController extends Controller {
public async createRequest(@Body() createRequestOptions: CreateProofRequestOobOptions) {
try {
let routing: Routing
if (createRequestOptions?.recipientKey) {
routing = {
endpoints: this.agent.config.endpoints,
routingKeys: [],
recipientKey: Key.fromPublicKeyBase58(createRequestOptions.recipientKey, KeyType.Ed25519),
mediatorId: undefined,
}
let invitationDid: string | undefined

if (createRequestOptions?.invitationDid) {
invitationDid = createRequestOptions?.invitationDid
} else {
routing = await this.agent.mediationRecipient.getRouting({})
const didDocument = createPeerDidDocumentFromServices([
{
id: 'didcomm',
recipientKeys: [routing.recipientKey],
routingKeys: routing.routingKeys,
serviceEndpoint: routing.endpoints[0],
},
])
const did = await this.agent.dids.create<PeerDidNumAlgo2CreateOptions>({
didDocument,
method: 'peer',
options: {
numAlgo: PeerDidNumAlgo.MultipleInceptionKeyWithoutDoc,
},
})
invitationDid = did.didState.did
}

const proof = await this.agent.proofs.createRequest({
protocolVersion: createRequestOptions.protocolVersion as ProofsProtocolVersionType<[]>,
proofFormats: createRequestOptions.proofFormats,
Expand All @@ -173,7 +188,7 @@ export class ProofController extends Controller {
messages: [proofMessage],
autoAcceptConnection: true,
imageUrl: createRequestOptions?.imageUrl,
routing,
invitationDid,
})

return {
Expand All @@ -184,7 +199,7 @@ export class ProofController extends Controller {
useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed,
}),
outOfBandRecord: outOfBandRecord.toJSON(),
recipientKey: createRequestOptions?.recipientKey ? {} : { recipientKey: routing.recipientKey.publicKeyBase58 },
invitationDid: createRequestOptions?.invitationDid ? '' : invitationDid,
}
} catch (error) {
throw ErrorHandlingService.handle(error)
Expand Down
2 changes: 1 addition & 1 deletion src/events/ReuseConnectionEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { sendWebhookEvent } from './WebhookEvent'
export const reuseConnectionEvents = async (agent: Agent, config: ServerConfig) => {
agent.events.on(OutOfBandEventTypes.HandshakeReused, async (event: HandshakeReusedEvent) => {
const body = {
connectionRecord: event.payload.connectionRecord.toJSON(),
...event.payload.connectionRecord.toJSON(),
outOfBandRecord: event.payload.outOfBandRecord.toJSON(),
reuseThreadId: event.payload.reuseThreadId,
...event.metadata,
Expand Down