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

twitter-lite

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

twitter-lite - npm Package Compare versions

Comparing version 0.1.3 to 0.2.0

LICENSE

2

dist/twitter.js

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

var e=require("crypto"),t=require("oauth-1.0a"),n=require("sub-in"),r=require("cross-fetch"),s={subdomain:"api",consumer_key:null,consumer_secret:null,access_token_key:null,access_token_secret:null},i={"Content-Type":"application/json",Accept:"application/json"},o=function(r){var i,o=Object.assign({},s,r);this.client=t({consumer:{key:(i={key:o.consumer_key,secret:o.consumer_secret}).key,secret:i.secret},signature_method:"HMAC-SHA1",hash_function:function(t,n){return e.createHmac("sha1",n).update(t).digest("base64")}}),this.token={key:o.access_token_key,secret:o.access_token_secret},this.url=n("https://$0.twitter.com/1.1",[o.subdomain])};o.prototype.get=function(e){return new Promise(function(t,n){var s,i;return i=this.client.toHeader(this.client.authorize(s={url:this.url+"/"+e+".json",method:"GET"},this.token)),r(s.url,{headers:i}).then(function(e){return e.json()}).then(function(e){try{return t(e)}catch(e){return n(e)}}.bind(this),n)}.bind(this))},o.prototype.post=function(e,t){return new Promise(function(n,s){var o,c;return c=this.client.toHeader(this.client.authorize(o={url:this.url+"/"+e+".json",method:"POST"},this.token)),r(o.url,{method:"POST",headers:Object.assign({},i,c),body:JSON.stringify(t)}).then(function(e){return e.json()}).then(function(e){try{return n(e)}catch(e){return s(e)}}.bind(this),s)}.bind(this))},module.exports=o;
var e=require("crypto"),t=require("oauth-1.0a"),n=require("sub-in"),r=require("cross-fetch"),s={subdomain:"api",consumer_key:null,consumer_secret:null,access_token_key:null,access_token_secret:null,bearer_token:null},i={"Content-Type":"application/json",Accept:"application/json"},o=function(r){var i,o=Object.assign({},s,r);this.authType=o.bearer_token?"App":"User",this.client=t({consumer:{key:(i={key:o.consumer_key,secret:o.consumer_secret}).key,secret:i.secret},signature_method:"HMAC-SHA1",hash_function:function(t,n){return e.createHmac("sha1",n).update(t).digest("base64")}}),this.token={key:o.access_token_key,secret:o.access_token_secret},this.url=n("https://$0.twitter.com/1.1",[o.subdomain]),this.config=o};o.prototype.get=function(e){return new Promise(function(t,n){var s,i;return s={url:this.url+"/"+e+".json",method:"GET"},i={},i="User"===this.authType?this.client.toHeader(this.client.authorize(s,this.token)):{Authorization:"Bearer "+this.config.bearer_token},r(s.url,{headers:i}).then(function(e){return e.json()}).then(function(e){try{return t(e)}catch(e){return n(e)}}.bind(this),n)}.bind(this))},o.prototype.post=function(e,t){return new Promise(function(n,s){var o,u;return o={url:this.url+"/"+e+".json",method:"POST"},u={},u="User"===this.authType?this.client.toHeader(this.client.authorize(o,this.token)):{Authorization:"Bearer "+this.config.bearer_token},r(o.url,{method:"POST",headers:Object.assign({},i,u),body:JSON.stringify(t)}).then(function(e){return e.json()}).then(function(e){try{return n(e)}catch(e){return s(e)}}.bind(this),s)}.bind(this))},module.exports=o;
//# sourceMappingURL=twitter.js.map

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

