UNPKG

mapeo-id-bmf

Version:

iD Editor for osm-p2p & mapeo-desktop changed to meet requirements of Bruno Manser Fonds

34 lines (32 loc) 1.12 kB
import * as d3 from 'd3'; export function osmAuth () { var o = {}; return { authenticated: function () { return true; }, logout: function () { return this; }, authenticate: function (cb) { return cb(); }, bootstrapToken: function (token, cb) { cb(null, this); }, xhr: function (opts, cb) { console.log(opts.method, opts.path, { headers: (opts.options || {}).header || {} }); var xhr = d3.request(o.url + opts.path); var headers = (opts.options || {}).header || {}; Object.keys(headers).forEach(function (name) { xhr.header(name, headers[name]); }); var data = (opts.content == null) ? undefined : opts.content; xhr.send(opts.method, data, function (err, xhr) { if (err) return cb(err); else if (xhr.responseXML) return cb(null, xhr.responseXML); else return cb(null, xhr.response); }); }, preauth: function (c) {}, options: function (_) { if (!arguments.length) return o; o = _; o.url = o.url || 'http://www.openstreetmap.org'; } }; }