Socket
Socket
Sign inDemoInstall

@cryptoscamdb/api

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cryptoscamdb/api - npm Package Compare versions

Comparing version 1.0.0 to 1.1.1

2

lib/api.js

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

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("api",[],e):"object"==typeof exports?exports.api=e():t.api=e()}(window,function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";var n=function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(s,a)}c((n=n.apply(t,e||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),r(1);const o=r(3);e.API_ENDPOINT="https://cryptoscamdb.org/api";e.default=class{constructor(t={cache:{enabled:!1}}){this.cacheEnabled=!1,t.cache&&t.cache.enabled&&(this.cacheEnabled=!0,this.cacheProvider=t.cache.cacheProvider||new o.MemoryCacheProvider,this.cacheDuration=t.cache.cacheDuration||6e5)}check(t){return n(this,void 0,void 0,function*(){return this.getOrFetch(`check-${t}`,()=>new Promise((r,n)=>{fetch(`${e.API_ENDPOINT}/check/${t}`).then(t=>t.json()).then(r).catch(n)}))})}getAllScams(){return n(this,void 0,void 0,function*(){return this.getOrFetch("all-scams",()=>new Promise((t,r)=>{fetch(`${e.API_ENDPOINT}/scams`).then(t=>t.json()).then(t).catch(r)}))})}getAllScamsByAddress(){return n(this,void 0,void 0,function*(){return this.getOrFetch("all-scams-by-address",()=>new Promise((t,r)=>{fetch(`${e.API_ENDPOINT}/addresses`).then(t=>t.json()).then(t).catch(r)}))})}getAllScamsByIP(){return n(this,void 0,void 0,function*(){return this.getOrFetch("all-scams-by-ip",()=>new Promise((t,r)=>{fetch(`${e.API_ENDPOINT}/ips`).then(t=>t.json()).then(t).catch(r)}))})}getOrFetch(t,e){return n(this,void 0,void 0,function*(){if(this.cacheEnabled&&(yield this.cacheProvider.has(t))&&(new Date).getTime()-(yield this.cacheProvider.getTimestamp(t))<this.cacheDuration){const e=yield this.cacheProvider.get(t);if(e)return e}const r=yield e();return this.cacheEnabled&&(yield this.cacheProvider.set(t,r)),r})}}},function(t,e,r){r(2),t.exports=self.fetch.bind(self)},function(t,e,r){"use strict";r.r(e),r.d(e,"Headers",function(){return u}),r.d(e,"Request",function(){return b}),r.d(e,"Response",function(){return v}),r.d(e,"DOMException",function(){return P}),r.d(e,"fetch",function(){return g});var n={searchParams:"URLSearchParams"in self,iterable:"Symbol"in self&&"iterator"in Symbol,blob:"FileReader"in self&&"Blob"in self&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in self,arrayBuffer:"ArrayBuffer"in self};if(n.arrayBuffer)var o=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],i=ArrayBuffer.isView||function(t){return t&&o.indexOf(Object.prototype.toString.call(t))>-1};function s(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function a(t){return"string"!=typeof t&&(t=String(t)),t}function c(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return n.iterable&&(e[Symbol.iterator]=function(){return e}),e}function u(t){this.map={},t instanceof u?t.forEach(function(t,e){this.append(e,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function h(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function f(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function d(t){var e=new FileReader,r=f(e);return e.readAsArrayBuffer(t),r}function l(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function y(){return this.bodyUsed=!1,this._initBody=function(t){this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:n.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:n.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:n.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():n.arrayBuffer&&n.blob&&function(t){return t&&DataView.prototype.isPrototypeOf(t)}(t)?(this._bodyArrayBuffer=l(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):n.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||i(t))?this._bodyArrayBuffer=l(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):n.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},n.blob&&(this.blob=function(){var t=h(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?h(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(d)}),this.text=function(){var t=h(this);if(t)return t;if(this._bodyBlob)return function(t){var e=new FileReader,r=f(e);return e.readAsText(t),r}(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},n.formData&&(this.formData=function(){return this.text().then(m)}),this.json=function(){return this.text().then(JSON.parse)},this}u.prototype.append=function(t,e){t=s(t),e=a(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},u.prototype.delete=function(t){delete this.map[s(t)]},u.prototype.get=function(t){return t=s(t),this.has(t)?this.map[t]:null},u.prototype.has=function(t){return this.map.hasOwnProperty(s(t))},u.prototype.set=function(t,e){this.map[s(t)]=a(e)},u.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},u.prototype.keys=function(){var t=[];return this.forEach(function(e,r){t.push(r)}),c(t)},u.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),c(t)},u.prototype.entries=function(){var t=[];return this.forEach(function(e,r){t.push([r,e])}),c(t)},n.iterable&&(u.prototype[Symbol.iterator]=u.prototype.entries);var p=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function b(t,e){var r=(e=e||{}).body;if(t instanceof b){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new u(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,r||null==t._bodyInit||(r=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new u(e.headers)),this.method=function(t){var e=t.toUpperCase();return p.indexOf(e)>-1?e:t}(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(r)}function m(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),o=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(o))}}),e}function v(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new u(e.headers),this.url=e.url||"",this._initBody(t)}b.prototype.clone=function(){return new b(this,{body:this._bodyInit})},y.call(b.prototype),y.call(v.prototype),v.prototype.clone=function(){return new v(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new u(this.headers),url:this.url})},v.error=function(){var t=new v(null,{status:0,statusText:""});return t.type="error",t};var w=[301,302,303,307,308];v.redirect=function(t,e){if(-1===w.indexOf(e))throw new RangeError("Invalid status code");return new v(null,{status:e,headers:{location:t}})};var P=self.DOMException;try{new P}catch(t){(P=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack}).prototype=Object.create(Error.prototype),P.prototype.constructor=P}function g(t,e){return new Promise(function(r,o){var i=new b(t,e);if(i.signal&&i.signal.aborted)return o(new P("Aborted","AbortError"));var s=new XMLHttpRequest;function a(){s.abort()}s.onload=function(){var t={status:s.status,statusText:s.statusText,headers:function(t){var e=new u;return t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(t){var r=t.split(":"),n=r.shift().trim();if(n){var o=r.join(":").trim();e.append(n,o)}}),e}(s.getAllResponseHeaders()||"")};t.url="responseURL"in s?s.responseURL:t.headers.get("X-Request-URL");var e="response"in s?s.response:s.responseText;r(new v(e,t))},s.onerror=function(){o(new TypeError("Network request failed"))},s.ontimeout=function(){o(new TypeError("Network request failed"))},s.onabort=function(){o(new P("Aborted","AbortError"))},s.open(i.method,i.url,!0),"include"===i.credentials?s.withCredentials=!0:"omit"===i.credentials&&(s.withCredentials=!1),"responseType"in s&&n.blob&&(s.responseType="blob"),i.headers.forEach(function(t,e){s.setRequestHeader(e,t)}),i.signal&&(i.signal.addEventListener("abort",a),s.onreadystatechange=function(){4===s.readyState&&i.signal.removeEventListener("abort",a)}),s.send(void 0===i._bodyInit?null:i._bodyInit)})}g.polyfill=!0,self.fetch||(self.fetch=g,self.Headers=u,self.Request=b,self.Response=v)},function(t,e,r){"use strict";var n=function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(s,a)}c((n=n.apply(t,e||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});e.MemoryCacheProvider=class{constructor(){this.cache={}}get(t){return n(this,void 0,void 0,function*(){return this.cache[t].value})}getTimestamp(t){return n(this,void 0,void 0,function*(){return this.cache[t].timestamp})}set(t,e){return n(this,void 0,void 0,function*(){return this.cache[t]={timestamp:(new Date).getTime(),value:e},!0})}has(t){return n(this,void 0,void 0,function*(){return!!this.cache[t]})}remove(t){return n(this,void 0,void 0,function*(){return delete this.cache[t],!0})}}}])});
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("csdbapi",[],e):"object"==typeof exports?exports.csdbapi=e():t.csdbapi=e()}(window,function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";var n=function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(s,a)}c((n=n.apply(t,e||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),r(1);const o=r(3);e.API_ENDPOINT="https://cryptoscamdb.org/api/v1";e.default=class{constructor(t={cache:{enabled:!1}}){this.cacheEnabled=!1,t.cache&&t.cache.enabled&&(this.cacheEnabled=!0,this.cacheProvider=t.cache.cacheProvider||new o.MemoryCacheProvider,this.cacheDuration=t.cache.cacheDuration||6e5)}check(t){return n(this,void 0,void 0,function*(){return this.getOrFetch(`check-${t}`,()=>new Promise((r,n)=>{fetch(`${e.API_ENDPOINT}/check/${t}`).then(t=>t.json()).then(r).catch(n)}))})}getAllScams(){return n(this,void 0,void 0,function*(){return this.getOrFetch("all-scams",()=>new Promise((t,r)=>{fetch(`${e.API_ENDPOINT}/scams`).then(t=>t.json()).then(t).catch(r)}))})}getAllScamsByAddress(){return n(this,void 0,void 0,function*(){return this.getOrFetch("all-scams-by-address",()=>new Promise((t,r)=>{fetch(`${e.API_ENDPOINT}/addresses`).then(t=>t.json()).then(t).catch(r)}))})}getAllScamsByIP(){return n(this,void 0,void 0,function*(){return this.getOrFetch("all-scams-by-ip",()=>new Promise((t,r)=>{fetch(`${e.API_ENDPOINT}/ips`).then(t=>t.json()).then(t).catch(r)}))})}getOrFetch(t,e){return n(this,void 0,void 0,function*(){if(this.cacheEnabled&&(yield this.cacheProvider.has(t))&&(new Date).getTime()-(yield this.cacheProvider.getTimestamp(t))<this.cacheDuration){const e=yield this.cacheProvider.get(t);if(e)return e}const r=yield e();return this.cacheEnabled&&(yield this.cacheProvider.set(t,r)),r})}}},function(t,e,r){r(2),t.exports=self.fetch.bind(self)},function(t,e,r){"use strict";r.r(e),r.d(e,"Headers",function(){return u}),r.d(e,"Request",function(){return b}),r.d(e,"Response",function(){return v}),r.d(e,"DOMException",function(){return P}),r.d(e,"fetch",function(){return g});var n={searchParams:"URLSearchParams"in self,iterable:"Symbol"in self&&"iterator"in Symbol,blob:"FileReader"in self&&"Blob"in self&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in self,arrayBuffer:"ArrayBuffer"in self};if(n.arrayBuffer)var o=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],i=ArrayBuffer.isView||function(t){return t&&o.indexOf(Object.prototype.toString.call(t))>-1};function s(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function a(t){return"string"!=typeof t&&(t=String(t)),t}function c(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return n.iterable&&(e[Symbol.iterator]=function(){return e}),e}function u(t){this.map={},t instanceof u?t.forEach(function(t,e){this.append(e,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function h(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function f(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function d(t){var e=new FileReader,r=f(e);return e.readAsArrayBuffer(t),r}function l(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function y(){return this.bodyUsed=!1,this._initBody=function(t){this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:n.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:n.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:n.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():n.arrayBuffer&&n.blob&&function(t){return t&&DataView.prototype.isPrototypeOf(t)}(t)?(this._bodyArrayBuffer=l(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):n.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||i(t))?this._bodyArrayBuffer=l(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):n.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},n.blob&&(this.blob=function(){var t=h(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?h(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(d)}),this.text=function(){var t=h(this);if(t)return t;if(this._bodyBlob)return function(t){var e=new FileReader,r=f(e);return e.readAsText(t),r}(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},n.formData&&(this.formData=function(){return this.text().then(m)}),this.json=function(){return this.text().then(JSON.parse)},this}u.prototype.append=function(t,e){t=s(t),e=a(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},u.prototype.delete=function(t){delete this.map[s(t)]},u.prototype.get=function(t){return t=s(t),this.has(t)?this.map[t]:null},u.prototype.has=function(t){return this.map.hasOwnProperty(s(t))},u.prototype.set=function(t,e){this.map[s(t)]=a(e)},u.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},u.prototype.keys=function(){var t=[];return this.forEach(function(e,r){t.push(r)}),c(t)},u.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),c(t)},u.prototype.entries=function(){var t=[];return this.forEach(function(e,r){t.push([r,e])}),c(t)},n.iterable&&(u.prototype[Symbol.iterator]=u.prototype.entries);var p=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function b(t,e){var r=(e=e||{}).body;if(t instanceof b){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new u(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,r||null==t._bodyInit||(r=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new u(e.headers)),this.method=function(t){var e=t.toUpperCase();return p.indexOf(e)>-1?e:t}(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(r)}function m(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),o=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(o))}}),e}function v(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new u(e.headers),this.url=e.url||"",this._initBody(t)}b.prototype.clone=function(){return new b(this,{body:this._bodyInit})},y.call(b.prototype),y.call(v.prototype),v.prototype.clone=function(){return new v(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new u(this.headers),url:this.url})},v.error=function(){var t=new v(null,{status:0,statusText:""});return t.type="error",t};var w=[301,302,303,307,308];v.redirect=function(t,e){if(-1===w.indexOf(e))throw new RangeError("Invalid status code");return new v(null,{status:e,headers:{location:t}})};var P=self.DOMException;try{new P}catch(t){(P=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack}).prototype=Object.create(Error.prototype),P.prototype.constructor=P}function g(t,e){return new Promise(function(r,o){var i=new b(t,e);if(i.signal&&i.signal.aborted)return o(new P("Aborted","AbortError"));var s=new XMLHttpRequest;function a(){s.abort()}s.onload=function(){var t={status:s.status,statusText:s.statusText,headers:function(t){var e=new u;return t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(t){var r=t.split(":"),n=r.shift().trim();if(n){var o=r.join(":").trim();e.append(n,o)}}),e}(s.getAllResponseHeaders()||"")};t.url="responseURL"in s?s.responseURL:t.headers.get("X-Request-URL");var e="response"in s?s.response:s.responseText;r(new v(e,t))},s.onerror=function(){o(new TypeError("Network request failed"))},s.ontimeout=function(){o(new TypeError("Network request failed"))},s.onabort=function(){o(new P("Aborted","AbortError"))},s.open(i.method,i.url,!0),"include"===i.credentials?s.withCredentials=!0:"omit"===i.credentials&&(s.withCredentials=!1),"responseType"in s&&n.blob&&(s.responseType="blob"),i.headers.forEach(function(t,e){s.setRequestHeader(e,t)}),i.signal&&(i.signal.addEventListener("abort",a),s.onreadystatechange=function(){4===s.readyState&&i.signal.removeEventListener("abort",a)}),s.send(void 0===i._bodyInit?null:i._bodyInit)})}g.polyfill=!0,self.fetch||(self.fetch=g,self.Headers=u,self.Request=b,self.Response=v)},function(t,e,r){"use strict";var n=function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(s,a)}c((n=n.apply(t,e||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});e.MemoryCacheProvider=class{constructor(){this.cache={}}get(t){return n(this,void 0,void 0,function*(){return this.cache[t].value})}getTimestamp(t){return n(this,void 0,void 0,function*(){return this.cache[t].timestamp})}set(t,e){return n(this,void 0,void 0,function*(){return this.cache[t]={timestamp:(new Date).getTime(),value:e},!0})}has(t){return n(this,void 0,void 0,function*(){return!!this.cache[t]})}remove(t){return n(this,void 0,void 0,function*(){return delete this.cache[t],!0})}}}]).default});
//# sourceMappingURL=api.js.map

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

module.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var c=t[r]={i:r,l:!1,exports:{}};return e[r].call(c.exports,c,c.exports,n),c.l=!0,c.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var c in e)n.d(r,c,function(t){return e[t]}.bind(null,c));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";var r=function(e,t,n,r){return new(n||(n=Promise))(function(c,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function u(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){e.done?c(e.value):new n(function(t){t(e.value)}).then(o,u)}a((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),n(1);const c=n(2);t.API_ENDPOINT="https://cryptoscamdb.org/api";t.default=class{constructor(e={cache:{enabled:!1}}){this.cacheEnabled=!1,e.cache&&e.cache.enabled&&(this.cacheEnabled=!0,this.cacheProvider=e.cache.cacheProvider||new c.MemoryCacheProvider,this.cacheDuration=e.cache.cacheDuration||6e5)}check(e){return r(this,void 0,void 0,function*(){return this.getOrFetch(`check-${e}`,()=>new Promise((n,r)=>{fetch(`${t.API_ENDPOINT}/check/${e}`).then(e=>e.json()).then(n).catch(r)}))})}getAllScams(){return r(this,void 0,void 0,function*(){return this.getOrFetch("all-scams",()=>new Promise((e,n)=>{fetch(`${t.API_ENDPOINT}/scams`).then(e=>e.json()).then(e).catch(n)}))})}getAllScamsByAddress(){return r(this,void 0,void 0,function*(){return this.getOrFetch("all-scams-by-address",()=>new Promise((e,n)=>{fetch(`${t.API_ENDPOINT}/addresses`).then(e=>e.json()).then(e).catch(n)}))})}getAllScamsByIP(){return r(this,void 0,void 0,function*(){return this.getOrFetch("all-scams-by-ip",()=>new Promise((e,n)=>{fetch(`${t.API_ENDPOINT}/ips`).then(e=>e.json()).then(e).catch(n)}))})}getOrFetch(e,t){return r(this,void 0,void 0,function*(){if(this.cacheEnabled&&(yield this.cacheProvider.has(e))&&(new Date).getTime()-(yield this.cacheProvider.getTimestamp(e))<this.cacheDuration){const t=yield this.cacheProvider.get(e);if(t)return t}const n=yield t();return this.cacheEnabled&&(yield this.cacheProvider.set(e,n)),n})}}},function(e,t){e.exports=require("isomorphic-fetch")},function(e,t,n){"use strict";var r=function(e,t,n,r){return new(n||(n=Promise))(function(c,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function u(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){e.done?c(e.value):new n(function(t){t(e.value)}).then(o,u)}a((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0});t.MemoryCacheProvider=class{constructor(){this.cache={}}get(e){return r(this,void 0,void 0,function*(){return this.cache[e].value})}getTimestamp(e){return r(this,void 0,void 0,function*(){return this.cache[e].timestamp})}set(e,t){return r(this,void 0,void 0,function*(){return this.cache[e]={timestamp:(new Date).getTime(),value:t},!0})}has(e){return r(this,void 0,void 0,function*(){return!!this.cache[e]})}remove(e){return r(this,void 0,void 0,function*(){return delete this.cache[e],!0})}}}]);
module.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var c=t[r]={i:r,l:!1,exports:{}};return e[r].call(c.exports,c,c.exports,n),c.l=!0,c.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var c in e)n.d(r,c,function(t){return e[t]}.bind(null,c));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";var r=function(e,t,n,r){return new(n||(n=Promise))(function(c,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function u(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){e.done?c(e.value):new n(function(t){t(e.value)}).then(o,u)}a((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),n(1);const c=n(2);t.API_ENDPOINT="https://cryptoscamdb.org/api/v1";t.default=class{constructor(e={cache:{enabled:!1}}){this.cacheEnabled=!1,e.cache&&e.cache.enabled&&(this.cacheEnabled=!0,this.cacheProvider=e.cache.cacheProvider||new c.MemoryCacheProvider,this.cacheDuration=e.cache.cacheDuration||6e5)}check(e){return r(this,void 0,void 0,function*(){return this.getOrFetch(`check-${e}`,()=>new Promise((n,r)=>{fetch(`${t.API_ENDPOINT}/check/${e}`).then(e=>e.json()).then(n).catch(r)}))})}getAllScams(){return r(this,void 0,void 0,function*(){return this.getOrFetch("all-scams",()=>new Promise((e,n)=>{fetch(`${t.API_ENDPOINT}/scams`).then(e=>e.json()).then(e).catch(n)}))})}getAllScamsByAddress(){return r(this,void 0,void 0,function*(){return this.getOrFetch("all-scams-by-address",()=>new Promise((e,n)=>{fetch(`${t.API_ENDPOINT}/addresses`).then(e=>e.json()).then(e).catch(n)}))})}getAllScamsByIP(){return r(this,void 0,void 0,function*(){return this.getOrFetch("all-scams-by-ip",()=>new Promise((e,n)=>{fetch(`${t.API_ENDPOINT}/ips`).then(e=>e.json()).then(e).catch(n)}))})}getOrFetch(e,t){return r(this,void 0,void 0,function*(){if(this.cacheEnabled&&(yield this.cacheProvider.has(e))&&(new Date).getTime()-(yield this.cacheProvider.getTimestamp(e))<this.cacheDuration){const t=yield this.cacheProvider.get(e);if(t)return t}const n=yield t();return this.cacheEnabled&&(yield this.cacheProvider.set(e,n)),n})}}},function(e,t){e.exports=require("isomorphic-fetch")},function(e,t,n){"use strict";var r=function(e,t,n,r){return new(n||(n=Promise))(function(c,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function u(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){e.done?c(e.value):new n(function(t){t(e.value)}).then(o,u)}a((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0});t.MemoryCacheProvider=class{constructor(){this.cache={}}get(e){return r(this,void 0,void 0,function*(){return this.cache[e].value})}getTimestamp(e){return r(this,void 0,void 0,function*(){return this.cache[e].timestamp})}set(e,t){return r(this,void 0,void 0,function*(){return this.cache[e]={timestamp:(new Date).getTime(),value:t},!0})}has(e){return r(this,void 0,void 0,function*(){return!!this.cache[e]})}remove(e){return r(this,void 0,void 0,function*(){return delete this.cache[e],!0})}}}]).default;
//# sourceMappingURL=api.node.js.map
{
"name": "@cryptoscamdb/api",
"version": "1.0.0",
"version": "1.1.1",
"description": "A Javascript wrapper for the CryptoScamDB API",

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

@@ -44,2 +44,4 @@ # API

### Node.js
```typescript

@@ -64,1 +66,16 @@ import CryptoScamDBAPI from '@cryptoscamdb/api';

```
### Browser
```typescript
// API is available as `window.csdbapi`
const api = new window.csdbapi();
// Equal to https://cryptoscamdb.org/api/check/example.com
api.check('example.com')
.then(result => {
// Do something with the result
console.log(result.entries);
})
// Handle error
.catch(console.error);
```
import 'isomorphic-fetch';
import { CacheProvider, MemoryCacheProvider } from './cache';
export const API_ENDPOINT = 'https://cryptoscamdb.org/api';
export const API_ENDPOINT = 'https://cryptoscamdb.org/api/v1';

@@ -6,0 +6,0 @@ export interface Options {

import 'isomorphic-fetch';
import { CacheProvider } from './cache';
export declare const API_ENDPOINT = "https://cryptoscamdb.org/api";
export declare const API_ENDPOINT = "https://cryptoscamdb.org/api/v1";
export interface Options {

@@ -5,0 +5,0 @@ cache?: {

@@ -16,3 +16,4 @@ import * as path from 'path';

path: path.resolve(__dirname, 'lib'),
library: 'api'
library: 'csdbapi',
libraryExport: 'default'
},

@@ -19,0 +20,0 @@ resolve: {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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