Skip to content

Commit

Permalink
chore: merge develop to main (#116)
Browse files Browse the repository at this point in the history
Co-authored-by: tipusinghaw <[email protected]>
Co-authored-by: Sai Ranjit Tummalapalli <[email protected]>
Co-authored-by: Krishna <[email protected]>
Co-authored-by: KulkarniShashank <[email protected]>
  • Loading branch information
5 people committed Sep 13, 2024
1 parent ceaeb71 commit 2f8b540
Show file tree
Hide file tree
Showing 10 changed files with 847 additions and 1,023 deletions.
10 changes: 4 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
# # Only needed to build indy-sdk
# build-essential

# # nodejs
# # RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
# # RUN /bin/bash -c "source /root/.nvm/nvm.sh && nvm install 18 && nvm use 18"

# RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash -

# # yarn
Expand All @@ -23,6 +19,10 @@
# RUN apt-get update -y && apt-get install -y --allow-unauthenticated \
# nodejs

# # install depdencies
# RUN apt-get update -y && apt-get install -y --allow-unauthenticated \
# nodejs

# # Install yarn seperately due to `no-install-recommends` to skip nodejs install
# RUN apt-get install -y --no-install-recommends yarn

Expand Down Expand Up @@ -76,5 +76,3 @@ COPY --from=builder /app/patches ./patches

# Set entry point
ENTRYPOINT ["node", "./bin/afj-rest.js", "start"]


24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@
"validate": "yarn lint && yarn check-types && yarn check-format"
},
"dependencies": {
"@ayanworks/credo-polygon-w3c-module": "0.0.2-alpha.7",
"@credo-ts/anoncreds": "0.5.1",
"@credo-ts/askar": "0.5.1",
"@credo-ts/core": "0.5.1",
"@credo-ts/indy-vdr": "0.5.1",
"@credo-ts/node": "0.5.1",
"@ayanworks/credo-polygon-w3c-module": "0.0.2-alpha.8",
"@credo-ts/anoncreds": "0.5.3",
"@credo-ts/askar": "0.5.3",
"@credo-ts/core": "0.5.3",
"@credo-ts/indy-vdr": "0.5.3",
"@credo-ts/node": "0.5.3",
"@credo-ts/push-notifications": "^0.7.0",
"@credo-ts/question-answer": "0.5.1",
"@credo-ts/tenants": "0.5.1",
"@hyperledger/anoncreds-nodejs": "0.2.1",
"@hyperledger/aries-askar-nodejs": "0.2.0",
"@hyperledger/indy-vdr-nodejs": "0.2.0",
"@credo-ts/question-answer": "0.5.3",
"@credo-ts/tenants": "0.5.3",
"@hyperledger/anoncreds-nodejs": "0.2.2",
"@hyperledger/aries-askar-nodejs": "0.2.1",
"@hyperledger/indy-vdr-nodejs": "0.2.2",
"@tsoa/runtime": "^6.0.0",
"@types/node-fetch": "^2.6.4",
"@types/ref-struct-di": "^1.1.9",
Expand Down Expand Up @@ -100,6 +100,6 @@
"typescript": "^5.3.3"
},
"engines": {
"node": "18.19.0"
"node": ">=18"
}
}
4 changes: 2 additions & 2 deletions samples/cliConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
"autoAcceptMediationRequests": false,
"adminPort": 4001,
"tenancy": true,
"didRegistryContractAddress": "0xc087766218b885C6283072BA316a2Bc31B5c17db",
"schemaManagerContractAddress": "0xD6f235F1159970211B3628CbC15e6c75D4Fb6e6e",
"didRegistryContractAddress": "0xC1c392DC1073a86821B4ae37f1F0faCDcFFf45bF",
"schemaManagerContractAddress": "0x289c7Bd4C7d38cC54bff370d6f9f01b74Df51b11",
"rpcUrl": "https://rpc-amoy.polygon.technology",
"fileServerUrl": "https://schema.credebl.id/",
"fileServerToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJBeWFuV29ya3MiLCJpZCI6ImNhZDI3ZjhjLTMyNWYtNDRmZC04ZmZkLWExNGNhZTY3NTMyMSJ9.I3IR7abjWbfStnxzn1BhxhV0OEzt1x3mULjDdUcgWHk"
Expand Down
4 changes: 2 additions & 2 deletions src/cliAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ const getModules = (networkConfig: [IndyVdrPoolConfig, ...IndyVdrPoolConfig[]])

