// 
// The native code will use this file to set up the IO object
// before sending it across the bridge to the core side.

import { pbkdf2, secp256k1 } from 'react-native-fast-crypto'
import { Socket } from 'react-native-tcp'
import { bridgifyObject } from 'yaob'

import {



  makeEdgeSocket
} from './plugin/pluginIo.js'

export default function makeCustomIo() {
  bridgifyObject(pbkdf2)
  bridgifyObject(secp256k1)

  return {
    pbkdf2,
    secp256k1,
    makeSocket(opts) {
      let socket
      if (opts.type === 'tcp') socket = new Socket()
      else if (opts.type === 'tls') throw new Error('No TLS support')
      else throw new Error('Unsupported socket type')

      return Promise.resolve(makeEdgeSocket(socket, opts))
    }
  }
}
