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

fix: sign off develop #190

Merged
merged 26 commits into from
Aug 27, 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
6a66109
updated Taskdef.json
KambleSahil3 Aug 27, 2024
93921cc
fix: externalise env
GHkrishna Jul 17, 2024
b476415
fix: externalise env
GHkrishna Jul 17, 2024
d50b518
fix: number conversion
GHkrishna Jul 17, 2024
ede08f6
fix: remove logs
GHkrishna Jul 17, 2024
1178723
fix: sample env variable
GHkrishna Jul 17, 2024
aadc53f
fix: remove comments
GHkrishna Jul 17, 2024
846c59b
fix: remove comments
GHkrishna Jul 17, 2024
91b5020
chore: github warnings
GHkrishna Jul 17, 2024
1883c7d
chore: fix preetier
GHkrishna Jul 17, 2024
1d1a902
chore: fix preetier
GHkrishna Jul 17, 2024
2e76b36
fix: provision to default to 'Infinity' if required
GHkrishna Aug 13, 2024
041c5e9
wip: added json limit configurations
bhavanakarwade Jul 25, 2024
a2b71e4
fix:added-patch
pallavighule Jul 25, 2024
72bbc68
fix:added patch for prettyVc
pallavighule Jul 25, 2024
85ee4ce
fix:added patch for prettyVc
pallavighule Jul 25, 2024
73e6e65
fix: yarn lock
GHkrishna Aug 13, 2024
159ad56
fix: added assertion method in did web
tipusinghaw Aug 23, 2024
1ada15f
fix:added-reuse-connection-event
pallavighule Aug 26, 2024
950e576
fix: added patch for avoiding proof abandoned issue (#177)
pallavighule Aug 26, 2024
b4962e2
fix:added cache tenant record patch
pallavighule Aug 26, 2024
69ae0b9
fix: w3c issuance without holderDID (#179)
GHkrishna Aug 27, 2024
75ad818
Update .env.sample file
KulkarniShashank Aug 16, 2024
cf5c5ac
refactor: Implemented white labeling in taskdef.json file
KambleSahil3 Aug 27, 2024
1bbda9b
fix: update sample env
GHkrishna Aug 27, 2024
e251451
fix: update sample env
GHkrishna Aug 27, 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
58 changes: 37 additions & 21 deletions src/utils/util.ts → .env.sample

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"axios": "^1.4.0",
"body-parser": "^1.20.0",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"express": "^4.18.1",
"express-rate-limit": "^7.1.5",
"joi": "^17.12.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/node_modules/@credo-ts/core/build/modules/credentials/formats/jsonld/JsonLdCredentialFormat.d.ts b/node_modules/@credo-ts/core/build/modules/credentials/formats/jsonld/JsonLdCredentialFormat.d.ts
index d12468b..ae70f36 100644
--- a/node_modules/@credo-ts/core/build/modules/credentials/formats/jsonld/JsonLdCredentialFormat.d.ts
+++ b/node_modules/@credo-ts/core/build/modules/credentials/formats/jsonld/JsonLdCredentialFormat.d.ts
@@ -10,6 +10,8 @@ export interface JsonCredential {
issuanceDate: string;
expirationDate?: string;
credentialSubject: SingleOrArray<JsonObject>;
+ //TODO change type
+ prettyVc?: any;
[key: string]: unknown;
}
/**
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
@@ -0,0 +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..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
@@ -97,7 +97,6 @@ class V2CredentialProtocol extends BaseCredentialProtocol_1.BaseCredentialProtoc
let credentialRecord = await this.findByProperties(messageContext.agentContext, {
threadId: proposalMessage.threadId,
role: models_1.CredentialRole.Issuer,
- connectionId: connection === null || connection === void 0 ? void 0 : connection.id,
});
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) {
6 changes: 3 additions & 3 deletions src/cliAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ const getModules = (
}),
w3cCredentials: new W3cCredentialsModule(),
cache: new CacheModule({
cache: new InMemoryLruCache({ limit: Infinity }),
cache: new InMemoryLruCache({ limit: Number(process.env.INMEMORY_LRU_CACHE_LIMIT) || Infinity }),
}),

questionAnswer: new QuestionAnswerModule(),
Expand Down Expand Up @@ -233,8 +233,8 @@ const getWithTenantModules = (
)
return {
tenants: new TenantsModule<typeof modules>({
sessionAcquireTimeout: Infinity,
sessionLimit: Infinity,
sessionAcquireTimeout: Number(process.env.SESSION_ACQUIRE_TIMEOUT) || Infinity,
sessionLimit: Number(process.env.SESSION_LIMIT) || Infinity,
}),
...modules,
}
Expand Down
4 changes: 4 additions & 0 deletions src/controllers/did/DidController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export class DidController extends Controller {
didDocument: didDocument,
}
} else {
const BCOVRIN_REGISTER_URL = process.env.BCOVRIN_REGISTER_URL as string
const res = await axios.post(BCOVRIN_REGISTER_URL, {
role: 'ENDORSER',
alias: 'Alias',
Expand Down Expand Up @@ -219,6 +220,7 @@ export class DidController extends Controller {
}
} else {
const key = await this.createIndicioKey(createDidOptions)
const INDICIO_NYM_URL = process.env.INDICIO_NYM_URL as string
const res = await axios.post(INDICIO_NYM_URL, key)
if (res.data.statusCode === 200) {
await this.importDid(didMethod, key.did, createDidOptions.seed)
Expand Down Expand Up @@ -381,13 +383,15 @@ export class DidController extends Controller {
.addContext('https://w3id.org/security/suites/ed25519-2018/v1')
.addVerificationMethod(getEd25519VerificationKey2018({ key, id: keyId, controller: did }))
.addAuthentication(keyId)
.addAssertionMethod(keyId)
.build()
}
if (didOptions.keyType === KeyType.Bls12381g2) {
didDocument = new DidDocumentBuilder(did)
.addContext('https://w3id.org/security/bbs/v1')
.addVerificationMethod(getBls12381G2Key2020({ key, id: keyId, controller: did }))
.addAuthentication(keyId)
.addAssertionMethod(keyId)
.build()
}

Expand Down
4 changes: 4 additions & 0 deletions src/controllers/multi-tenancy/MultiTenancyController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ export class MultiTenancyController extends Controller {
seed: seed,
}

const BCOVRIN_REGISTER_URL = process.env.BCOVRIN_REGISTER_URL as string
const res = await axios.post(BCOVRIN_REGISTER_URL, body)
if (res) {
const { did } = res?.data || {}
Expand Down Expand Up @@ -330,6 +331,7 @@ export class MultiTenancyController extends Controller {
verkey: TypedArrayEncoder.toBase58(buffer),
}
}
const INDICIO_NYM_URL = process.env.INDICIO_NYM_URL as string
const res = await axios.post(INDICIO_NYM_URL, body)
if (res.data.statusCode === 200) {
await this.importDid(didMethod, did, seed, tenantAgent)
Expand Down Expand Up @@ -487,13 +489,15 @@ export class MultiTenancyController extends Controller {
.addContext('https://w3id.org/security/suites/ed25519-2018/v1')
.addVerificationMethod(getEd25519VerificationKey2018({ key, id: keyId, controller: did }))
.addAuthentication(keyId)
.addAssertionMethod(keyId)
.build()
}
if (keyType === KeyType.Bls12381g2) {
didDocument = new DidDocumentBuilder(did)
.addContext('https://w3id.org/security/bbs/v1')
.addVerificationMethod(getBls12381G2Key2020({ key, id: keyId, controller: did }))
.addAuthentication(keyId)
.addAssertionMethod(keyId)
.build()
}

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
9 changes: 7 additions & 2 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { Response as ExResponse, Request as ExRequest, NextFunction } from
import { Agent } from '@credo-ts/core'
import bodyParser from 'body-parser'
import cors from 'cors'
import dotenv from 'dotenv'
import express from 'express'
import { rateLimit } from 'express-rate-limit'
import * as fs from 'fs'
Expand All @@ -21,10 +22,11 @@ import { questionAnswerEvents } from './events/QuestionAnswerEvents'
import { reuseConnectionEvents } from './events/ReuseConnectionEvents'
import { RegisterRoutes } from './routes/routes'
import { SecurityMiddleware } from './securityMiddleware'
import { maxRateLimit, windowMs } from './utils/util'

import { ValidateError } from 'tsoa'

dotenv.config()

export const setupServer = async (agent: Agent, config: ServerConfig, apiKey?: string) => {
container.registerInstance(Agent, agent)
fs.writeFileSync('config.json', JSON.stringify(config, null, 2))
Expand All @@ -44,16 +46,19 @@ export const setupServer = async (agent: Agent, config: ServerConfig, apiKey?: s
app.use(
bodyParser.urlencoded({
extended: true,
limit: '50mb',
})
)

setDynamicApiKey(apiKey ? apiKey : '')

app.use(bodyParser.json())
app.use(bodyParser.json({ limit: '50mb' }))
app.use('/docs', serve, async (_req: ExRequest, res: ExResponse) => {
return res.send(generateHTML(await import('./routes/swagger.json')))
})

const windowMs = Number(process.env.windowMs)
const maxRateLimit = Number(process.env.maxRateLimit)
const limiter = rateLimit({
windowMs, // 1 second
max: maxRateLimit, // max 800 requests per second
Expand Down
3 changes: 1 addition & 2 deletions src/utils/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import { ariesAskar } from '@hyperledger/aries-askar-nodejs'
import { indyVdr } from '@hyperledger/indy-vdr-nodejs'

import { TsLogger } from './logger'
import { BCOVRIN_TEST_GENESIS } from './util'

export const setupAgent = async ({ name, endpoints, port }: { name: string; endpoints: string[]; port: number }) => {
const logger = new TsLogger(LogLevel.debug)
Expand All @@ -62,7 +61,7 @@ export const setupAgent = async ({ name, endpoints, port }: { name: string; endp
{
isProduction: false,
indyNamespace: 'bcovrin:test',
genesisTransactions: BCOVRIN_TEST_GENESIS,
genesisTransactions: process.env.BCOVRIN_TEST_GENESIS as string,
connectOnStartup: true,
},
],
Expand Down
14 changes: 7 additions & 7 deletions taskdef/credo-ecs-taskdef.json
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
Loading