import { AnonCredsModule, LegacyIndyCredentialFormatService, LegacyIndyProofFormatService, V1CredentialProtocol, V1ProofProtocol, AnonCredsCredentialFormatService, AnonCredsProofFormatService } from '@aries-framework/anoncreds';
import { AnonCredsRsModule } from '@aries-framework/anoncreds-rs';
import { AskarModule } from '@aries-framework/askar';
import { AutoAcceptCredential, ConnectionsModule, CredentialsModule, MediatorPickupStrategy, ProofsModule, MediationRecipientModule, V2CredentialProtocol, V2ProofProtocol, AutoAcceptProof } from '@aries-framework/core';
import { IndyVdrAnonCredsRegistry, IndyVdrModule } from '@aries-framework/indy-vdr';
import { PushNotificationsFcmModule, PushNotificationsApnsModule } from '@aries-framework/push-notifications';
import { useAgent } from '@aries-framework/react-hooks';
import { anoncreds } from '@hyperledger/anoncreds-react-native';
import { ariesAskar } from '@hyperledger/aries-askar-react-native';
import { indyVdr } from '@hyperledger/indy-vdr-react-native';
export function getAgentModules(_ref) {
  let {
    indyNetworks,
    mediatorInvitationUrl
  } = _ref;
  const indyCredentialFormat = new LegacyIndyCredentialFormatService();
  const indyProofFormat = new LegacyIndyProofFormatService();
  return {
    askar: new AskarModule({
      ariesAskar
    }),
    anoncredsRs: new AnonCredsRsModule({
      anoncreds
    }),
    anoncreds: new AnonCredsModule({
      registries: [new IndyVdrAnonCredsRegistry()]
    }),
    indyVdr: new IndyVdrModule({
      indyVdr,
      networks: indyNetworks
    }),
    connections: new ConnectionsModule({
      autoAcceptConnections: true
    }),
    credentials: new CredentialsModule({
      autoAcceptCredentials: AutoAcceptCredential.ContentApproved,
      credentialProtocols: [new V1CredentialProtocol({
        indyCredentialFormat
      }), new V2CredentialProtocol({
        credentialFormats: [indyCredentialFormat, new AnonCredsCredentialFormatService()]
      })]
    }),
    proofs: new ProofsModule({
      autoAcceptProofs: AutoAcceptProof.ContentApproved,
      proofProtocols: [new V1ProofProtocol({
        indyProofFormat
      }), new V2ProofProtocol({
        proofFormats: [indyProofFormat, new AnonCredsProofFormatService()]
      })]
    }),
    mediationRecipient: new MediationRecipientModule({
      mediatorInvitationUrl: mediatorInvitationUrl,
      mediatorPickupStrategy: MediatorPickupStrategy.Implicit
    }),
    pushNotificationsFcm: new PushNotificationsFcmModule(),
    pushNotificationsApns: new PushNotificationsApnsModule()
  };
}
export const useAppAgent = useAgent;
export const createLinkSecretIfRequired = async agent => {
  // If we don't have any link secrets yet, we will create a
  // default link secret that will be used for all anoncreds
  // credential requests.
  const linkSecretIds = await agent.modules.anoncreds.getLinkSecretIds();
  if (linkSecretIds.length === 0) {
    await agent.modules.anoncreds.createLinkSecret({
      setAsDefault: true
    });
  }
};
//# sourceMappingURL=agent.js.map