questionAnswer: new QuestionAnswerModule(),
polygon: new PolygonModule({
didContractAddress: '0xc087766218b885C6283072BA316a2Bc31B5c17db',
schemaManagerContractAddress: '0xD6f235F1159970211B3628CbC15e6c75D4Fb6e6e',
didContractAddress: '0xC1c392DC1073a86821B4ae37f1F0faCDcFFf45bF',
schemaManagerContractAddress: '0x289c7Bd4C7d38cC54bff370d6f9f01b74Df51b11',
fileServerToken:
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJBeWFuV29ya3MiLCJpZCI6ImNhZDI3ZjhjLTMyNWYtNDRmZC04ZmZkLWExNGNhZTY3NTMyMSJ9.I3IR7abjWbfStnxzn1BhxhV0OEzt1x3mULjDdUcgWHk',
rpcUrl: 'https://rpc-amoy.polygon.technology',
Expand Down
40 changes: 25 additions & 15 deletions src/controllers/multi-tenancy/MultiTenancyController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ import {
getBls12381G2Key2020,
getEd25519VerificationKey2018,
injectable,
createPeerDidDocumentFromServices,
PeerDidNumAlgo,
} from '@credo-ts/core'
import { QuestionAnswerRole, QuestionAnswerState } from '@credo-ts/question-answer'
import axios from 'axios'
Expand Down Expand Up @@ -680,24 +682,32 @@ export class MultiTenancyController extends Controller {
@Body() config?: Omit<CreateOutOfBandInvitationConfig, 'routing'> & RecipientKeyOption // Remove routing property from type
) {
let outOfBandRecord: OutOfBandRecord | undefined
let finalConfig: Omit<CreateOutOfBandInvitationConfig, 'routing'> & RecipientKeyOption & { routing?: Routing } = {} // Initialize finalConfig

let invitationDid: string | undefined
try {
await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => {
if (config?.recipientKey) {
const routing: Routing = {
// Initialize routing object
endpoints: tenantAgent.config.endpoints,
routingKeys: [],
recipientKey: Key.fromPublicKeyBase58(config.recipientKey, KeyType.Ed25519),
mediatorId: undefined,
}
finalConfig = { ...config, routing } // Assign finalConfig
if (config?.invitationDid) {
invitationDid = config?.invitationDid
} else {
finalConfig = { ...config, routing: await tenantAgent.mediationRecipient.getRouting({}) } // Assign finalConfig
const didRouting = await tenantAgent.mediationRecipient.getRouting({})
const didDocument = createPeerDidDocumentFromServices([
{
id: 'didcomm',
recipientKeys: [didRouting.recipientKey],
routingKeys: didRouting.routingKeys,
serviceEndpoint: didRouting.endpoints[0],
},
])
const did = await tenantAgent.dids.create<PeerDidNumAlgo2CreateOptions>({
didDocument,
method: 'peer',
options: {
numAlgo: PeerDidNumAlgo.MultipleInceptionKeyWithoutDoc,
},
})
invitationDid = did.didState.did
}

outOfBandRecord = await tenantAgent.oob.createInvitation(finalConfig)
outOfBandRecord = await tenantAgent.oob.createInvitation({ ...config, invitationDid })
})

return {
Expand All @@ -708,7 +718,7 @@ export class MultiTenancyController extends Controller {
useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed,
}),
outOfBandRecord: outOfBandRecord?.toJSON(),
...(finalConfig?.recipientKey ? {} : { recipientKey: finalConfig.routing?.recipientKey.publicKeyBase58 }), // Access recipientKey from routing
invitationDid: config?.invitationDid ? '' : invitationDid,
}
} catch (error) {
return internalServerError(500, { message: `something went wrong: ${error}` })
Expand Down Expand Up @@ -1421,7 +1431,7 @@ export class MultiTenancyController extends Controller {
}),
outOfBandRecord: outOfBandRecord.toJSON(),
outOfBandRecordId: outOfBandRecord.id,
recipientKey: createOfferOptions?.recipientKey ? {} : { recipientKey: routing.recipientKey.publicKeyBase58 },
invitationDid: createOfferOptions?.invitationDid ? '' : invitationDid,
}
})
return createOfferOobRecord
Expand Down
44 changes: 31 additions & 13 deletions src/controllers/outofband/OutOfBandController.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import type { OutOfBandInvitationProps, OutOfBandRecordWithInvitationProps } from '../examples'
import type { AgentMessageType, RecipientKeyOption, CreateInvitationOptions } from '../types'
import type { ConnectionRecordProps, CreateLegacyInvitationConfig, Routing } from '@credo-ts/core'
import type {
ConnectionRecordProps,
CreateLegacyInvitationConfig,
PeerDidNumAlgo2CreateOptions,
Routing,
} from '@credo-ts/core'

