Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .env.demo
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ INDICIO_NYM_URL=https://selfserve.indiciotech.io/nym
# Contract address for Polygon (mainnet)
SCHEMA_MANAGER_CONTRACT_ADDRESS=0x4B16719E73949a62E9A7306F352ec73F1B143c27
DID_CONTRACT_ADDRESS=0x0C16958c4246271622201101C83B9F0Fc7180d15
RPC_URL=https://polygon-rpc.com
RPC_URL=https://polygon.drpc.org
# Contract address for Polygon (testnet)
# SCHEMA_MANAGER_CONTRACT_ADDRESS=0x4742d43C2dFCa5a1d4238240Afa8547Daf87Ee7a
# DID_CONTRACT_ADDRESS=0xcB80F37eDD2bE3570c6C9D5B0888614E04E1e49E
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"validate": "yarn lint && yarn check-types && yarn check-format"
},
"dependencies": {
"@ayanworks/credo-polygon-w3c-module": "2.0.0",
"@ayanworks/credo-polygon-w3c-module": "^2.0.0",
"@credo-ts/anoncreds": "0.6.2",
"@credo-ts/askar": "0.6.2",
"@credo-ts/core": "0.6.2",
Expand Down
32 changes: 17 additions & 15 deletions src/cliAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import { setupServer } from './server'
import { generateSecretKey } from './utils/helpers'
import { TsLogger } from './utils/logger'
import { getMixedCredentialRequestToCredentialMapper, getTrustedCerts } from './utils/oid4vc-agent'
import { PolygonDidRegistrar, PolygonDidResolver, PolygonModule } from '@ayanworks/credo-polygon-w3c-module'

export type Transports = 'ws' | 'http'
export type InboundTransport = {
Expand Down Expand Up @@ -174,15 +175,14 @@ const getModules = (
new IndyVdrIndyDidRegistrar(),
new KeyDidRegistrar(),
new JwkDidRegistrar(),
// TODO: We can enable polygon later
// , new PolygonDidRegistrar()
new PolygonDidRegistrar(),
],
resolvers: [
new IndyVdrIndyDidResolver(),
new KeyDidResolver(),
new WebDidResolver(),
new JwkDidResolver(),
// , new PolygonDidResolver()
new PolygonDidResolver(),
],
}),

Expand Down Expand Up @@ -237,17 +237,16 @@ const getModules = (
}),

