-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from credebl/feat/agent-setup
feat: add agent provider and agent modules
- Loading branch information
Showing
14 changed files
with
10,496 additions
and
3,181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules | ||
build/ | ||
.DS_Store | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pnpm-lock.yaml | ||
node_modules | ||
.DS_Store | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"git": { | ||
"commitMessage": "chore: release v${version}" | ||
}, | ||
"github": { | ||
"release": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
import type { InitConfig } from '@aries-framework/core' | ||
import type { IndyVdrPoolConfig } from '@aries-framework/indy-vdr' | ||
|
||
import { | ||
AnonCredsCredentialFormatService, | ||
AnonCredsModule, | ||
AnonCredsProofFormatService, | ||
LegacyIndyCredentialFormatService, | ||
LegacyIndyProofFormatService, | ||
V1CredentialProtocol, | ||
V1ProofProtocol | ||
} from '@aries-framework/anoncreds' | ||
import { AnonCredsRsModule } from '@aries-framework/anoncreds-rs' | ||
import { AskarModule } from '@aries-framework/askar' | ||
import { | ||
JwkDidRegistrar, | ||
JwkDidResolver, | ||
Agent, | ||
DidsModule, | ||
WebDidResolver, | ||
CredentialsModule, | ||
V2CredentialProtocol, | ||
ProofsModule, | ||
V2ProofProtocol, | ||
AutoAcceptProof, | ||
AutoAcceptCredential, | ||
MediationRecipientModule, | ||
HttpOutboundTransport, | ||
WsOutboundTransport, | ||
ConnectionsModule, | ||
MediatorPickupStrategy, | ||
JsonLdCredentialFormatService | ||
} from '@aries-framework/core' | ||
import { | ||
IndyVdrAnonCredsRegistry, | ||
IndyVdrIndyDidResolver, | ||
IndyVdrModule, | ||
IndyVdrSovDidResolver | ||
} from '@aries-framework/indy-vdr' | ||
import { PushNotificationsFcmModule } from '@aries-framework/push-notifications' | ||
import { agentDependencies } from '@aries-framework/react-native' | ||
import { anoncreds } from '@hyperledger/anoncreds-react-native' | ||
import { ariesAskar } from '@hyperledger/aries-askar-react-native' | ||
import { indyVdr } from '@hyperledger/indy-vdr-react-native' | ||
|
||
const getAgentModules = (mediatorInvitationUrl: string, indyNetworks: [IndyVdrPoolConfig, ...IndyVdrPoolConfig[]]) => { | ||
return { | ||
askar: new AskarModule({ | ||
ariesAskar | ||
}), | ||
anoncredsRs: new AnonCredsRsModule({ | ||
anoncreds | ||
}), | ||
anoncreds: new AnonCredsModule({ | ||
registries: [new IndyVdrAnonCredsRegistry()] | ||
}), | ||
mediationRecipient: new MediationRecipientModule({ | ||
mediatorPickupStrategy: MediatorPickupStrategy.PickUpV2, | ||
mediatorInvitationUrl: mediatorInvitationUrl | ||
}), | ||
dids: new DidsModule({ | ||
registrars: [new JwkDidRegistrar()], | ||
resolvers: [new WebDidResolver(), new JwkDidResolver(), new IndyVdrSovDidResolver(), new IndyVdrIndyDidResolver()] | ||
}), | ||
indyVdr: new IndyVdrModule({ | ||
indyVdr, | ||
networks: indyNetworks | ||
}), | ||
credentials: new CredentialsModule({ | ||
autoAcceptCredentials: AutoAcceptCredential.ContentApproved, | ||
credentialProtocols: [ | ||
new V1CredentialProtocol({ | ||
indyCredentialFormat: new LegacyIndyCredentialFormatService() | ||
}), | ||
new V2CredentialProtocol({ | ||
credentialFormats: [ | ||
new LegacyIndyCredentialFormatService(), | ||
new AnonCredsCredentialFormatService(), | ||
new JsonLdCredentialFormatService() | ||
] | ||
}) | ||
] | ||
}), | ||
proofs: new ProofsModule({ | ||
autoAcceptProofs: AutoAcceptProof.ContentApproved, | ||
proofProtocols: [ | ||
new V1ProofProtocol({ | ||
indyProofFormat: new LegacyIndyProofFormatService() | ||
}), | ||
new V2ProofProtocol({ | ||
proofFormats: [new LegacyIndyProofFormatService(), new AnonCredsProofFormatService()] | ||
}) | ||
] | ||
}), | ||
connections: new ConnectionsModule({ | ||
autoAcceptConnections: true | ||
}), | ||
pushNotificationsFcm: new PushNotificationsFcmModule() | ||
} | ||
} | ||
|
||
export const initializeAgent = async ({ | ||
agentConfig, | ||
mediatorInvitationUrl, | ||
indyNetworks | ||
}: { | ||
agentConfig: InitConfig | ||
mediatorInvitationUrl: string | ||
indyNetworks: [IndyVdrPoolConfig, ...IndyVdrPoolConfig[]] | ||
}) => { | ||
const agent = new Agent({ | ||
dependencies: agentDependencies, | ||
config: { | ||
autoUpdateStorageOnStartup: true, | ||
...agentConfig | ||
}, | ||
modules: getAgentModules(mediatorInvitationUrl, indyNetworks) | ||
}) | ||
|
||
agent.registerOutboundTransport(new HttpOutboundTransport()) | ||
agent.registerOutboundTransport(new WsOutboundTransport()) | ||
|
||
await agent.initialize() | ||
|
||
return agent | ||
} | ||
|
||
export type AdeyaAgent = Awaited<ReturnType<typeof initializeAgent>> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { | ||
useBasicMessages, | ||
useBasicMessagesByConnectionId, | ||
useConnectionById, | ||
useConnections, | ||
useCredentialById, | ||
useCredentialByState, | ||
useCredentialNotInState, | ||
useCredentials, | ||
useCredentialsByConnectionId, | ||
useExchanges, | ||
useExchangesByConnectionId, | ||
useProofById, | ||
useProofByState, | ||
useProofNotInState, | ||
useProofs, | ||
useProofsByConnectionId, | ||
useQuestionAnswer, | ||
useQuestionAnswerByConnectionId, | ||
useQuestionAnswerById | ||
} from '@aries-framework/react-hooks' | ||
|
||
export { | ||
useBasicMessages, | ||
useBasicMessagesByConnectionId, | ||
useConnectionById, | ||
useConnections, | ||
useCredentialById, | ||
useCredentialByState, | ||
useCredentialNotInState, | ||
useCredentials, | ||
useCredentialsByConnectionId, | ||
useExchanges, | ||
useExchangesByConnectionId, | ||
useProofById, | ||
useProofByState, | ||
useProofNotInState, | ||
useProofs, | ||
useProofsByConnectionId, | ||
useQuestionAnswer, | ||
useQuestionAnswerByConnectionId, | ||
useQuestionAnswerById | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,52 @@ | ||
export const add = (a: number, b: number) => { | ||
return a + b | ||
import type { InitConfig } from '@aries-framework/core' | ||
|
||
// Anoncreds | ||
import { | ||
V1RequestPresentationMessage, | ||
AnonCredsCredentialOffer, | ||
AnonCredsCredentialsForProofRequest, | ||
AnonCredsRequestedAttributeMatch, | ||
AnonCredsRequestedPredicateMatch, | ||
AnonCredsNonRevokedInterval, | ||
AnonCredsProofRequestRestriction, | ||
AnonCredsProofFormat, | ||
AnonCredsProofFormatService, | ||
LegacyIndyProofFormat, | ||
LegacyIndyProofFormatService, | ||
AnonCredsPredicateType, | ||
AnonCredsProof, | ||
AnonCredsRequestedAttribute, | ||
AnonCredsRequestedPredicate, | ||
LegacyIndyProofRequest, | ||
AnonCredsProofRequest | ||
} from '@aries-framework/anoncreds' | ||
import { AnonCredsCredentialMetadataKey } from '@aries-framework/anoncreds/build/utils/metadata' | ||
// Core | ||
import { LogLevel, ConsoleLogger } from '@aries-framework/core' | ||
// Indy VDR | ||
import { IndyVdrPoolConfig } from '@aries-framework/indy-vdr' | ||
|
||
export { initializeAgent, AdeyaAgent } from './agent' | ||
export { LogLevel, ConsoleLogger, InitConfig, IndyVdrPoolConfig } | ||
export * from './providers' | ||
export * from './hooks' | ||
export { | ||
V1RequestPresentationMessage, | ||
AnonCredsCredentialOffer, | ||
AnonCredsCredentialsForProofRequest, | ||
AnonCredsRequestedAttributeMatch, | ||
AnonCredsRequestedPredicateMatch, | ||
AnonCredsNonRevokedInterval, | ||
AnonCredsProofRequestRestriction, | ||
AnonCredsProofFormat, | ||
AnonCredsProofFormatService, | ||
LegacyIndyProofFormat, | ||
LegacyIndyProofFormatService, | ||
AnonCredsPredicateType, | ||
AnonCredsProof, | ||
AnonCredsRequestedAttribute, | ||
AnonCredsRequestedPredicate, | ||
LegacyIndyProofRequest, | ||
AnonCredsProofRequest, | ||
AnonCredsCredentialMetadataKey | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import AgentProvider, { useAgent } from '@aries-framework/react-hooks' | ||
|
||
export { useAgent as useAdeyaAgent, AgentProvider as AdeyaAgentProvider } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { AdeyaAgentProvider, useAdeyaAgent } from './AgentProvider' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
import { add } from '../src' | ||
|
||
describe('add function', () => { | ||
it('should return the sum of two numbers', () => { | ||
expect(add(1, 2)).toBe(3) | ||
expect(add(0, 0)).toBe(0) | ||
expect(add(-1, 1)).toBe(0) | ||
it('should add two numbers', () => { | ||
expect(1 + 1).toBe(2) | ||
}) | ||
}) |
Oops, something went wrong.