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.1 to 0.1.3

2

dist/twitter.js

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

var e=require("crypto"),t=require("oauth-1.0a"),n=require("sub-in"),r=require("node-fetch"),s={subdomain:"api",consumer_key:null,consumer_secret:null,access_token_key:null,access_token_secret:null},i=function(r){var i,u=Object.assign({},s,r);this.client=t({consumer:{key:(i={key:u.consumer_key,secret:u.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:u.access_token_key,secret:u.access_token_secret},this.url=n("https://$0.twitter.com/1.1",[u.subdomain])};i.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))},i.prototype.post=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:"POST"},this.token)),r(s.url,{method:"POST",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))},module.exports=i;
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;
//# sourceMappingURL=twitter.js.map

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

var e=require("crypto"),t=require("oauth-1.0a"),n=require("sub-in"),r=require("node-fetch"),s={subdomain:"api",consumer_key:null,consumer_secret:null,access_token_key:null,access_token_secret:null},i=function(r){var i,u=Object.assign({},s,r);this.client=t({consumer:{key:(i={key:u.consumer_key,secret:u.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:u.access_token_key,secret:u.access_token_secret},this.url=n("https://$0.twitter.com/1.1",[u.subdomain])};i.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))},i.prototype.post=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:"POST"},this.token)),r(s.url,{method:"POST",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))},module.exports=i;
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;
//# 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("node-fetch"),o={subdomain:"api",consumer_key:null,consumer_secret:null,access_token_key:null,access_token_secret:null},i=function(r){var i,s=Object.assign({},o,r);this.client=t({consumer:{key:(i={key:s.consumer_key,secret:s.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:s.access_token_key,secret:s.access_token_secret},this.url=n("https://$0.twitter.com/1.1",[s.subdomain])};i.prototype.get=function(e){return new Promise(function(t,n){var o,i;return i=this.client.toHeader(this.client.authorize(o={url:this.url+"/"+e+".json",method:"GET"},this.token)),r(o.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))},i.prototype.post=function(e){return new Promise(function(t,n){var o,i;return i=this.client.toHeader(this.client.authorize(o={url:this.url+"/"+e+".json",method:"POST"},this.token)),r(o.url,{method:"POST",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))},module.exports=i});
!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});
//# sourceMappingURL=twitter.umd.js.map
{
"name": "twitter-lite",
"version": "0.1.1",
"version": "0.1.3",
"description": "A tiny, full-featured client / server library for the Twitter API",

@@ -27,3 +27,3 @@ "source": "twitter.js",

"dependencies": {
"node-fetch": "^2.0.0",
"cross-fetch": "^1.1.1",
"oauth-1.0a": "^2.2.4",

@@ -30,0 +30,0 @@ "sub-in": "^1.0.2"

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

# Twitter Lite
# 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)

@@ -21,3 +21,32 @@ A lightweight, fully-featured, client & server library for the Twitter API

- Create an app on [https://apps.twitter.com/](https://apps.twitter.com)
- Grab the Consumer Key (API Key) and Consumer Secret (API Secret) from Keys and Access Tokens
- Make sure you set the right access level for your app
### App vs. User
Twitter has two different authentication options:
- App: higher rate limits. Great for building your own Twitter App
- User: lower rate limits. Great for making requests on behalf of a User.
**User** authentication requires:
- `consumer_key`
- `consumer_secret`
- `access_token_key`
- `access_token_secret`
**App** authentication requires:
- `bearer_token`
App authentication is a simple header behind the scenes:
```es6
headers: {
Authorization: `Bearer ${bearer_token}`
}
```
### Verifying Credentials Example (User auth)
```es6
const client = new Twitter({

@@ -31,7 +60,20 @@ subdomain: "api",

client.get("account/verify_credentials").then(results => {
console.log("results", results)
}).catch(console.error)
client.get("account/verify_credentials")
.then(results => { console.log("results", results) })
.catch(console.error)
```
### App authentication Example
```es6
const client = new Twitter({
subdomain: "api",
bearer_token: "Bearer ABC123XYZ" // generate a Bearer token
})
client.get("users/lookup")
.then(results => { console.log("results", results ) })
.catch(console.error)
```
## Streams

@@ -38,0 +80,0 @@

const crypto = require("crypto");
const OAuth = require("oauth-1.0a");
const SubIn = require("sub-in");
const Fetch = require("node-fetch");
const Fetch = require("cross-fetch");

@@ -30,2 +30,7 @@ const getUrl = subdomain => SubIn("https://$0.twitter.com/1.1", [subdomain]);

const baseHeaders = {
"Content-Type": "application/json",
Accept: "application/json"
};
class Twitter {

@@ -63,3 +68,3 @@ constructor(options) {

async post(resource) {
async post(resource, body) {
const requestData = {

@@ -75,3 +80,4 @@ url: `${this.url}/${resource}.json`,

method: "POST",
headers
headers: Object.assign({}, baseHeaders, headers),
body: JSON.stringify(body)
}).then(res => res.json());

@@ -78,0 +84,0 @@ return results;

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