Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stratumn-sdk

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stratumn-sdk - npm Package Compare versions

Comparing version 0.1.2 to 0.2.0

lib/getBranches.js

118

dist/stratumn-sdk.js

@@ -96,2 +96,10 @@ (function webpackUniversalModuleDefinition(root, factory) {

var _getChain = __webpack_require__(9);
var _getChain2 = _interopRequireDefault(_getChain);
var _getBranches = __webpack_require__(10);
var _getBranches2 = _interopRequireDefault(_getBranches);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -114,2 +122,4 @@

app.getLink = _getLink2.default.bind(null, app);
app.getChain = _getChain2.default.bind(null, app);
app.getBranches = _getBranches2.default.bind(null, app);

@@ -1631,2 +1641,14 @@ resolve(app);

/*eslint-disable*/
obj.getBranches = function (tags) {
/*eslint-enable*/
return app.getBranches(obj.meta.linkHash, tags);
};
/*eslint-disable*/
obj.load = function () {
/*eslint-enable*/
return app.getLink(obj.meta.linkHash);
};
return obj;

@@ -1675,2 +1697,98 @@ }

/***/ },
/* 9 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = getChain;
var _superagent = __webpack_require__(2);
var _superagent2 = _interopRequireDefault(_superagent);
var _config = __webpack_require__(5);
var _config2 = _interopRequireDefault(_config);
var _linkify = __webpack_require__(7);
var _linkify2 = _interopRequireDefault(_linkify);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function getChain(app, chainId) {
var tags = arguments.length <= 2 || arguments[2] === undefined ? [] : arguments[2];
return new Promise(function (resolve, reject) {
var query = '';
if (tags && tags.length) {
query = '?tags=' + tags.join('&tags=');
}
var url = _config2.default.applicationUrl.replace('%s', app.name) + '/chains/' + chainId + query;
return _superagent2.default.get(url).end(function (err, res) {
if (err) {
reject(err);
return;
}
resolve((0, _linkify2.default)(app, res.body));
});
});
}
/***/ },
/* 10 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = getBranches;
var _superagent = __webpack_require__(2);
var _superagent2 = _interopRequireDefault(_superagent);
var _config = __webpack_require__(5);
var _config2 = _interopRequireDefault(_config);
var _linkify = __webpack_require__(7);
var _linkify2 = _interopRequireDefault(_linkify);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function getBranches(app, linkHash) {
var tags = arguments.length <= 2 || arguments[2] === undefined ? [] : arguments[2];
return new Promise(function (resolve, reject) {
var query = '';
if (tags && tags.length) {
query = '?tags=' + tags.join('&tags=');
}
var url = _config2.default.applicationUrl.replace('%s', app.name) + '/branches/' + linkHash + query;
return _superagent2.default.get(url).end(function (err, res) {
if (err) {
reject(err);
return;
}
resolve((0, _linkify2.default)(app, res.body));
});
});
}
/***/ }

@@ -1677,0 +1795,0 @@ /******/ ])

2