questionAnswer: new QuestionAnswerModule(),
// Todo: We can remove this polygon module for time being
// polygon: new PolygonModule({
// didContractAddress: didRegistryContractAddress
// ? didRegistryContractAddress
// : (process.env.DID_CONTRACT_ADDRESS as string),
// schemaManagerContractAddress:
// schemaManagerContractAddress || (process.env.SCHEMA_MANAGER_CONTRACT_ADDRESS as string),
// fileServerToken: fileServerToken ? fileServerToken : (process.env.FILE_SERVER_TOKEN as string),
// rpcUrl: rpcUrl ? rpcUrl : (process.env.RPC_URL as string),
// serverUrl: fileServerUrl ? fileServerUrl : (process.env.SERVER_URL as string),
// }),
polygon: new PolygonModule({
didContractAddress: didRegistryContractAddress
? didRegistryContractAddress
: (process.env.DID_CONTRACT_ADDRESS as string),
schemaManagerContractAddress:
schemaManagerContractAddress || (process.env.SCHEMA_MANAGER_CONTRACT_ADDRESS as string),
fileServerToken: fileServerToken ? fileServerToken : (process.env.FILE_SERVER_TOKEN as string),
rpcUrl: rpcUrl ? rpcUrl : (process.env.RPC_URL as string),
serverUrl: fileServerUrl ? fileServerUrl : (process.env.SERVER_URL as string),
}),
openid4vc: new OpenId4VcModule({
app: expressApp,
issuer: {
Expand All @@ -274,7 +273,10 @@ const getModules = (
}),
openId4VcHolderModule: new OpenId4VcHolderModule(),
x509: new X509Module({
getTrustedCertificatesForVerification: async (agentContext, { certificateChain: _certificateChain, verification: _verification }) => {
getTrustedCertificatesForVerification: async (
agentContext,
{ certificateChain: _certificateChain, verification: _verification },
) => {
//TODO: We need to trust the certificate tenant wise, for that we need to fetch those details from platform
const tenantId = agentContext.contextCorrelationId
console.log('[getTrustedCertificatesForVerification] tenantId from agentContext:', tenantId)
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/auth/AuthController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class AuthController extends Controller {

return response.data
}
// TODO: Remove these test endpoints after manual testing is done
// TODO: Remove these test endpoints after manual testing is done
@Get('/test/dedicated-x509-certificates')
public async testFetchDedicatedX509Certificates(@Request() _request: Req): Promise<string[]> {
return fetchDedicatedX509Certificates()
Expand Down
3 changes: 1 addition & 2 deletions src/controllers/didcomm/connections/ConnectionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ export class ConnectionController extends Controller {
try {
const outOfBandRecord = await request.agent.modules.didcomm.connections.findByInvitationDid(invitationId)

if (!outOfBandRecord)
throw new NotFoundError(`connection with invitationId "${invitationId}" not found.`)
if (!outOfBandRecord) throw new NotFoundError(`connection with invitationId "${invitationId}" not found.`)

return outOfBandRecord
} catch (error) {
Expand Down
34 changes: 17 additions & 17 deletions src/controllers/didcomm/outofband/OutOfBandController.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
import type { OutOfBandInvitationProps, OutOfBandRecordWithInvitationProps } from '../../examples'
import type { RecipientKeyOption, CreateInvitationOptions, AgentMessageType } from '../../types'
import type {
PeerDidNumAlgo2CreateOptions,
} from '@credo-ts/core'
import type { PeerDidNumAlgo2CreateOptions } from '@credo-ts/core'

import {
createPeerDidDocumentFromServices,
JsonTransformer,
PeerDidNumAlgo,
} from '@credo-ts/core'
import { createPeerDidDocumentFromServices, JsonTransformer, PeerDidNumAlgo } from '@credo-ts/core'

import {
DidCommConnectionRecordProps,
DidCommRouting,
DidCommOutOfBandInvitation,
DidCommMessage} from '@credo-ts/didcomm'
DidCommMessage,
} from '@credo-ts/didcomm'
import { Request as Req } from 'express'
import { Body, Controller, Delete, Example, Get, Path, Post, Query, Route, Tags, Security, Request } from 'tsoa'
import { injectable } from 'tsyringe'
Expand Down Expand Up @@ -94,8 +89,7 @@ export class OutOfBandController extends Controller {
let invitationDid: string | undefined
if (config?.invitationDid) {
invitationDid = config?.invitationDid
}
else {
} else {
const didRouting = await request.agent.modules.didcomm.mediationRecipient.getRouting({})
const { didDocument, keys } = createPeerDidDocumentFromServices(
[
Expand All @@ -113,7 +107,7 @@ export class OutOfBandController extends Controller {
method: 'peer',
options: {
numAlgo: PeerDidNumAlgo.MultipleInceptionKeyWithoutDoc,
keys
keys,
},
})

Expand Down Expand Up @@ -159,9 +153,9 @@ export class OutOfBandController extends Controller {
@Body()
config: {
recordId: string
message: Record<string, unknown>;
domain: string,
routing?: DidCommRouting;
message: Record<string, unknown>
domain: string
routing?: DidCommRouting
},
) {
try {
Expand Down Expand Up @@ -193,8 +187,14 @@ export class OutOfBandController extends Controller {
const { invitation, ...config } = invitationRequest

try {
const invite = new DidCommOutOfBandInvitation({ ...invitation, handshakeProtocols: invitation.handshake_protocols })
const { outOfBandRecord, connectionRecord } = await request.agent.modules.didcomm.oob.receiveInvitation(invite, config)
const invite = new DidCommOutOfBandInvitation({
...invitation,
handshakeProtocols: invitation.handshake_protocols,
})
const { outOfBandRecord, connectionRecord } = await request.agent.modules.didcomm.oob.receiveInvitation(
invite,
config,
)

return {
outOfBandRecord: outOfBandRecord.toJSON(),
Expand Down
171 changes: 89 additions & 82 deletions src/controllers/openid4vc/examples/issuer.examples.ts
Original file line number Diff line number Diff line change
@@ -1,111 +1,118 @@
export const OpenId4VcUpdateIssuerRecordOptionsExample = {
withScope: {
value: {
issuerId: "abc-gov",
accessTokenSignerKeyType: "ed25519",
issuerId: 'abc-gov',
accessTokenSignerKeyType: 'ed25519',
display: [
{
name: "ABC Gov",
locale: "en",
name: 'ABC Gov',
locale: 'en',
logo: {
uri: "https://upload.wikimedia.org/wikipedia/commons/2/2f/ABC-2021-LOGO.svg",
alt_text: "abc_logo",
uri: 'https://upload.wikimedia.org/wikipedia/commons/2/2f/ABC-2021-LOGO.svg',
alt_text: 'abc_logo',
},
},
],
dpopSigningAlgValuesSupported: ["RS256", "ES256"],
dpopSigningAlgValuesSupported: ['RS256', 'ES256'],
credentialConfigurationsSupported: {
"VaccinationCredential-sdjwt": {
format: "vc+sd-jwt",
vct: "VaccinationCredential",
scope: "openid4vc:credential:VaccinationCredential-sdjwt",
'VaccinationCredential-sdjwt': {
format: 'vc+sd-jwt',
vct: 'VaccinationCredential',
scope: 'openid4vc:credential:VaccinationCredential-sdjwt',
claims: {
name: { mandatory: true, value_type: "string", display: { name: "Full Name", locale: "en" } },
vaccine: { mandatory: true, value_type: "string", display: { name: "Vaccine Type", locale: "en" } },
lotNumber: { value_type: "string", display: { name: "Batch Number", locale: "en" } },
performer: { value_type: "string", display: { name: "Healthcare Provider", locale: "en" } },
doseDate: { value_type: "date", display: { name: "Date of Dose", locale: "en" } }
name: { mandatory: true, value_type: 'string', display: { name: 'Full Name', locale: 'en' } },
vaccine: { mandatory: true, value_type: 'string', display: { name: 'Vaccine Type', locale: 'en' } },
lotNumber: { value_type: 'string', display: { name: 'Batch Number', locale: 'en' } },
performer: { value_type: 'string', display: { name: 'Healthcare Provider', locale: 'en' } },
doseDate: { value_type: 'date', display: { name: 'Date of Dose', locale: 'en' } },
},
credential_signing_alg_values_supported: ["ES256"],
cryptographic_binding_methods_supported: ["did:key"],
credential_signing_alg_values_supported: ['ES256'],
cryptographic_binding_methods_supported: ['did:key'],
display: [
{
name: "COVID-19 Vaccination Certificate",
description: "Proof of vaccination against COVID-19",
locale: "en"
}
]
name: 'COVID-19 Vaccination Certificate',
description: 'Proof of vaccination against COVID-19',
locale: 'en',
},
],
},
"NationalIDCredential-mdoc": {
format: "mso_mdoc",
doctype: "org.iso.18013.5.1",
scope: "openid4vc:credential:NationalIDCredential-mdoc",
'NationalIDCredential-mdoc': {
format: 'mso_mdoc',
doctype: 'org.iso.18013.5.1',
scope: 'openid4vc:credential:NationalIDCredential-mdoc',
claims: {
family_name: { mandatory: true, value_type: "string", display: { name: "Last Name", locale: "en" } },
given_name: { mandatory: true, value_type: "string", display: { name: "First Name", locale: "en" } },
birth_date: { value_type: "date", display: { name: "Date of Birth", locale: "en" } },
gender: { value_type: "string", display: { name: "Gender", locale: "en" } },
nationality: { value_type: "string", display: { name: "Nationality", locale: "en" } },
document_number: { mandatory: true, value_type: "string", display: { name: "Document Number", locale: "en" } },
issuing_authority: { value_type: "string", display: { name: "Issuing Authority", locale: "en" } },
expiry_date: { value_type: "date", display: { name: "Expiry Date", locale: "en" } }
family_name: { mandatory: true, value_type: 'string', display: { name: 'Last Name', locale: 'en' } },
given_name: { mandatory: true, value_type: 'string', display: { name: 'First Name', locale: 'en' } },
birth_date: { value_type: 'date', display: { name: 'Date of Birth', locale: 'en' } },
gender: { value_type: 'string', display: { name: 'Gender', locale: 'en' } },
nationality: { value_type: 'string', display: { name: 'Nationality', locale: 'en' } },
document_number: {
mandatory: true,
value_type: 'string',
display: { name: 'Document Number', locale: 'en' },
},
issuing_authority: { value_type: 'string', display: { name: 'Issuing Authority', locale: 'en' } },
expiry_date: { value_type: 'date', display: { name: 'Expiry Date', locale: 'en' } },
},
credential_signing_alg_values_supported: ["ES256"],
cryptographic_binding_methods_supported: ["did:key"],
credential_signing_alg_values_supported: ['ES256'],
cryptographic_binding_methods_supported: ['did:key'],
display: [
{
name: "National ID",
description: "Digital government-issued identity credential",
locale: "en"
}
]
name: 'National ID',
description: 'Digital government-issued identity credential',
locale: 'en',
},
],
},
"UniversityDegreeCredential-sdjwt": {
format: "vc+sd-jwt",
vct: "UniversityDegreeCredential",
scope: "openid4vc:credential:UniversityDegreeCredential-sdjwt",
'UniversityDegreeCredential-sdjwt': {
format: 'vc+sd-jwt',
vct: 'UniversityDegreeCredential',
scope: 'openid4vc:credential:UniversityDegreeCredential-sdjwt',
claims: {
full_name: { mandatory: true, value_type: "string", display: { name: "Full Name", locale: "en" } },
diploma_name: { mandatory: true, value_type: "string", display: { name: "Degree Title", locale: "en" } },
college_name: { value_type: "string", display: { name: "College/University", locale: "en" } },
graduation_date: { value_type: "date", display: { name: "Graduation Date", locale: "en" } },
awarded_date: { value_type: "date", display: { name: "Award Date", locale: "en" } }
full_name: { mandatory: true, value_type: 'string', display: { name: 'Full Name', locale: 'en' } },
diploma_name: { mandatory: true, value_type: 'string', display: { name: 'Degree Title', locale: 'en' } },
college_name: { value_type: 'string', display: { name: 'College/University', locale: 'en' } },
graduation_date: { value_type: 'date', display: { name: 'Graduation Date', locale: 'en' } },
awarded_date: { value_type: 'date', display: { name: 'Award Date', locale: 'en' } },
},
credential_signing_alg_values_supported: ["ES256", "EdDSA"],
cryptographic_binding_methods_supported: ["did:key"],
credential_signing_alg_values_supported: ['ES256', 'EdDSA'],
cryptographic_binding_methods_supported: ['did:key'],
display: [
{
name: "University Degree Credential",
description: "Issued by a recognized educational institution",
locale: "en"
}
]
name: 'University Degree Credential',
description: 'Issued by a recognized educational institution',
locale: 'en',
},
],
},
"DrivingLicenseCredential-mdoc": {
format: "mso_mdoc",
doctype: "org.iso.18013.5.1",
scope: "openid4vc:credential:DrivingLicenseCredential-mdoc",
'DrivingLicenseCredential-mdoc': {
format: 'mso_mdoc',
doctype: 'org.iso.18013.5.1',
scope: 'openid4vc:credential:DrivingLicenseCredential-mdoc',
claims: {
family_name: { mandatory: true, value_type: "string", display: { name: "Surname", locale: "en" } },
given_name: { mandatory: true, value_type: "string", display: { name: "Given Name", locale: "en" } },
birth_date: { value_type: "date", display: { name: "Date of Birth", locale: "en" } },
issue_date: { value_type: "date", display: { name: "Issued On", locale: "en" } },
expiry_date: { value_type: "date", display: { name: "Expires On", locale: "en" } },
issuing_country: { value_type: "string", display: { name: "Issuing Country", locale: "en" } },
license_number: { value_type: "string", display: { name: "License Number", locale: "en" } },
categories_of_vehicles: { value_type: "string", display: { name: "Authorized Vehicle Types", locale: "en" } }
family_name: { mandatory: true, value_type: 'string', display: { name: 'Surname', locale: 'en' } },
given_name: { mandatory: true, value_type: 'string', display: { name: 'Given Name', locale: 'en' } },
birth_date: { value_type: 'date', display: { name: 'Date of Birth', locale: 'en' } },
issue_date: { value_type: 'date', display: { name: 'Issued On', locale: 'en' } },
expiry_date: { value_type: 'date', display: { name: 'Expires On', locale: 'en' } },
issuing_country: { value_type: 'string', display: { name: 'Issuing Country', locale: 'en' } },
license_number: { value_type: 'string', display: { name: 'License Number', locale: 'en' } },
categories_of_vehicles: {
value_type: 'string',
display: { name: 'Authorized Vehicle Types', locale: 'en' },
},
},
credential_signing_alg_values_supported: ["ES256"],
cryptographic_binding_methods_supported: ["did:key"],
credential_signing_alg_values_supported: ['ES256'],
cryptographic_binding_methods_supported: ['did:key'],
display: [
{
name: "Driving License",
description: "ISO-compliant mobile driving license",
locale: "en"
}
]
}
}
}
}
};
name: 'Driving License',
description: 'ISO-compliant mobile driving license',
locale: 'en',
},
],
},
},
},
},
}
Loading