gscatterjs-core
Advanced tools
Comparing version 0.0.2 to 0.1.0
@@ -1,3 +0,3 @@ | ||
"use strict";var _interopRequireWildcard=require("@babel/runtime/helpers/interopRequireWildcard"),_interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator")),_asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")),_classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")),_createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass")),_PluginRepository=_interopRequireDefault(require("./plugins/PluginRepository")),_SocketService=_interopRequireDefault(require("./services/SocketService")),_Plugin=_interopRequireDefault(require("./plugins/Plugin")),PluginTypes=_interopRequireWildcard(require("./plugins/PluginTypes"));var origin,_Blockchains=require("./models/Blockchains"),_Network=_interopRequireDefault(require("./models/Network")),throwNoAuth=function(){if(!holder.scatter.isExtension&&!_SocketService.default.isConnected())throw new Error("Connect and Authenticate first - scatter.connect( pluginName )")},checkForExtension=function(a){var b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:0;return 20<b?void 0:holder.scatter.isExtension?a(!0):void setTimeout(function(){return checkForExtension(a,b+1)},100)},Index=/*#__PURE__*/function(){function a(){(0,_classCallCheck2.default)(this,a),this.isExtension=!1,this.identity=null}return(0,_createClass2.default)(a,[{key:"loadPlugin",value:function loadPlugin(a){var b=this;if(!a.isValid())throw new Error("".concat(a.name," doesn't seem to be a valid ScatterJS plugin."));_PluginRepository.default.loadPlugin(a),a.isSignatureProvider()&&(this[a.name]=a.signatureProvider(function noIdFunc(){if(!b.identity)throw new Error("No Identity")},function(){return b.identity}),this[a.name+"Hook"]=a.hookProvider)}},{key:"connect",value:function(){var a=(0,_asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function a(b,c){var d=this;return _regenerator.default.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",new Promise(function(a){if(!b||!b.length)throw new Error("You must specify a name for this connection");// Setting options defaults | ||
c=Object.assign({initTimeout:1e4,linkTimeout:3e4},c),setTimeout(function(){a(!1)},c.initTimeout),checkForExtension(a),_SocketService.default.init(b,c.linkTimeout),_SocketService.default.link().then(/*#__PURE__*/function(){var b=(0,_asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function b(c){return _regenerator.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(c){b.next=2;break}return b.abrupt("return",!1);case 2:return b.next=4,d.getIdentityFromPermissions();case 4:return d.identity=b.sent,b.abrupt("return",a(!0));case 6:case"end":return b.stop();}},b,this)}));return function(){return b.apply(this,arguments)}}())}));case 1:case"end":return a.stop();}},a,this)}));return function connect(){return a.apply(this,arguments)}}()},{key:"disconnect",value:function disconnect(){return _SocketService.default.disconnect()}},{key:"isConnected",value:function isConnected(){return _SocketService.default.isConnected()}},{key:"isPaired",value:function isPaired(){return _SocketService.default.isPaired()}},{key:"getVersion",value:function getVersion(){return _SocketService.default.sendApiRequest({type:"getVersion",payload:{}})}},{key:"getIdentity",value:function getIdentity(a){var b=this;return throwNoAuth(),_SocketService.default.sendApiRequest({type:"getOrRequestIdentity",payload:{fields:a}}).then(function(a){return a&&(b.identity=a),a})}},{key:"getIdentityFromPermissions",value:function getIdentityFromPermissions(){var a=this;return throwNoAuth(),_SocketService.default.sendApiRequest({type:"identityFromPermissions",payload:{}}).then(function(b){return b&&(a.identity=b),b})}},{key:"forgetIdentity",value:function forgetIdentity(){var a=this;return throwNoAuth(),_SocketService.default.sendApiRequest({type:"forgetIdentity",payload:{}}).then(function(b){return a.identity=null,b})}},{key:"authenticate",value:function authenticate(a){return throwNoAuth(),_SocketService.default.sendApiRequest({type:"authenticate",payload:{nonce:a}})}},{key:"getArbitrarySignature",value:function getArbitrarySignature(a,b){var c=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",d=!!(3<arguments.length&&void 0!==arguments[3])&&arguments[3];return throwNoAuth(),_SocketService.default.sendApiRequest({type:"requestArbitrarySignature",payload:{publicKey:a,data:b,whatfor:c,isHash:d}})}},{key:"getPublicKey",value:function getPublicKey(a){return throwNoAuth(),_SocketService.default.sendApiRequest({type:"getPublicKey",payload:{blockchain:a}})}},{key:"linkAccount",value:function linkAccount(a,b){return throwNoAuth(),_SocketService.default.sendApiRequest({type:"linkAccount",payload:{publicKey:a,network:b}})}},{key:"hasAccountFor",value:function hasAccountFor(a){return throwNoAuth(),_SocketService.default.sendApiRequest({type:"hasAccountFor",payload:{network:a}})}},{key:"suggestNetwork",value:function suggestNetwork(a){return throwNoAuth(),_SocketService.default.sendApiRequest({type:"requestAddNetwork",payload:{network:a}})}},{key:"requestTransfer",value:function requestTransfer(a,b,c){var d=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};return _SocketService.default.sendApiRequest({type:"requestTransfer",payload:{network:a,to:b,amount:c,options:d}})}},{key:"requestSignature",value:function requestSignature(a){return throwNoAuth(),_SocketService.default.sendApiRequest({type:"requestSignature",payload:a})}},{key:"createTransaction",value:function createTransaction(a,b,c,d){return throwNoAuth(),_SocketService.default.sendApiRequest({type:"createTransaction",payload:{blockchain:a,actions:b,account:c,network:d}})}}]),a}(),Holder=/*#__PURE__*/function(){function a(b){(0,_classCallCheck2.default)(this,a),this.scatter=b}return(0,_createClass2.default)(a,[{key:"plugins",value:function plugins(){var a=this;if(!this.scatter.isExtension){for(var b=arguments.length,c=Array(b),d=0;d<b;d++)c[d]=arguments[d];c.map(function(b){return a.scatter.loadPlugin(b)})}}}]),a}(),holder=new Holder(new Index());Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"SocketService",{enumerable:!0,get:function get(){return _SocketService.default}}),Object.defineProperty(exports,"Plugin",{enumerable:!0,get:function get(){return _Plugin.default}}),Object.defineProperty(exports,"Blockchains",{enumerable:!0,get:function get(){return _Blockchains.Blockchains}}),Object.defineProperty(exports,"Network",{enumerable:!0,get:function get(){return _Network.default}}),exports.PluginTypes=exports.default=void 0;exports.PluginTypes=PluginTypes;if("undefined"!=typeof window){// Catching extension instead of Desktop | ||
if("undefined"!=typeof document){var bindScatterClassic=function(){holder.scatter=window.scatter,holder.scatter.isExtension=!0,holder.scatter.connect=function(){return new Promise(function(a){return a(!0)})}};"undefined"==typeof window.scatter?document.addEventListener("scatterLoaded",function(){return bindScatterClassic()}):bindScatterClassic()}window.ScatterJS=holder}holder.Plugin=_Plugin.default,holder.PluginTypes=PluginTypes,holder.Blockchains=_Blockchains.Blockchains,holder.Network=_Network.default,holder.SocketService=_SocketService.default;var _default=holder;exports.default=_default; | ||
"use strict";var _interopRequireWildcard=require("@babel/runtime/helpers/interopRequireWildcard"),_interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator")),_asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")),_classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")),_createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass")),_PluginRepository=_interopRequireDefault(require("./plugins/PluginRepository")),_SocketService=_interopRequireDefault(require("./services/SocketService")),_Plugin=_interopRequireDefault(require("./plugins/Plugin")),PluginTypes=_interopRequireWildcard(require("./plugins/PluginTypes"));var origin,_Blockchains=require("./models/Blockchains"),_Network=_interopRequireDefault(require("./models/Network")),throwNoAuth=function(){if(!holder.gscatter.isExtension&&!_SocketService.default.isConnected())throw new Error("Connect and Authenticate first - gscatter.connect( pluginName )")},checkForExtension=function(a,b){var c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:0;return 30<c?void b(!1):holder.gscatter.isExtension?a(!0):void setTimeout(function(){return checkForExtension(a,c+1)},100)},Index=/*#__PURE__*/function(){function a(){(0,_classCallCheck2.default)(this,a),this.isExtension=!1,this.identity=null}return(0,_createClass2.default)(a,[{key:"loadPlugin",value:function loadPlugin(a){var b=this;if(!a.isValid())throw new Error("".concat(a.name," doesn't seem to be a valid GScatterJS plugin."));_PluginRepository.default.loadPlugin(a),a.isSignatureProvider()&&(this[a.name]=a.signatureProvider(function noIdFunc(){if(!b.identity)throw new Error("No Identity")},function(){return b.identity}),this[a.name+"Hook"]=a.hookProvider)}},{key:"connect",value:function(){var a=(0,_asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function a(b,c){return _regenerator.default.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",new Promise(function(a,d){if(!b||!b.length)throw new Error("You must specify a name for this connection");// Setting options defaults | ||
c=Object.assign({initTimeout:1e4,linkTimeout:3e4},c),setTimeout(function(){a(!1)},c.initTimeout),checkForExtension(a,d)}));case 1:case"end":return a.stop();}},a,this)}));return function connect(){return a.apply(this,arguments)}}()},{key:"disconnect",value:function disconnect(){return _SocketService.default.disconnect()}},{key:"isConnected",value:function isConnected(){return _SocketService.default.isConnected()}},{key:"isPaired",value:function isPaired(){return _SocketService.default.isPaired()}},{key:"getVersion",value:function getVersion(){return _SocketService.default.sendApiRequest({type:"getVersion",payload:{}})}},{key:"getIdentity",value:function getIdentity(a){var b=this;return throwNoAuth(),_SocketService.default.sendApiRequest({type:"getOrRequestIdentity",payload:{fields:a}}).then(function(a){return a&&(b.identity=a),a})}},{key:"getIdentityFromPermissions",value:function getIdentityFromPermissions(){var a=this;return throwNoAuth(),_SocketService.default.sendApiRequest({type:"identityFromPermissions",payload:{}}).then(function(b){return b&&(a.identity=b),b})}},{key:"forgetIdentity",value:function forgetIdentity(){var a=this;return throwNoAuth(),_SocketService.default.sendApiRequest({type:"forgetIdentity",payload:{}}).then(function(b){return a.identity=null,b})}},{key:"authenticate",value:function authenticate(a){return throwNoAuth(),_SocketService.default.sendApiRequest({type:"authenticate",payload:{nonce:a}})}},{key:"getArbitrarySignature",value:function getArbitrarySignature(a,b){var c=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"",d=!!(3<arguments.length&&void 0!==arguments[3])&&arguments[3];return throwNoAuth(),_SocketService.default.sendApiRequest({type:"requestArbitrarySignature",payload:{publicKey:a,data:b,whatfor:c,isHash:d}})}},{key:"getPublicKey",value:function getPublicKey(a){return throwNoAuth(),_SocketService.default.sendApiRequest({type:"getPublicKey",payload:{blockchain:a}})}},{key:"linkAccount",value:function linkAccount(a,b){return throwNoAuth(),_SocketService.default.sendApiRequest({type:"linkAccount",payload:{publicKey:a,network:b}})}},{key:"hasAccountFor",value:function hasAccountFor(a){return throwNoAuth(),_SocketService.default.sendApiRequest({type:"hasAccountFor",payload:{network:a}})}},{key:"suggestNetwork",value:function suggestNetwork(a){return throwNoAuth(),_SocketService.default.sendApiRequest({type:"requestAddNetwork",payload:{network:a}})}},{key:"requestTransfer",value:function requestTransfer(a,b,c){var d=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};return _SocketService.default.sendApiRequest({type:"requestTransfer",payload:{network:a,to:b,amount:c,options:d}})}},{key:"requestSignature",value:function requestSignature(a){return throwNoAuth(),_SocketService.default.sendApiRequest({type:"requestSignature",payload:a})}},{key:"createTransaction",value:function createTransaction(a,b,c,d){return throwNoAuth(),_SocketService.default.sendApiRequest({type:"createTransaction",payload:{blockchain:a,actions:b,account:c,network:d}})}}]),a}(),Holder=/*#__PURE__*/function(){function a(b){(0,_classCallCheck2.default)(this,a),this.gscatter=b}return(0,_createClass2.default)(a,[{key:"plugins",value:function plugins(){var a=this;if(!this.gscatter.isExtension){for(var b=arguments.length,c=Array(b),d=0;d<b;d++)c[d]=arguments[d];c.map(function(b){return a.gscatter.loadPlugin(b)})}}}]),a}(),holder=new Holder(new Index());Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"SocketService",{enumerable:!0,get:function get(){return _SocketService.default}}),Object.defineProperty(exports,"Plugin",{enumerable:!0,get:function get(){return _Plugin.default}}),Object.defineProperty(exports,"Blockchains",{enumerable:!0,get:function get(){return _Blockchains.Blockchains}}),Object.defineProperty(exports,"Network",{enumerable:!0,get:function get(){return _Network.default}}),exports.PluginTypes=exports.default=void 0;exports.PluginTypes=PluginTypes;if("undefined"!=typeof window){// Catching extension instead of Desktop | ||
if("undefined"!=typeof document){var bindScatterClassic=function(){holder.gscatter=window.gscatter,holder.gscatter.isExtension=!0,holder.gscatter.connect=function(){return new Promise(function(a){return a(!0)})}};"undefined"==typeof window.gscatter?document.addEventListener("gscatterLoaded",function(){return bindScatterClassic()}):bindScatterClassic()}window.GScatterJS=holder}holder.Plugin=_Plugin.default,holder.PluginTypes=PluginTypes,holder.Blockchains=_Blockchains.Blockchains,holder.Network=_Network.default,holder.SocketService=_SocketService.default;var _default=holder;exports.default=_default; |
@@ -1,1 +0,1 @@ | ||
"use strict";var _interopRequireWildcard=require("@babel/runtime/helpers/interopRequireWildcard"),_interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")),_createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass")),ErrorTypes=_interopRequireWildcard(require("./ErrorTypes")),ErrorCodes={NO_SIGNATURE:402,FORBIDDEN:403,TIMED_OUT:408,LOCKED:423,UPGRADE_REQUIRED:426,TOO_MANY_REQUESTS:429};Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ErrorCodes=void 0;exports.ErrorCodes=ErrorCodes;var Error=/*#__PURE__*/function(){function a(b,c){var d=2<arguments.length&&void 0!==arguments[2]?arguments[2]:ErrorCodes.LOCKED;(0,_classCallCheck2.default)(this,a),this.type=b,this.message=c,this.code=d,this.isError=!0}return(0,_createClass2.default)(a,null,[{key:"locked",value:function locked(){return new a(ErrorTypes.LOCKED,"The user's Scatter is locked. They have been notified and should unlock before continuing.")}},{key:"maliciousEvent",value:function maliciousEvent(){return new a(ErrorTypes.MALICIOUS,"Malicious event discarded.",ErrorCodes.FORBIDDEN)}},{key:"signatureError",value:function signatureError(b,c){return new a(b,c,ErrorCodes.NO_SIGNATURE)}},{key:"requiresUpgrade",value:function requiresUpgrade(){return new a(ErrorTypes.UPGRADE_REQUIRED,"The required version is newer than the User's Scatter",ErrorCodes.UPGRADE_REQUIRED)}},{key:"noNetwork",value:function noNetwork(){return this.signatureError("no_network","You must bind a network first")}},{key:"usedKeyProvider",value:function usedKeyProvider(){return new a(ErrorTypes.MALICIOUS,"Do not use a `keyProvider` with a Scatter. Use a `signProvider` and return only signatures to this object. A malicious person could retrieve your keys otherwise.",ErrorCodes.NO_SIGNATURE)}}]),a}();exports.default=Error; | ||
"use strict";var _interopRequireWildcard=require("@babel/runtime/helpers/interopRequireWildcard"),_interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")),_createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass")),ErrorTypes=_interopRequireWildcard(require("./ErrorTypes")),ErrorCodes={NO_SIGNATURE:402,FORBIDDEN:403,TIMED_OUT:408,LOCKED:423,UPGRADE_REQUIRED:426,TOO_MANY_REQUESTS:429};Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ErrorCodes=void 0;exports.ErrorCodes=ErrorCodes;var Error=/*#__PURE__*/function(){function a(b,c){var d=2<arguments.length&&void 0!==arguments[2]?arguments[2]:ErrorCodes.LOCKED;(0,_classCallCheck2.default)(this,a),this.type=b,this.message=c,this.code=d,this.isError=!0}return(0,_createClass2.default)(a,null,[{key:"locked",value:function locked(){return new a(ErrorTypes.LOCKED,"The user's GScatter is locked. They have been notified and should unlock before continuing.")}},{key:"maliciousEvent",value:function maliciousEvent(){return new a(ErrorTypes.MALICIOUS,"Malicious event discarded.",ErrorCodes.FORBIDDEN)}},{key:"signatureError",value:function signatureError(b,c){return new a(b,c,ErrorCodes.NO_SIGNATURE)}},{key:"requiresUpgrade",value:function requiresUpgrade(){return new a(ErrorTypes.UPGRADE_REQUIRED,"The required version is newer than the User's GScatter",ErrorCodes.UPGRADE_REQUIRED)}},{key:"noNetwork",value:function noNetwork(){return this.signatureError("no_network","You must bind a network first")}},{key:"usedKeyProvider",value:function usedKeyProvider(){return new a(ErrorTypes.MALICIOUS,"Do not use a `keyProvider` with a GScatter. Use a `signProvider` and return only signatures to this object. A malicious person could retrieve your keys otherwise.",ErrorCodes.NO_SIGNATURE)}}]),a}();exports.default=Error; |
{ | ||
"name": "gscatterjs-core", | ||
"version": "0.0.2", | ||
"version": "0.1.0", | ||
"main": "dist/index.js", | ||
@@ -13,3 +13,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "fab858c629ef37d6e5ee6c58e29ce593ff9ba784" | ||
"gitHead": "f9c3cea6e18cefd93d0237871c5c4a89400ecd9c" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
51586
800