var e=require("crypto"),t=require("oauth-1.0a"),n=require("sub-in"),r=require("cross-fetch"),s={subdomain:"api",consumer_key:null,consumer_secret:null,access_token_key:null,access_token_secret:null},i={"Content-Type":"application/json",Accept:"application/json"},o=function(r){var i,o=Object.assign({},s,r);this.client=t({consumer:{key:(i={key:o.consumer_key,secret:o.consumer_secret}).key,secret:i.secret},signature_method:"HMAC-SHA1",hash_function:function(t,n){return e.createHmac("sha1",n).update(t).digest("base64")}}),this.token={key:o.access_token_key,secret:o.access_token_secret},this.url=n("https://$0.twitter.com/1.1",[o.subdomain])};o.prototype.get=function(e){return new Promise(function(t,n){var s,i;return i=this.client.toHeader(this.client.authorize(s={url:this.url+"/"+e+".json",method:"GET"},this.token)),r(s.url,{headers:i}).then(function(e){return e.json()}).then(function(e){try{return t(e)}catch(e){return n(e)}}.bind(this),n)}.bind(this))},o.prototype.post=function(e,t){return new Promise(function(n,s){var o,c;return c=this.client.toHeader(this.client.authorize(o={url:this.url+"/"+e+".json",method:"POST"},this.token)),r(o.url,{method:"POST",headers:Object.assign({},i,c),body:JSON.stringify(t)}).then(function(e){return e.json()}).then(function(e){try{return n(e)}catch(e){return s(e)}}.bind(this),s)}.bind(this))},module.exports=o;
var e=require("crypto"),t=require("oauth-1.0a"),n=require("sub-in"),r=require("cross-fetch"),s={subdomain:"api",consumer_key:null,consumer_secret:null,access_token_key:null,access_token_secret:null,bearer_token:null},i={"Content-Type":"application/json",Accept:"application/json"},o=function(r){var i,o=Object.assign({},s,r);this.authType=o.bearer_token?"App":"User",this.client=t({consumer:{key:(i={key:o.consumer_key,secret:o.consumer_secret}).key,secret:i.secret},signature_method:"HMAC-SHA1",hash_function:function(t,n){return e.createHmac("sha1",n).update(t).digest("base64")}}),this.token={key:o.access_token_key,secret:o.access_token_secret},this.url=n("https://$0.twitter.com/1.1",[o.subdomain]),this.config=o};o.prototype.get=function(e){return new Promise(function(t,n){var s,i;return s={url:this.url+"/"+e+".json",method:"GET"},i={},i="User"===this.authType?this.client.toHeader(this.client.authorize(s,this.token)):{Authorization:"Bearer "+this.config.bearer_token},r(s.url,{headers:i}).then(function(e){return e.json()}).then(function(e){try{return t(e)}catch(e){return n(e)}}.bind(this),n)}.bind(this))},o.prototype.post=function(e,t){return new Promise(function(n,s){var o,u;return o={url:this.url+"/"+e+".json",method:"POST"},u={},u="User"===this.authType?this.client.toHeader(this.client.authorize(o,this.token)):{Authorization:"Bearer "+this.config.bearer_token},r(o.url,{method:"POST",headers:Object.assign({},i,u),body:JSON.stringify(t)}).then(function(e){return e.json()}).then(function(e){try{return n(e)}catch(e){return s(e)}}.bind(this),s)}.bind(this))},module.exports=o;
//# sourceMappingURL=twitter.m.js.map

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(0,function(){var e=require("crypto"),t=require("oauth-1.0a"),n=require("sub-in"),r=require("cross-fetch"),i={subdomain:"api",consumer_key:null,consumer_secret:null,access_token_key:null,access_token_secret:null},o={"Content-Type":"application/json",Accept:"application/json"},s=function(r){var o,s=Object.assign({},i,r);this.client=t({consumer:{key:(o={key:s.consumer_key,secret:s.consumer_secret}).key,secret:o.secret},signature_method:"HMAC-SHA1",hash_function:function(t,n){return e.createHmac("sha1",n).update(t).digest("base64")}}),this.token={key:s.access_token_key,secret:s.access_token_secret},this.url=n("https://$0.twitter.com/1.1",[s.subdomain])};s.prototype.get=function(e){return new Promise(function(t,n){var i,o;return o=this.client.toHeader(this.client.authorize(i={url:this.url+"/"+e+".json",method:"GET"},this.token)),r(i.url,{headers:o}).then(function(e){return e.json()}).then(function(e){try{return t(e)}catch(e){return n(e)}}.bind(this),n)}.bind(this))},s.prototype.post=function(e,t){return new Promise(function(n,i){var s,c;return c=this.client.toHeader(this.client.authorize(s={url:this.url+"/"+e+".json",method:"POST"},this.token)),r(s.url,{method:"POST",headers:Object.assign({},o,c),body:JSON.stringify(t)}).then(function(e){return e.json()}).then(function(e){try{return n(e)}catch(e){return i(e)}}.bind(this),i)}.bind(this))},module.exports=s});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(0,function(){var e=require("crypto"),t=require("oauth-1.0a"),n=require("sub-in"),r=require("cross-fetch"),i={subdomain:"api",consumer_key:null,consumer_secret:null,access_token_key:null,access_token_secret:null,bearer_token:null},o={"Content-Type":"application/json",Accept:"application/json"},s=function(r){var o,s=Object.assign({},i,r);this.authType=s.bearer_token?"App":"User",this.client=t({consumer:{key:(o={key:s.consumer_key,secret:s.consumer_secret}).key,secret:o.secret},signature_method:"HMAC-SHA1",hash_function:function(t,n){return e.createHmac("sha1",n).update(t).digest("base64")}}),this.token={key:s.access_token_key,secret:s.access_token_secret},this.url=n("https://$0.twitter.com/1.1",[s.subdomain]),this.config=s};s.prototype.get=function(e){return new Promise(function(t,n){var i,o;return i={url:this.url+"/"+e+".json",method:"GET"},o={},o="User"===this.authType?this.client.toHeader(this.client.authorize(i,this.token)):{Authorization:"Bearer "+this.config.bearer_token},r(i.url,{headers:o}).then(function(e){return e.json()}).then(function(e){try{return t(e)}catch(e){return n(e)}}.bind(this),n)}.bind(this))},s.prototype.post=function(e,t){return new Promise(function(n,i){var s,u;return s={url:this.url+"/"+e+".json",method:"POST"},u={},u="User"===this.authType?this.client.toHeader(this.client.authorize(s,this.token)):{Authorization:"Bearer "+this.config.bearer_token},r(s.url,{method:"POST",headers:Object.assign({},o,u),body:JSON.stringify(t)}).then(function(e){return e.json()}).then(function(e){try{return n(e)}catch(e){return i(e)}}.bind(this),i)}.bind(this))},module.exports=s});
//# sourceMappingURL=twitter.umd.js.map
{
"name": "twitter-lite",
"version": "0.1.3",
"version": "0.2.0",
"description": "A tiny, full-featured client / server library for the Twitter API",

@@ -5,0 +5,0 @@ "source": "twitter.js",

# Twitter Lite [![npm](https://img.shields.io/npm/v/twitter-lite.svg)](https://npm.im/twitter-lite) [![travis](https://travis-ci.org/preposterous/twitter-lite.svg?branch=master)](https://travis-ci.org/preposterous/twitter-lite)
A lightweight, fully-featured, client & server library for the Twitter API
A tiny (591B), fully-featured, client & server library for the Twitter API

@@ -83,2 +83,20 @@ - Promise-first via Async / Await

## Troubleshooting
### API Errors
Api errors are returned (with "catch" in the Promise api or with "err" param in the callback api) as an array of errors.
Thus errors described in twitter docs for example as:
```JSON
{ "errors": [ { "code": 88, "message": "Rate limit exceeded" } ] }
```
Would return as :
```
[ { "code": 88, "message": "Rate limit exceeded" } ]
```
## Credit

@@ -85,0 +103,0 @@

@@ -27,3 +27,4 @@ const crypto = require("crypto");

access_token_key: null,
access_token_secret: null
access_token_secret: null,
bearer_token: null
};

@@ -39,2 +40,3 @@

const config = Object.assign({}, defaults, options);
this.authType = config.bearer_token ? "App" : "User";
this.client = createOauthClient({

@@ -51,2 +53,3 @@ key: config.consumer_key,

this.url = getUrl(config.subdomain);
this.config = config;
}

@@ -60,5 +63,12 @@

const headers = this.client.toHeader(
this.client.authorize(requestData, this.token)
);
let headers = {};
if (this.authType === "User") {
headers = this.client.toHeader(
this.client.authorize(requestData, this.token)
);
} else {
headers = {
Authorization: `Bearer ${this.config.bearer_token}`
};
}

@@ -76,6 +86,14 @@ const results = await Fetch(requestData.url, { headers }).then(res =>

};
const headers = this.client.toHeader(
this.client.authorize(requestData, this.token)
);
let headers = {};
if (this.authType === "User") {
headers = this.client.toHeader(
this.client.authorize(requestData, this.token)
);
} else {
headers = {
Authorization: `Bearer ${this.config.bearer_token}`
};
}
const results = await Fetch(requestData.url, {

@@ -82,0 +100,0 @@ method: "POST",

Sorry, the diff of this file is not supported yet

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