import {
AgentMessage,
Expand All @@ -10,6 +15,8 @@ import {
RecordNotFoundError,
Key,
KeyType,
createPeerDidDocumentFromServices,
PeerDidNumAlgo,
} from '@credo-ts/core'
import { injectable } from 'tsyringe'

Expand Down Expand Up @@ -99,20 +106,31 @@ export class OutOfBandController extends Controller {
@Body() config: CreateInvitationOptions & RecipientKeyOption // props removed because of issues with serialization
) {
try {
let routing: Routing
if (config?.recipientKey) {
routing = {
endpoints: this.agent.config.endpoints,
routingKeys: [],
recipientKey: Key.fromPublicKeyBase58(config.recipientKey, KeyType.Ed25519),
mediatorId: undefined,
}
let invitationDid: string | undefined
if (config?.invitationDid) {
invitationDid = config?.invitationDid
} else {
routing = await this.agent.mediationRecipient.getRouting({})
const didRouting = await this.agent.mediationRecipient.getRouting({})
const didDocument = createPeerDidDocumentFromServices([
{
id: 'didcomm',
recipientKeys: [didRouting.recipientKey],
routingKeys: didRouting.routingKeys,
serviceEndpoint: didRouting.endpoints[0],
},
])
const did = await this.agent.dids.create<PeerDidNumAlgo2CreateOptions>({
didDocument,
method: 'peer',
options: {
numAlgo: PeerDidNumAlgo.MultipleInceptionKeyWithoutDoc,
},
})
// eslint-disable-next-line @typescript-eslint/no-unused-vars
invitationDid = did.didState.did
}

config.routing = routing
const outOfBandRecord = await this.agent.oob.createInvitation(config)
const outOfBandRecord = await this.agent.oob.createInvitation({ ...config, invitationDid })
return {
invitationUrl: outOfBandRecord.outOfBandInvitation.toUrl({
domain: this.agent.config.endpoints[0],
Expand All @@ -121,7 +139,7 @@ export class OutOfBandController extends Controller {
useDidSovPrefixWhereAllowed: this.agent.config.useDidSovPrefixWhereAllowed,
}),
outOfBandRecord: outOfBandRecord.toJSON(),
...(config?.recipientKey ? {} : { recipientKey: routing.recipientKey.publicKeyBase58 }),
invitationDid: config?.invitationDid ? '' : invitationDid,
}
} catch (error) {
return internalServerError(500, { message: `something went wrong: ${error}` })
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/proofs/ProofController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
Routing,
} from '@credo-ts/core'

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

import { ProofRecordExample, RecordId } from '../examples'
Expand Down
Loading

0 comments on commit 2f8b540

Please sign in to comment.