{"version":3,"file":null,"sources":["../src/deprecated.js","../src/makeQueryString.js","../src/request.js","../src/findSegments.js","../src/getBranches.js","../src/segmentify.js","../src/createMap.js","../src/getSegment.js","../src/getMapIds.js","../src/getLink.js","../src/getMap.js","../src/getAgent.js","../src/fromSegment.js","../src/getApplication.js","../src/loadLink.js","../node_modules/httpplease/plugins/jsonrequest.js","../node_modules/httpplease/plugins/jsonresponse.js","../node_modules/httpplease/plugins/json.js","../node_modules/httpplease/plugins/cleanurl.js","../node_modules/httpplease/lib/xhr-browser.js","../node_modules/httpplease/lib/utils/delay.js","../node_modules/httpplease/lib/request.js","../node_modules/xtend/index.js","../node_modules/httpplease/lib/utils/extractResponseProps.js","../node_modules/httpplease/lib/response.js","../node_modules/httpplease/lib/error.js","../node_modules/httpplease/lib/utils/once.js","../node_modules/httpplease/lib/index.js","../src/config.js"],"sourcesContent":["export default function deprecated(oldFunc, newFunc) {\n if (!newFunc) {\n console.warn(`WARNING: ${oldFunc} is deprecated.`);\n } else {\n console.warn(`WARNING: ${oldFunc} is deprecated. Please use ${newFunc} instead.`);\n }\n}\n","/**\n * Makes a query string.\n * @param {object} obj - an object of keys\n * @returns {string} a query string\n */\nexport default function makeQueryString(obj) {\n const parts = Object.keys(obj).reduce((curr, key) => {\n const val = Array.isArray(obj[key]) ? obj[key].join('+') : obj[key];\n curr.push(`${encodeURIComponent(key)}=${encodeURIComponent(val)}`);\n return curr;\n }, []);\n\n if (parts.length) {\n return `?${parts.join('&')}`;\n }\n\n return '';\n}\n","import json from 'httpplease/plugins/json';\nimport httpplease from 'httpplease';\n\nconst request = httpplease.use(json);\n\nfunction send(method, url, args) {\n return new Promise((resolve, reject) => {\n request({ method, url, body: args }, (err, res) => {\n if (err) {\n const error = (err && err.body && err.body.meta && err.body.meta.errorMessage)\n ? new Error(err.body.meta.errorMessage)\n : err;\n error.status = err.status;\n reject(error);\n } else {\n resolve(res);\n }\n });\n });\n}\n\nexport function get(url) {\n return send('GET', url);\n}\n\nexport function post(url, args) {\n return send('POST', url, args);\n}\n","import segmentify from './segmentify';\nimport makeQueryString from './makeQueryString';\nimport { get } from './request';\n\nexport default function findSegments(agent, opts = {}) {\n return get(`${agent.url}/segments${makeQueryString(opts)}`)\n .then(res => res.body.map(obj => segmentify(agent, obj)));\n}\n","import findSegments from './findSegments';\nimport deprecated from './deprecated';\n\nexport default function getBranches(agent, prevLinkHash, tags = []) {\n deprecated(\n 'Agent#getBranches(agent, prevLinkHash, tags = [])',\n 'Agent#findSegments(agent, filter)'\n );\n\n return findSegments(agent, { prevLinkHash, tags });\n}\n","import deprecated from './deprecated';\nimport getBranches from './getBranches';\nimport { post } from './request';\n\nexport default function segmentify(agent, obj) {\n Object\n .keys(agent.agentInfo.actions)\n .filter(key => ['init'].indexOf(key) < 0)\n .forEach(key => {\n /*eslint-disable*/\n obj[key] = (...args) =>\n post(`${agent.url}/segments/${obj.meta.linkHash}/${key}`, args)\n .then(res => segmentify(agent, res.body))\n });\n\n /*eslint-disable*/\n obj.getPrev = () => {\n /*eslint-enable*/\n if (obj.link.meta.prevLinkHash) {\n return agent.getSegment(obj.link.meta.prevLinkHash);\n }\n\n return Promise.resolve(null);\n };\n\n // Deprecated.\n /*eslint-disable*/\n obj.load = () => {\n /*eslint-enable*/\n deprecated('segment#load()');\n return Promise.resolve(segmentify(agent, {\n link: JSON.parse(JSON.stringify(obj.link)),\n meta: JSON.parse(JSON.stringify(obj.meta))\n }));\n };\n\n // Deprecated.\n /*eslint-disable*/\n obj.getBranches = (...args) => {\n /*eslint-enable*/\n return getBranches(agent, obj.meta.linkHash, ...args);\n };\n\n return obj;\n}\n","import segmentify from './segmentify';\nimport { post } from './request';\n\nexport default function createMap(agent, ...args) {\n return post(`${agent.url}/segments`, args)\n .then(res => segmentify(agent, res.body));\n}\n","import segmentify from './segmentify';\nimport { get } from './request';\n\nexport default function getSegment(agent, linkHash) {\n return get(`${agent.url}/segments/${linkHash}`)\n .then(res => segmentify(agent, res.body));\n}\n","import makeQueryString from './makeQueryString';\nimport { get } from './request';\n\nexport default function getMapIds(agent, opts = {}) {\n return get(`${agent.url}/maps${makeQueryString(opts)}`)\n .then(res => res.body);\n}\n","import getSegment from './getSegment';\nimport deprecated from './deprecated';\n\nexport default function getLink(agent, hash) {\n deprecated('Agent#getLink(agent, hash)', 'Agent#getSegment(agent, hash)');\n\n return getSegment(agent, hash);\n}\n","import findSegments from './findSegments';\nimport deprecated from './deprecated';\n\nexport default function getMap(agent, mapId, tags = []) {\n deprecated('getMap(agent, mapId, tags = [])', 'findSegments(agent, filter)');\n\n return findSegments(agent, { mapId, tags });\n}\n","import createMap from './createMap';\nimport getSegment from './getSegment';\nimport findSegments from './findSegments';\nimport getMapIds from './getMapIds';\nimport { get } from './request';\n\n// Deprecated.\nimport getBranches from './getBranches';\nimport getLink from './getLink';\nimport getMap from './getMap';\n\nexport default function getAgent(url) {\n return get(url)\n .then(res => {\n const agent = res.body;\n\n agent.url = url;\n agent.createMap = createMap.bind(null, agent);\n agent.getSegment = getSegment.bind(null, agent);\n agent.findSegments = findSegments.bind(null, agent);\n agent.getMapIds = getMapIds.bind(null, agent);\n\n // Deprecated.\n agent.getBranches = getBranches.bind(null, agent);\n agent.getLink = getLink.bind(null, agent);\n agent.getMap = getMap.bind(null, agent);\n\n return agent;\n });\n}\n","import getAgent from './getAgent';\nimport segmentify from './segmentify';\n\nexport default function fromSegment(obj) {\n return getAgent(obj.meta.agentUrl || obj.meta.applicationLocation)\n .then(agent => {\n const segment = segmentify(agent, obj);\n return { agent, segment };\n });\n}\n","import getAgent from './getAgent';\nimport deprecated from './deprecated';\nimport config from './config';\n\nexport default function getApplication(name, url) {\n deprecated('getApplication(name, url)', 'getAgent(url)');\n\n return getAgent(url || config.applicationUrl.replace('%s', name));\n}\n","import fromSegment from './fromSegment';\nimport deprecated from './deprecated';\n\nexport default function loadLink(obj) {\n deprecated('loadLink(obj)', 'fromSegment(obj)');\n\n return fromSegment(obj)\n .then(({ segment }) => segment);\n}\n","'use strict';\n\nmodule.exports = {\n processRequest: function(req) {\n var\n contentType = req.header('Content-Type'),\n hasJsonContentType = contentType &&\n contentType.indexOf('application/json') !== -1;\n\n if (contentType != null && !hasJsonContentType) {\n return;\n }\n\n if (req.body) {\n if (!contentType) {\n req.header('Content-Type', 'application/json');\n }\n\n req.body = JSON.stringify(req.body);\n }\n }\n};\n","'use strict';\n\nmodule.exports = {\n processRequest: function(req) {\n var accept = req.header('Accept');\n if (accept == null) {\n req.header('Accept', 'application/json');\n }\n },\n processResponse: function(res) {\n // Check to see if the contentype is \"something/json\" or\n // \"something/somethingelse+json\"\n if (res.contentType && /^.*\\/(?:.*\\+)?json(;|$)/i.test(res.contentType)) {\n var raw = typeof res.body === 'string' ? res.body : res.text;\n if (raw) {\n res.body = JSON.parse(raw);\n }\n }\n }\n};\n","'use strict';\n\nvar jsonrequest = require('./jsonrequest'),\n jsonresponse = require('./jsonresponse');\n\nmodule.exports = {\n processRequest: function(req) {\n jsonrequest.processRequest.call(this, req);\n jsonresponse.processRequest.call(this, req);\n },\n processResponse: function(res) {\n jsonresponse.processResponse.call(this, res);\n }\n};\n","'use strict';\n\nmodule.exports = {\n processRequest: function(req) {\n req.url = req.url.replace(/[^%]+/g, function(s) {\n return encodeURI(s);\n });\n }\n};\n","module.exports = window.XMLHttpRequest;\n","'use strict';\n\n// Wrap a function in a `setTimeout` call. This is used to guarantee async\n// behavior, which can avoid unexpected errors.\n\nmodule.exports = function(fn) {\n return function() {\n var\n args = Array.prototype.slice.call(arguments, 0),\n newFunc = function() {\n return fn.apply(null, args);\n };\n setTimeout(newFunc, 0);\n };\n};\n","'use strict';\n\nfunction Request(optsOrUrl) {\n var opts = typeof optsOrUrl === 'string' ? {url: optsOrUrl} : optsOrUrl || {};\n this.method = opts.method ? opts.method.toUpperCase() : 'GET';\n this.url = opts.url;\n this.headers = opts.headers || {};\n this.body = opts.body;\n this.timeout = opts.timeout || 0;\n this.errorOn404 = opts.errorOn404 != null ? opts.errorOn404 : true;\n this.onload = opts.onload;\n this.onerror = opts.onerror;\n}\n\nRequest.prototype.abort = function() {\n if (this.aborted) return;\n this.aborted = true;\n this.xhr.abort();\n return this;\n};\n\nRequest.prototype.header = function(name, value) {\n var k;\n for (k in this.headers) {\n if (this.headers.hasOwnProperty(k)) {\n if (name.toLowerCase() === k.toLowerCase()) {\n if (arguments.length === 1) {\n return this.headers[k];\n }\n\n delete this.headers[k];\n break;\n }\n }\n }\n if (value != null) {\n this.headers[name] = value;\n return value;\n }\n};\n\n\nmodule.exports = Request;\n","module.exports = extend\n\nfunction extend() {\n var target = {}\n\n for (var i = 0; i < arguments.length; i++) {\n var source = arguments[i]\n\n for (var key in source) {\n if (source.hasOwnProperty(key)) {\n target[key] = source[key]\n }\n }\n }\n\n return target\n}\n","'use strict';\n\nvar extend = require('xtend');\n\nmodule.exports = function(req) {\n var xhr = req.xhr;\n var props = {request: req, xhr: xhr};\n\n // Try to create the response from the request. If the request was aborted,\n // accesssing properties of the XHR may throw an error, so we wrap in a\n // try/catch.\n try {\n var lines, i, m, headers = {};\n if (xhr.getAllResponseHeaders) {\n lines = xhr.getAllResponseHeaders().split('\\n');\n for (i = 0; i < lines.length; i++) {\n if ((m = lines[i].match(/\\s*([^\\s]+):\\s+([^\\s]+)/))) {\n headers[m[1]] = m[2];\n }\n }\n }\n\n props = extend(props, {\n status: xhr.status,\n contentType: xhr.contentType || (xhr.getResponseHeader && xhr.getResponseHeader('Content-Type')),\n headers: headers,\n text: xhr.responseText,\n body: xhr.response || xhr.responseText\n });\n } catch (err) {}\n\n return props;\n};\n","'use strict';\n\nvar Request = require('./request');\nvar extractResponseProps = require('./utils/extractResponseProps');\n\nfunction Response(props) {\n this.request = props.request;\n this.xhr = props.xhr;\n this.headers = props.headers || {};\n this.status = props.status || 0;\n this.text = props.text;\n this.body = props.body;\n this.contentType = props.contentType;\n this.isHttpError = props.status >= 400;\n}\n\nResponse.prototype.header = Request.prototype.header;\n\nResponse.fromRequest = function(req) {\n return new Response(extractResponseProps(req));\n};\n\n\nmodule.exports = Response;\n","'use strict';\n\nvar Response = require('./response');\nvar extractResponseProps = require('./utils/extractResponseProps');\nvar extend = require('xtend');\n\nfunction RequestError(message, props) {\n var err = new Error(message);\n err.name = 'RequestError';\n this.name = err.name;\n this.message = err.message;\n if (err.stack) {\n this.stack = err.stack;\n }\n\n this.toString = function() {\n return this.message;\n };\n\n for (var k in props) {\n if (props.hasOwnProperty(k)) {\n this[k] = props[k];\n }\n }\n}\n\nRequestError.prototype = extend(Error.prototype);\nRequestError.prototype.constructor = RequestError;\n\nRequestError.create = function(message, req, props) {\n var err = new RequestError(message, props);\n Response.call(err, extractResponseProps(req));\n return err;\n};\n\nmodule.exports = RequestError;\n","'use strict';\n\n// A \"once\" utility.\nmodule.exports = function(fn) {\n var result, called = false;\n return function() {\n if (!called) {\n called = true;\n result = fn.apply(this, arguments);\n }\n return result;\n };\n};\n","'use strict';\n\nvar\n cleanURL = require('../plugins/cleanurl'),\n XHR = require('./xhr'),\n delay = require('./utils/delay'),\n RequestError = require('./error'),\n Response = require('./response'),\n Request = require('./request'),\n extend = require('xtend'),\n once = require('./utils/once');\n\nvar i,\n createError = RequestError.create;\n\nfunction factory(defaults, plugins) {\n defaults = defaults || {};\n plugins = plugins || [];\n\n function http(req, cb) {\n var xhr, plugin, done, k, timeoutId, supportsLoadAndErrorEvents;\n\n req = new Request(extend(defaults, req));\n\n for (i = 0; i < plugins.length; i++) {\n plugin = plugins[i];\n if (plugin.processRequest) {\n plugin.processRequest(req);\n }\n }\n\n // Give the plugins a chance to create the XHR object\n for (i = 0; i < plugins.length; i++) {\n plugin = plugins[i];\n if (plugin.createXHR) {\n xhr = plugin.createXHR(req);\n break; // First come, first serve\n }\n }\n xhr = xhr || new XHR();\n\n req.xhr = xhr;\n\n // Use a single completion callback. This can be called with or without\n // an error. If no error is passed, the request will be examined to see\n // if it was successful.\n done = once(delay(function(rawError) {\n clearTimeout(timeoutId);\n xhr.onload = xhr.onerror = xhr.onabort = xhr.onreadystatechange = xhr.ontimeout = xhr.onprogress = null;\n\n var err = getError(req, rawError);\n\n var res = err || Response.fromRequest(req);\n for (i = 0; i < plugins.length; i++) {\n plugin = plugins[i];\n if (plugin.processResponse) {\n plugin.processResponse(res);\n }\n }\n\n // Invoke callbacks\n if (err && req.onerror) req.onerror(err);\n if (!err && req.onload) req.onload(res);\n if (cb) cb(err, err ? undefined : res);\n\n }));\n\n supportsLoadAndErrorEvents = ('onload' in xhr) && ('onerror' in xhr);\n xhr.onload = function() { done(); };\n xhr.onerror = done;\n xhr.onabort = function() { done(); };\n\n // We'd rather use `onload`, `onerror`, and `onabort` since they're the\n // only way to reliably detect successes and failures but, if they\n // aren't available, we fall back to using `onreadystatechange`.\n xhr.onreadystatechange = function() {\n if (xhr.readyState !== 4) return;\n\n if (req.aborted) return done();\n\n if (!supportsLoadAndErrorEvents) {\n // Assume a status of 0 is an error. This could be a false\n // positive, but there's no way to tell when using\n // `onreadystatechange` ):\n // See matthewwithanm/react-inlinesvg#10.\n\n // Some browsers don't like you reading XHR properties when the\n // XHR has been aborted. In case we've gotten here as a result\n // of that (either our calling `about()` in the timeout handler\n // or the user calling it directly even though they shouldn't),\n // be careful about accessing it.\n var status;\n try {\n status = xhr.status;\n } catch (err) {}\n var err = status === 0 ? new Error('Internal XHR Error') : null;\n return done(err);\n }\n };\n\n // IE sometimes fails if you don't specify every handler.\n // See http://social.msdn.microsoft.com/Forums/ie/en-US/30ef3add-767c-4436-b8a9-f1ca19b4812e/ie9-rtm-xdomainrequest-issued-requests-may-abort-if-all-event-handlers-not-specified?forum=iewebdevelopment\n xhr.ontimeout = function() { /* noop */ };\n xhr.onprogress = function() { /* noop */ };\n\n xhr.open(req.method, req.url);\n\n if (req.timeout) {\n // If we use the normal XHR timeout mechanism (`xhr.timeout` and\n // `xhr.ontimeout`), `onreadystatechange` will be triggered before\n // `ontimeout`. There's no way to recognize that it was triggered by\n // a timeout, and we'd be unable to dispatch the right error.\n timeoutId = setTimeout(function() {\n req.timedOut = true;\n done();\n try {\n xhr.abort();\n } catch (err) {}\n }, req.timeout);\n }\n\n for (k in req.headers) {\n if (req.headers.hasOwnProperty(k)) {\n xhr.setRequestHeader(k, req.headers[k]);\n }\n }\n\n xhr.send(req.body);\n\n return req;\n }\n\n var method,\n methods = ['get', 'post', 'put', 'head', 'patch', 'delete'],\n verb = function(method) {\n return function(req, cb) {\n req = new Request(req);\n req.method = method;\n return http(req, cb);\n };\n };\n for (i = 0; i < methods.length; i++) {\n method = methods[i];\n http[method] = verb(method);\n }\n\n http.plugins = function() {\n return plugins;\n };\n\n http.defaults = function(newValues) {\n if (newValues) {\n return factory(extend(defaults, newValues), plugins);\n }\n return defaults;\n };\n\n http.use = function() {\n var newPlugins = Array.prototype.slice.call(arguments, 0);\n return factory(defaults, plugins.concat(newPlugins));\n };\n\n http.bare = function() {\n return factory();\n };\n\n http.Request = Request;\n http.Response = Response;\n http.RequestError = RequestError;\n\n return http;\n}\n\nmodule.exports = factory({}, [cleanURL]);\n\n/**\n * Analyze the request to see if it represents an error. If so, return it! An\n * original error object can be passed as a hint.\n */\nfunction getError(req, err) {\n if (req.aborted) return createError('Request aborted', req, {name: 'Abort'});\n\n if (req.timedOut) return createError('Request timeout', req, {name: 'Timeout'});\n\n var xhr = req.xhr;\n var type = Math.floor(xhr.status / 100);\n\n var kind;\n switch (type) {\n case 0:\n case 2:\n // These don't represent errors unless the function was passed an\n // error object explicitly.\n if (!err) return;\n return createError(err.message, req);\n case 4:\n // Sometimes 4XX statuses aren't errors.\n if (xhr.status === 404 && !req.errorOn404) return;\n kind = 'Client';\n break;\n case 5:\n kind = 'Server';\n break;\n default:\n kind = 'HTTP';\n }\n var msg = kind + ' Error: ' +\n 'The server returned a status of ' + xhr.status +\n ' for the request \"' +\n req.method.toUpperCase() + ' ' + req.url + '\"';\n return createError(msg, req);\n}\n","// Deprecated.\nexport default {\n applicationUrl: 'https://%s.stratumn.rocks'\n};\n"],"names":["deprecated","oldFunc","newFunc","warn","makeQueryString","obj","parts","Object","keys","reduce","curr","key","val","Array","isArray","join","push","encodeURIComponent","length","send","method","url","args","Promise","resolve","reject","body","err","res","error","meta","errorMessage","Error","status","get","post","findSegments","agent","opts","then","map","segmentify","getBranches","prevLinkHash","tags","agentInfo","actions","filter","indexOf","forEach","linkHash","getPrev","link","getSegment","load","JSON","parse","stringify","createMap","getMapIds","getLink","hash","getMap","mapId","getAgent","bind","fromSegment","agentUrl","applicationLocation","segment","getApplication","name","config","applicationUrl","replace","loadLink","module","exports","processRequest","req","contentType","header","hasJsonContentType","accept","processResponse","test","raw","text","jsonrequest","commonjsHelpers.interopDefault","jsonresponse","call","this","s","encodeURI","window","XMLHttpRequest","fn","prototype","slice","arguments","apply","setTimeout","Request","optsOrUrl","toUpperCase","headers","timeout","errorOn404","onload","onerror","abort","aborted","xhr","value","k","hasOwnProperty","toLowerCase","extend","target","i","source","props","request","lines","m","getAllResponseHeaders","split","match","getResponseHeader","responseText","response","Response","isHttpError","extractResponseProps","fromRequest","RequestError","message","stack","toString","constructor","create","result","called","factory","defaults","plugins","http","cb","plugin","done","timeoutId","supportsLoadAndErrorEvents","createXHR","XHR","once","delay","rawError","clearTimeout","onabort","onreadystatechange","ontimeout","onprogress","getError","undefined","readyState","open","timedOut","setRequestHeader","methods","verb","newValues","use","newPlugins","concat","bare","createError","kind","type","Math","floor","msg","cleanURL","httpplease","json"],"mappings":"4MAAe,SAASA,GAAWC,EAASC,GACrCA,UAGKC,iBAAiBF,gCAAqCC,uBAFtDC,iBAAiBF,qBCG7B,QAAwBG,GAAgBC,MAChCC,GAAQC,OAAOC,KAAKH,GAAKI,OAAO,SAACC,EAAMC,MACrCC,GAAMC,MAAMC,QAAQT,EAAIM,IAAQN,EAAIM,GAAKI,KAAK,KAAOV,EAAIM,YAC1DK,KAAQC,mBAAmBN,OAAQM,mBAAmBL,IACpDF,aAGLJ,GAAMY,WACGZ,EAAMS,KAAK,KAGjB,wICXT,QAASI,GAAKC,EAAQC,EAAKC,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