import { AnonCredsCredentialFormatService, AnonCredsModule, AnonCredsProofFormatService, DataIntegrityCredentialFormatService, LegacyIndyCredentialFormatService, LegacyIndyProofFormatService, V1CredentialProtocol, V1ProofProtocol } from '@credo-ts/anoncreds';
import { AskarModule } from '@credo-ts/askar';
import { AutoAcceptCredential, AutoAcceptProof, ConnectionsModule, CredentialsModule, DifPresentationExchangeProofFormatService, MediationRecipientModule, MediatorPickupStrategy, ProofsModule, V2CredentialProtocol, V2ProofProtocol } from '@credo-ts/core';
import { IndyVdrAnonCredsRegistry, IndyVdrModule } from '@credo-ts/indy-vdr';
import { PushNotificationsApnsModule, PushNotificationsFcmModule } from '@credo-ts/push-notifications';
import { useAgent } from '@credo-ts/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
    }),
    anoncreds: new AnonCredsModule({
      anoncreds,
      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(), 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()
  };
}
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