support JSONP in externals

COUCHDB-1313
refactor replicator_db_security to be more resilient