dist/stratumn-sdk.min.js

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.StratumnSDK=e():t.StratumnSDK=e()}(this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}var i=r(1),o=n(i);t.exports={getApplication:o["default"]}},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t){return new Promise(function(e,r){var n=u["default"].applicationUrl.replace("%s",t);return s["default"].get(n).end(function(t,i){if(t)return void r(t);var o=i.body;o.url=n,o.createChain=h["default"].bind(null,o),o.getLink=p["default"].bind(null,o),e(o)})})}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=i;var o=r(2),s=n(o),a=r(5),u=n(a),c=r(6),h=n(c),l=r(8),p=n(l)},function(t,e,r){function n(){}function i(t){var e={}.toString.call(t);switch(e){case"[object File]":case"[object Blob]":case"[object FormData]":return!0;default:return!1}}function o(t){return t===Object(t)}function s(t){if(!o(t))return t;var e=[];for(var r in t)null!=t[r]&&a(e,r,t[r]);return e.join("&")}function a(t,e,r){return Array.isArray(r)?r.forEach(function(r){a(t,e,r)}):void t.push(encodeURIComponent(e)+"="+encodeURIComponent(r))}function u(t){for(var e,r,n={},i=t.split("&"),o=0,s=i.length;s>o;++o)r=i[o],e=r.split("="),n[decodeURIComponent(e[0])]=decodeURIComponent(e[1]);return n}function c(t){var e,r,n,i,o=t.split(/\r?\n/),s={};o.pop();for(var a=0,u=o.length;u>a;++a)r=o[a],e=r.indexOf(":"),n=r.slice(0,e).toLowerCase(),i=w(r.slice(e+1)),s[n]=i;return s}function h(t){return/[\/+]json\b/.test(t)}function l(t){return t.split(/ *; */).shift()}function p(t){return _(t.split(/ *; */),function(t,e){var r=e.split(/ *= */),n=r.shift(),i=r.shift();return n&&i&&(t[n]=i),t},{})}function f(t,e){e=e||{},this.req=t,this.xhr=this.req.xhr,this.text="HEAD"!=this.req.method&&(""===this.xhr.responseType||"text"===this.xhr.responseType)||"undefined"==typeof this.xhr.responseType?this.xhr.responseText:null,this.statusText=this.req.xhr.statusText,this.setStatusProperties(this.xhr.status),this.header=this.headers=c(this.xhr.getAllResponseHeaders()),this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this.setHeaderProperties(this.header),this.body="HEAD"!=this.req.method?this.parseBody(this.text?this.text:this.xhr.response):null}function d(t,e){var r=this;b.call(this),this._query=this._query||[],this.method=t,this.url=e,this.header={},this._header={},this.on("end",function(){var t=null,e=null;try{e=new f(r)}catch(n){return t=new Error("Parser is unable to parse the response"),t.parse=!0,t.original=n,t.rawResponse=r.xhr&&r.xhr.responseText?r.xhr.responseText:null,r.callback(t)}if(r.emit("response",e),t)return r.callback(t,e);if(e.status>=200&&e.status<300)return r.callback(t,e);var i=new Error(e.statusText||"Unsuccessful HTTP response");i.original=t,i.response=e,i.status=e.status,r.callback(i,e)})}function y(t,e){return"function"==typeof e?new d("GET",t).end(e):1==arguments.length?new d("GET",t):new d(t,e)}function m(t,e){var r=y("DELETE",t);return e&&r.end(e),r}var v,b=r(3),_=r(4);v="undefined"!=typeof window?window:"undefined"!=typeof self?self:this,y.getXHR=function(){if(!(!v.XMLHttpRequest||v.location&&"file:"==v.location.protocol&&v.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(t){}return!1};var w="".trim?function(t){return t.trim()}:function(t){return t.replace(/(^\s*|\s*$)/g,"")};y.serializeObject=s,y.parseString=u,y.types={html:"text/html",json:"application/json",xml:"application/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},y.serialize={"application/x-www-form-urlencoded":s,"application/json":JSON.stringify},y.parse={"application/x-www-form-urlencoded":u,"application/json":JSON.parse},f.prototype.get=function(t){return this.header[t.toLowerCase()]},f.prototype.setHeaderProperties=function(t){var e=this.header["content-type"]||"";this.type=l(e);var r=p(e);for(var n in r)this[n]=r[n]},f.prototype.parseBody=function(t){var e=y.parse[this.type];return e&&t&&(t.length||t instanceof Object)?e(t):null},f.prototype.setStatusProperties=function(t){1223===t&&(t=204);var e=t/100|0;this.status=this.statusCode=t,this.statusType=e,this.info=1==e,this.ok=2==e,this.clientError=4==e,this.serverError=5==e,this.error=4==e||5==e?this.toError():!1,this.accepted=202==t,this.noContent=204==t,this.badRequest=400==t,this.unauthorized=401==t,this.notAcceptable=406==t,this.notFound=404==t,this.forbidden=403==t},f.prototype.toError=function(){var t=this.req,e=t.method,r=t.url,n="cannot "+e+" "+r+" ("+this.status+")",i=new Error(n);return i.status=this.status,i.method=e,i.url=r,i},y.Response=f,b(d.prototype),d.prototype.use=function(t){return t(this),this},d.prototype.timeout=function(t){return this._timeout=t,this},d.prototype.clearTimeout=function(){return this._timeout=0,clearTimeout(this._timer),this},d.prototype.abort=function(){return this.aborted?void 0:(this.aborted=!0,this.xhr.abort(),this.clearTimeout(),this.emit("abort"),this)},d.prototype.set=function(t,e){if(o(t)){for(var r in t)this.set(r,t[r]);return this}return this._header[t.toLowerCase()]=e,this.header[t]=e,this},d.prototype.unset=function(t){return delete this._header[t.toLowerCase()],delete this.header[t],this},d.prototype.getHeader=function(t){return this._header[t.toLowerCase()]},d.prototype.type=function(t){return this.set("Content-Type",y.types[t]||t),this},d.prototype.parse=function(t){return this._parser=t,this},d.prototype.accept=function(t){return this.set("Accept",y.types[t]||t),this},d.prototype.auth=function(t,e){var r=btoa(t+":"+e);return this.set("Authorization","Basic "+r),this},d.prototype.query=function(t){return"string"!=typeof t&&(t=s(t)),t&&this._query.push(t),this},d.prototype.field=function(t,e){return this._formData||(this._formData=new v.FormData),this._formData.append(t,e),this},d.prototype.attach=function(t,e,r){return this._formData||(this._formData=new v.FormData),this._formData.append(t,e,r||e.name),this},d.prototype.send=function(t){var e=o(t),r=this.getHeader("Content-Type");if(e&&o(this._data))for(var n in t)this._data[n]=t[n];else"string"==typeof t?(r||this.type("form"),r=this.getHeader("Content-Type"),"application/x-www-form-urlencoded"==r?this._data=this._data?this._data+"&"+t:t:this._data=(this._data||"")+t):this._data=t;return!e||i(t)?this:(r||this.type("json"),this)},d.prototype.callback=function(t,e){var r=this._callback;this.clearTimeout(),r(t,e)},d.prototype.crossDomainError=function(){var t=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");t.crossDomain=!0,t.status=this.status,t.method=this.method,t.url=this.url,this.callback(t)},d.prototype.timeoutError=function(){var t=this._timeout,e=new Error("timeout of "+t+"ms exceeded");e.timeout=t,this.callback(e)},d.prototype.withCredentials=function(){return this._withCredentials=!0,this},d.prototype.end=function(t){var e=this,r=this.xhr=y.getXHR(),o=this._query.join("&"),s=this._timeout,a=this._formData||this._data;this._callback=t||n,r.onreadystatechange=function(){if(4==r.readyState){var t;try{t=r.status}catch(n){t=0}if(0==t){if(e.timedout)return e.timeoutError();if(e.aborted)return;return e.crossDomainError()}e.emit("end")}};var u=function(t){t.total>0&&(t.percent=t.loaded/t.total*100),t.direction="download",e.emit("progress",t)};this.hasListeners("progress")&&(r.onprogress=u);try{r.upload&&this.hasListeners("progress")&&(r.upload.onprogress=u)}catch(c){}if(s&&!this._timer&&(this._timer=setTimeout(function(){e.timedout=!0,e.abort()},s)),o&&(o=y.serializeObject(o),this.url+=~this.url.indexOf("?")?"&"+o:"?"+o),r.open(this.method,this.url,!0),this._withCredentials&&(r.withCredentials=!0),"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof a&&!i(a)){var l=this.getHeader("Content-Type"),p=this._parser||y.serialize[l?l.split(";")[0]:""];!p&&h(l)&&(p=y.serialize["application/json"]),p&&(a=p(a))}for(var f in this.header)null!=this.header[f]&&r.setRequestHeader(f,this.header[f]);return this.emit("request",this),r.send("undefined"!=typeof a?a:null),this},d.prototype.then=function(t,e){return this.end(function(r,n){r?e(r):t(n)})},y.Request=d,y.get=function(t,e,r){var n=y("GET",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},y.head=function(t,e,r){var n=y("HEAD",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},y.del=m,y["delete"]=m,y.patch=function(t,e,r){var n=y("PATCH",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},y.post=function(t,e,r){var n=y("POST",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},y.put=function(t,e,r){var n=y("PUT",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},t.exports=y},function(t,e){function r(t){return t?n(t):void 0}function n(t){for(var e in r.prototype)t[e]=r.prototype[e];return t}t.exports=r,r.prototype.on=r.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},r.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this},r.prototype.off=r.prototype.removeListener=r.prototype.removeAllListeners=r.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r=this._callbacks["$"+t];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var n,i=0;i<r.length;i++)if(n=r[i],n===e||n.fn===e){r.splice(i,1);break}return this},r.prototype.emit=function(t){this._callbacks=this._callbacks||{};var e=[].slice.call(arguments,1),r=this._callbacks["$"+t];if(r){r=r.slice(0);for(var n=0,i=r.length;i>n;++n)r[n].apply(this,e)}return this},r.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},r.prototype.hasListeners=function(t){return!!this.listeners(t).length}},function(t,e){t.exports=function(t,e,r){for(var n=0,i=t.length,o=3==arguments.length?r:t[n++];i>n;)o=e.call(null,o,t[n],++n,t);return o}},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r={baseUrl:"https://stratumn.rocks",applicationUrl:"https://%s.stratumn.rocks"};e["default"]=r},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t){for(var e=arguments.length,r=Array(e>1?e-1:0),n=1;e>n;n++)r[n-1]=arguments[n];return new Promise(function(e,n){var i=u["default"].applicationUrl.replace("%s",t.name)+"/chains";return s["default"].post(i).send(r).end(function(r,i){return r?void n(r):void e((0,h["default"])(t,i.body))})})}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=i;var o=r(2),s=n(o),a=r(5),u=n(a),c=r(7),h=n(c)},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){return Object.keys(t.agentInfo.functions).filter(function(t){return["init","catchAll"].indexOf(t)<0}).forEach(function(r){e[r]=function(){for(var n=arguments.length,o=Array(n),a=0;n>a;a++)o[a]=arguments[a];return new Promise(function(n,a){var c=u["default"].applicationUrl.replace("%s",t.name)+"/links/"+e.meta.linkHash+"/"+r;return s["default"].post(c).send(o).end(function(e,r){return e?void a(e):void n(i(t,r.body))})})}}),e.getPrev=function(){return e.link.meta.prevLinkHash?t.getLink(e.link.meta.prevLinkHash):Promise.resolve(null)},e}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=i;var o=r(2),s=n(o),a=r(5),u=n(a)},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){return new Promise(function(r,n){var i=u["default"].applicationUrl.replace("%s",t.name)+"/links/"+e;return s["default"].get(i).end(function(e,i){return e?void n(e):void r((0,h["default"])(t,i.body))})})}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=i;var o=r(2),s=n(o),a=r(5),u=n(a),c=r(7),h=n(c)}])});
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.StratumnSDK=e():t.StratumnSDK=e()}(this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}var i=r(1),o=n(i);t.exports={getApplication:o["default"]}},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t){return new Promise(function(e,r){var n=u["default"].applicationUrl.replace("%s",t);return s["default"].get(n).end(function(t,i){if(t)return void r(t);var o=i.body;o.url=n,o.createChain=l["default"].bind(null,o),o.getLink=f["default"].bind(null,o),o.getChain=d["default"].bind(null,o),o.getBranches=v["default"].bind(null,o),e(o)})})}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=i;var o=r(2),s=n(o),a=r(5),u=n(a),c=r(6),l=n(c),h=r(8),f=n(h),p=r(9),d=n(p),y=r(10),v=n(y)},function(t,e,r){function n(){}function i(t){var e={}.toString.call(t);switch(e){case"[object File]":case"[object Blob]":case"[object FormData]":return!0;default:return!1}}function o(t){return t===Object(t)}function s(t){if(!o(t))return t;var e=[];for(var r in t)null!=t[r]&&a(e,r,t[r]);return e.join("&")}function a(t,e,r){return Array.isArray(r)?r.forEach(function(r){a(t,e,r)}):void t.push(encodeURIComponent(e)+"="+encodeURIComponent(r))}function u(t){for(var e,r,n={},i=t.split("&"),o=0,s=i.length;s>o;++o)r=i[o],e=r.split("="),n[decodeURIComponent(e[0])]=decodeURIComponent(e[1]);return n}function c(t){var e,r,n,i,o=t.split(/\r?\n/),s={};o.pop();for(var a=0,u=o.length;u>a;++a)r=o[a],e=r.indexOf(":"),n=r.slice(0,e).toLowerCase(),i=g(r.slice(e+1)),s[n]=i;return s}function l(t){return/[\/+]json\b/.test(t)}function h(t){return t.split(/ *; */).shift()}function f(t){return b(t.split(/ *; */),function(t,e){var r=e.split(/ *= */),n=r.shift(),i=r.shift();return n&&i&&(t[n]=i),t},{})}function p(t,e){e=e||{},this.req=t,this.xhr=this.req.xhr,this.text="HEAD"!=this.req.method&&(""===this.xhr.responseType||"text"===this.xhr.responseType)||"undefined"==typeof this.xhr.responseType?this.xhr.responseText:null,this.statusText=this.req.xhr.statusText,this.setStatusProperties(this.xhr.status),this.header=this.headers=c(this.xhr.getAllResponseHeaders()),this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this.setHeaderProperties(this.header),this.body="HEAD"!=this.req.method?this.parseBody(this.text?this.text:this.xhr.response):null}function d(t,e){var r=this;_.call(this),this._query=this._query||[],this.method=t,this.url=e,this.header={},this._header={},this.on("end",function(){var t=null,e=null;try{e=new p(r)}catch(n){return t=new Error("Parser is unable to parse the response"),t.parse=!0,t.original=n,t.rawResponse=r.xhr&&r.xhr.responseText?r.xhr.responseText:null,r.callback(t)}if(r.emit("response",e),t)return r.callback(t,e);if(e.status>=200&&e.status<300)return r.callback(t,e);var i=new Error(e.statusText||"Unsuccessful HTTP response");i.original=t,i.response=e,i.status=e.status,r.callback(i,e)})}function y(t,e){return"function"==typeof e?new d("GET",t).end(e):1==arguments.length?new d("GET",t):new d(t,e)}function v(t,e){var r=y("DELETE",t);return e&&r.end(e),r}var m,_=r(3),b=r(4);m="undefined"!=typeof window?window:"undefined"!=typeof self?self:this,y.getXHR=function(){if(!(!m.XMLHttpRequest||m.location&&"file:"==m.location.protocol&&m.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(t){}return!1};var g="".trim?function(t){return t.trim()}:function(t){return t.replace(/(^\s*|\s*$)/g,"")};y.serializeObject=s,y.parseString=u,y.types={html:"text/html",json:"application/json",xml:"application/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},y.serialize={"application/x-www-form-urlencoded":s,"application/json":JSON.stringify},y.parse={"application/x-www-form-urlencoded":u,"application/json":JSON.parse},p.prototype.get=function(t){return this.header[t.toLowerCase()]},p.prototype.setHeaderProperties=function(t){var e=this.header["content-type"]||"";this.type=h(e);var r=f(e);for(var n in r)this[n]=r[n]},p.prototype.parseBody=function(t){var e=y.parse[this.type];return e&&t&&(t.length||t instanceof Object)?e(t):null},p.prototype.setStatusProperties=function(t){1223===t&&(t=204);var e=t/100|0;this.status=this.statusCode=t,this.statusType=e,this.info=1==e,this.ok=2==e,this.clientError=4==e,this.serverError=5==e,this.error=4==e||5==e?this.toError():!1,this.accepted=202==t,this.noContent=204==t,this.badRequest=400==t,this.unauthorized=401==t,this.notAcceptable=406==t,this.notFound=404==t,this.forbidden=403==t},p.prototype.toError=function(){var t=this.req,e=t.method,r=t.url,n="cannot "+e+" "+r+" ("+this.status+")",i=new Error(n);return i.status=this.status,i.method=e,i.url=r,i},y.Response=p,_(d.prototype),d.prototype.use=function(t){return t(this),this},d.prototype.timeout=function(t){return this._timeout=t,this},d.prototype.clearTimeout=function(){return this._timeout=0,clearTimeout(this._timer),this},d.prototype.abort=function(){return this.aborted?void 0:(this.aborted=!0,this.xhr.abort(),this.clearTimeout(),this.emit("abort"),this)},d.prototype.set=function(t,e){if(o(t)){for(var r in t)this.set(r,t[r]);return this}return this._header[t.toLowerCase()]=e,this.header[t]=e,this},d.prototype.unset=function(t){return delete this._header[t.toLowerCase()],delete this.header[t],this},d.prototype.getHeader=function(t){return this._header[t.toLowerCase()]},d.prototype.type=function(t){return this.set("Content-Type",y.types[t]||t),this},d.prototype.parse=function(t){return this._parser=t,this},d.prototype.accept=function(t){return this.set("Accept",y.types[t]||t),this},d.prototype.auth=function(t,e){var r=btoa(t+":"+e);return this.set("Authorization","Basic "+r),this},d.prototype.query=function(t){return"string"!=typeof t&&(t=s(t)),t&&this._query.push(t),this},d.prototype.field=function(t,e){return this._formData||(this._formData=new m.FormData),this._formData.append(t,e),this},d.prototype.attach=function(t,e,r){return this._formData||(this._formData=new m.FormData),this._formData.append(t,e,r||e.name),this},d.prototype.send=function(t){var e=o(t),r=this.getHeader("Content-Type");if(e&&o(this._data))for(var n in t)this._data[n]=t[n];else"string"==typeof t?(r||this.type("form"),r=this.getHeader("Content-Type"),"application/x-www-form-urlencoded"==r?this._data=this._data?this._data+"&"+t:t:this._data=(this._data||"")+t):this._data=t;return!e||i(t)?this:(r||this.type("json"),this)},d.prototype.callback=function(t,e){var r=this._callback;this.clearTimeout(),r(t,e)},d.prototype.crossDomainError=function(){var t=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");t.crossDomain=!0,t.status=this.status,t.method=this.method,t.url=this.url,this.callback(t)},d.prototype.timeoutError=function(){var t=this._timeout,e=new Error("timeout of "+t+"ms exceeded");e.timeout=t,this.callback(e)},d.prototype.withCredentials=function(){return this._withCredentials=!0,this},d.prototype.end=function(t){var e=this,r=this.xhr=y.getXHR(),o=this._query.join("&"),s=this._timeout,a=this._formData||this._data;this._callback=t||n,r.onreadystatechange=function(){if(4==r.readyState){var t;try{t=r.status}catch(n){t=0}if(0==t){if(e.timedout)return e.timeoutError();if(e.aborted)return;return e.crossDomainError()}e.emit("end")}};var u=function(t){t.total>0&&(t.percent=t.loaded/t.total*100),t.direction="download",e.emit("progress",t)};this.hasListeners("progress")&&(r.onprogress=u);try{r.upload&&this.hasListeners("progress")&&(r.upload.onprogress=u)}catch(c){}if(s&&!this._timer&&(this._timer=setTimeout(function(){e.timedout=!0,e.abort()},s)),o&&(o=y.serializeObject(o),this.url+=~this.url.indexOf("?")?"&"+o:"?"+o),r.open(this.method,this.url,!0),this._withCredentials&&(r.withCredentials=!0),"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof a&&!i(a)){var h=this.getHeader("Content-Type"),f=this._parser||y.serialize[h?h.split(";")[0]:""];!f&&l(h)&&(f=y.serialize["application/json"]),f&&(a=f(a))}for(var p in this.header)null!=this.header[p]&&r.setRequestHeader(p,this.header[p]);return this.emit("request",this),r.send("undefined"!=typeof a?a:null),this},d.prototype.then=function(t,e){return this.end(function(r,n){r?e(r):t(n)})},y.Request=d,y.get=function(t,e,r){var n=y("GET",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},y.head=function(t,e,r){var n=y("HEAD",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},y.del=v,y["delete"]=v,y.patch=function(t,e,r){var n=y("PATCH",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},y.post=function(t,e,r){var n=y("POST",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},y.put=function(t,e,r){var n=y("PUT",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},t.exports=y},function(t,e){function r(t){return t?n(t):void 0}function n(t){for(var e in r.prototype)t[e]=r.prototype[e];return t}t.exports=r,r.prototype.on=r.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},r.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this},r.prototype.off=r.prototype.removeListener=r.prototype.removeAllListeners=r.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r=this._callbacks["$"+t];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var n,i=0;i<r.length;i++)if(n=r[i],n===e||n.fn===e){r.splice(i,1);break}return this},r.prototype.emit=function(t){this._callbacks=this._callbacks||{};var e=[].slice.call(arguments,1),r=this._callbacks["$"+t];if(r){r=r.slice(0);for(var n=0,i=r.length;i>n;++n)r[n].apply(this,e)}return this},r.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},r.prototype.hasListeners=function(t){return!!this.listeners(t).length}},function(t,e){t.exports=function(t,e,r){for(var n=0,i=t.length,o=3==arguments.length?r:t[n++];i>n;)o=e.call(null,o,t[n],++n,t);return o}},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r={baseUrl:"https://stratumn.rocks",applicationUrl:"https://%s.stratumn.rocks"};e["default"]=r},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t){for(var e=arguments.length,r=Array(e>1?e-1:0),n=1;e>n;n++)r[n-1]=arguments[n];return new Promise(function(e,n){var i=u["default"].applicationUrl.replace("%s",t.name)+"/chains";return s["default"].post(i).send(r).end(function(r,i){return r?void n(r):void e((0,l["default"])(t,i.body))})})}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=i;var o=r(2),s=n(o),a=r(5),u=n(a),c=r(7),l=n(c)},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){return Object.keys(t.agentInfo.functions).filter(function(t){return["init","catchAll"].indexOf(t)<0}).forEach(function(r){e[r]=function(){for(var n=arguments.length,o=Array(n),a=0;n>a;a++)o[a]=arguments[a];return new Promise(function(n,a){var c=u["default"].applicationUrl.replace("%s",t.name)+"/links/"+e.meta.linkHash+"/"+r;return s["default"].post(c).send(o).end(function(e,r){return e?void a(e):void n(i(t,r.body))})})}}),e.getPrev=function(){return e.link.meta.prevLinkHash?t.getLink(e.link.meta.prevLinkHash):Promise.resolve(null)},e.getBranches=function(r){return t.getBranches(e.meta.linkHash,r)},e.load=function(){return t.getLink(e.meta.linkHash)},e}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=i;var o=r(2),s=n(o),a=r(5),u=n(a)},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){return new Promise(function(r,n){var i=u["default"].applicationUrl.replace("%s",t.name)+"/links/"+e;return s["default"].get(i).end(function(e,i){return e?void n(e):void r((0,l["default"])(t,i.body))})})}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=i;var o=r(2),s=n(o),a=r(5),u=n(a),c=r(7),l=n(c)},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){var r=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];return new Promise(function(n,i){var o="";r&&r.length&&(o="?tags="+r.join("&tags="));var a=u["default"].applicationUrl.replace("%s",t.name)+"/chains/"+e+o;return s["default"].get(a).end(function(e,r){return e?void i(e):void n((0,l["default"])(t,r.body))})})}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=i;var o=r(2),s=n(o),a=r(5),u=n(a),c=r(7),l=n(c)},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){var r=arguments.length<=2||void 0===arguments[2]?[]:arguments[2];return new Promise(function(n,i){var o="";r&&r.length&&(o="?tags="+r.join("&tags="));var a=u["default"].applicationUrl.replace("%s",t.name)+"/branches/"+e+o;return s["default"].get(a).end(function(e,r){return e?void i(e):void n((0,l["default"])(t,r.body))})})}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=i;var o=r(2),s=n(o),a=r(5),u=n(a),c=r(7),l=n(c)}])});

@@ -24,2 +24,10 @@ 'use strict';

var _getChain = require('./getChain');
var _getChain2 = _interopRequireDefault(_getChain);
var _getBranches = require('./getBranches');
var _getBranches2 = _interopRequireDefault(_getBranches);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -42,2 +50,4 @@

app.getLink = _getLink2.default.bind(null, app);
app.getChain = _getChain2.default.bind(null, app);
app.getBranches = _getBranches2.default.bind(null, app);

@@ -44,0 +54,0 @@ resolve(app);

@@ -54,3 +54,15 @@ 'use strict';

/*eslint-disable*/
obj.getBranches = function (tags) {
/*eslint-enable*/
return app.getBranches(obj.meta.linkHash, tags);
};
/*eslint-disable*/
obj.load = function () {
/*eslint-enable*/
return app.getLink(obj.meta.linkHash);
};
return obj;
}
{
"name": "stratumn-sdk",
"version": "0.1.2",
"version": "0.2.0",
"description": "Stratumn SDK for Javascript",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -8,3 +8,6 @@ # Stratumn SDK for Javascript

```html
<script src="https://d3tl9uzqhxq1a1.cloudfront.net/stratumn-sdk.min.js"></script>
<!-- Polyfill for browser compatibility -->
<script src="https://libs.stratumn.com/babel-polyfill.min.js"></script>
<!-- Actual Stratumn SDK -->
<script src="https://libs.stratumn.com/stratumn-sdk.min.js"></script>
```

@@ -97,2 +100,40 @@

### Application#getChain(chainId, tags)
Returns a promise that resolves with the meta data of the links in a chain,
optionally filters by tags.
```javascript
StratumnSDK
.getApplication('quickstart')
.then(function(app) {
return app.getChain('56ef33', ['tag1', 'tag2']);
})
.then(function(res) {
console.log(res);
})
.catch(function(err) {
// Handle errors
});
```
### Application#getBranches(linkHash, tags)
Returns a promise that resolves with the meta data of the links whose previous hashes
are the given hash, optionally filters by tags.
```javascript
StratumnSDK
.getApplication('quickstart')
.then(function(app) {
return app.getBranches('abcdef', ['tag1', 'tag2']);
})
.then(function(res) {
console.log(res);
})
.catch(function(err) {
// Handle errors
});
```
### Link#getPrev()

@@ -119,2 +160,46 @@

### Link#load()
Returns a promise that resolves with the full link.
Can be useful when you only have the meta data of links.
```javascript
StratumnSDK
.getApplication('quickstart')
.then(function(app) {
return app.getBranches('aee5427');
})
.then(function(res) {
return Promise.all(res.map(function() { return res.load(); }));
})
.then(function(res) {
console.log(res);
})
.catch(function(err) {
// Handle errors
});
```
### Link#getBranches(tags)
Returns a promise that resolves with the meta data of the links whose previous hashes
are the hash of the link, optionally filters by tags.
```javascript
StratumnSDK
.getApplication('quickstart')
.then(function(app) {
return app.getLink('aee5427');
})
.then(function(app) {
return app.getBranches(['tag1']);
})
.then(function(res) {
console.log(res);
})
.catch(function(err) {
// Handle errors
});
```
### Link#:transitionFunction(...args)

@@ -121,0 +206,0 @@

@@ -5,2 +5,4 @@ import request from 'superagent';

import getLink from './getLink';
import getChain from './getChain';
import getBranches from './getBranches';

@@ -24,2 +26,4 @@ export default function getApplication(appName) {

app.getLink = getLink.bind(null, app);
app.getChain = getChain.bind(null, app);
app.getBranches = getBranches.bind(null, app);

@@ -26,0 +30,0 @@ resolve(app);

@@ -39,3 +39,15 @@ import request from 'superagent';

/*eslint-disable*/
obj.getBranches = tags => {
/*eslint-enable*/
return app.getBranches(obj.meta.linkHash, tags);
};
/*eslint-disable*/
obj.load = () => {
/*eslint-enable*/
return app.getLink(obj.meta.linkHash);
};
return obj;
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc