-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Bryce McMath <[email protected]>
- Loading branch information
1 parent
9142f09
commit 0a0226a
Showing
13 changed files
with
232 additions
and
119 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
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,6 @@ | ||
OCA_URL=https://raw.githubusercontent.com/bcgov/aries-oca-bundles/main/ | ||
MEDIATOR_URL=https://f326-207-194-65-204.ngrok.io?c_i=eyJAdHlwZSI6ICJodHRwczovL2RpZGNvbW0ub3JnL2Nvbm5lY3Rpb25zLzEuMC9pbnZpdGF0aW9uIiwgIkBpZCI6ICI2MjQ0ZThiNS0wNWYzLTRhYWItYjM1Yy1lYWVlMWNmZTAyM2MiLCAicmVjaXBpZW50S2V5cyI6IFsiQ3lqM1BHRUJzQ3RyUGFtTTQyRngza3BlYmR2QWdNd1lGejlFS3RmNnlUN3giXSwgImxhYmVsIjogIk1lZGlhdG9yIiwgInNlcnZpY2VFbmRwb2ludCI6ICJodHRwczovL2YzMjYtMjA3LTE5NC02NS0yMDQubmdyb2suaW8ifQ== | ||
MEDIATOR_USE_PUSH_NOTIFICATIONS=false | ||
MEDIATOR_USE_PUSH_NOTIFICATIONS=false | ||
PROOF_TEMPLATE_URL= | ||
REMOTE_LOGGING_URL= | ||
INDY_VDR_PROXY_URL= |
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,136 @@ | ||
import { | ||
AnonCredsCredentialFormatService, | ||
AnonCredsModule, | ||
AnonCredsProofFormatService, | ||
DataIntegrityCredentialFormatService, | ||
LegacyIndyCredentialFormatService, | ||
LegacyIndyProofFormatService, | ||
V1CredentialProtocol, | ||
V1ProofProtocol, | ||
} from '@credo-ts/anoncreds' | ||
import { AskarModule } from '@credo-ts/askar' | ||
import { | ||
Agent, | ||
AutoAcceptCredential, | ||
AutoAcceptProof, | ||
ConnectionsModule, | ||
CredentialsModule, | ||
DidsModule, | ||
DifPresentationExchangeProofFormatService, | ||
MediationRecipientModule, | ||
MediatorPickupStrategy, | ||
ProofsModule, | ||
V2CredentialProtocol, | ||
V2ProofProtocol, | ||
} from '@credo-ts/core' | ||
import { DrpcModule } from '@credo-ts/drpc' | ||
import { IndyVdrAnonCredsRegistry, IndyVdrModule, IndyVdrPoolConfig } from '@credo-ts/indy-vdr' | ||
import { PushNotificationsApnsModule, PushNotificationsFcmModule } from '@credo-ts/push-notifications' | ||
import { anoncreds } from '@hyperledger/anoncreds-react-native' | ||
import { ariesAskar } from '@hyperledger/aries-askar-react-native' | ||
import { indyVdr } from '@hyperledger/indy-vdr-react-native' | ||
import { IndyVdrProxyDidResolver, IndyVdrProxyAnonCredsRegistry, CacheSettings } from 'credo-ts-indy-vdr-proxy-client' | ||
|
||
export type BCAgent = Agent<ReturnType<typeof getBCAgentModules>> | ||
|
||
interface GetBCAgentModulesOptions { | ||
indyNetworks: IndyVdrPoolConfig[] | ||
mediatorInvitationUrl?: string | ||
txnCache?: { capacity: number; expiryOffsetMs: number; path?: string } | ||
enableProxy?: boolean | ||
proxyBaseUrl?: string | ||
proxyCacheSettings?: CacheSettings | ||
} | ||
|
||
/** | ||
* Constructs the modules to be used in the agent setup | ||
* @param indyNetworks | ||
* @param mediatorInvitationUrl determine which mediator to use | ||
* @param txnCache optional local cache config for indyvdr | ||
* @param enableProxy boolean from the store to determine if proxy should be used | ||
* @param proxyBaseUrl URL of indy vdr proxy | ||
* @param proxyCacheSettings settings for above mentioned proxy client caching | ||
* @returns modules to be used in agent setup | ||
*/ | ||
export function getBCAgentModules({ | ||
indyNetworks, | ||
mediatorInvitationUrl, | ||
txnCache, | ||
enableProxy, | ||
proxyBaseUrl, | ||
proxyCacheSettings, | ||
}: GetBCAgentModulesOptions) { | ||
const indyCredentialFormat = new LegacyIndyCredentialFormatService() | ||
const indyProofFormat = new LegacyIndyProofFormatService() | ||
|
||
if (txnCache) { | ||
indyVdr.setLedgerTxnCache({ | ||
capacity: txnCache.capacity, | ||
expiry_offset_ms: txnCache.expiryOffsetMs, | ||
path: txnCache.path, | ||
}) | ||
} | ||
|
||
const modules = { | ||
askar: new AskarModule({ | ||
ariesAskar, | ||
}), | ||
anoncreds: new AnonCredsModule({ | ||
anoncreds, | ||
registries: [new IndyVdrAnonCredsRegistry()], | ||
}), | ||
indyVdr: new IndyVdrModule({ | ||
indyVdr, | ||
networks: indyNetworks as [IndyVdrPoolConfig], | ||
}), | ||
connections: new ConnectionsModule({ | ||
autoAcceptConnections: true, | ||
}), | ||
credentials: new CredentialsModule({ | ||
autoAcceptCredentials: AutoAcceptCredential.ContentApproved, | ||
credentialProtocols: [ | ||
new V1CredentialProtocol({ indyCredentialFormat }), | ||
new V2CredentialProtocol({ | ||
credentialFormats: [ | ||
indyCredentialFormat, | ||
new AnonCredsCredentialFormatService(), | ||
new DataIntegrityCredentialFormatService(), | ||
], | ||
}), | ||
], | ||
}), | ||
proofs: new ProofsModule({ | ||
autoAcceptProofs: AutoAcceptProof.ContentApproved, | ||
proofProtocols: [ | ||
new V1ProofProtocol({ indyProofFormat }), | ||
new V2ProofProtocol({ | ||
proofFormats: [ | ||
indyProofFormat, | ||
new AnonCredsProofFormatService(), | ||
new DifPresentationExchangeProofFormatService(), | ||
], | ||
}), | ||
], | ||
}), | ||
mediationRecipient: new MediationRecipientModule({ | ||
mediatorInvitationUrl: mediatorInvitationUrl, | ||
mediatorPickupStrategy: MediatorPickupStrategy.Implicit, | ||
}), | ||
pushNotificationsFcm: new PushNotificationsFcmModule(), | ||
pushNotificationsApns: new PushNotificationsApnsModule(), | ||
dids: new DidsModule(), | ||
drpc: new DrpcModule(), | ||
} | ||
|
||
if (enableProxy && proxyBaseUrl) { | ||
modules.anoncreds = new AnonCredsModule({ | ||
anoncreds, | ||
registries: [new IndyVdrProxyAnonCredsRegistry({ proxyBaseUrl, cacheOptions: proxyCacheSettings })], | ||
}) | ||
modules.dids = new DidsModule({ | ||
resolvers: [new IndyVdrProxyDidResolver(proxyBaseUrl)], | ||
}) | ||
} | ||
|
||
return modules | ||
} |
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
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
Oops, something went wrong.