Socket
Socket
Sign inDemoInstall

client-oauth2

Package Overview
Dependencies
Maintainers
2
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

client-oauth2 - npm Package Compare versions

Comparing version 2.2.0 to 3.0.0

src/client-oauth2.js

41

package.json
{
"name": "client-oauth2",
"version": "2.2.0",
"version": "3.0.0",
"description": "Straight-forward execution of OAuth 2.0 flows and authenticated API requests",
"main": "client-oauth2.js",
"main": "src/client-oauth2.js",
"files": [
"client-oauth2.js",
"src/",
"LICENSE"
],
"browser": {
"buffer": false
"buffer": false,
"./src/request/index.js": "./src/request/browser.js"
},
"scripts": {
"lint": "standard",
"test-browser": "karma start --single-run",
"test-node": "mocha -R spec --bail --require test/support/globals.js",
"test": "npm run lint && npm run test-node && npm run test-browser"
"test-server-open": "PORT=7357 node test/support/server.js & echo $! > server.pid",
"test-server-close": "if [ -f server.pid ]; then kill -9 $(cat server.pid); rm server.pid; fi",
"test-browser": "PORT=7357 karma start --single-run",
"test-node": "PORT=7357 mocha -R spec --bail --require test/support/globals.js",
"test": "npm run lint && npm run test-server-open && npm run test-node && npm run test-browser; npm run test-server-close"
},

@@ -35,26 +38,28 @@ "repository": {

"devDependencies": {
"browserify": "^12.0.2",
"body-parser": "^1.15.2",
"browserify": "^13.1.0",
"chai": "^3.2.0",
"cors": "^2.8.1",
"envify": "^3.4.1",
"es6-promise": "^3.1.2",
"express": "^4.14.0",
"is-travis": "^1.0.0",
"karma": "^0.13.3",
"karma": "^1.3.0",
"karma-browserify": "^5.0.2",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^0.2.0",
"karma-cli": "^0.1.0",
"karma-coverage": "^0.5.3",
"karma-firefox-launcher": "^0.1.3",
"karma-mocha": "^0.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-coverage": "^1.1.1",
"karma-firefox-launcher": "^1.0.0",
"karma-mocha": "^1.1.1",
"karma-phantomjs-launcher": "^1.0.0",
"mocha": "^2.0.1",
"mocha": "^3.0.2",
"phantomjs": "^2.1.3",
"phantomjs-prebuilt": "^2.1.4",
"standard": "^6.0.7",
"standard": "^8.1.0",
"watchify": "^3.7.0"
},
"dependencies": {
"object.omit": "^2.0.0",
"popsicle": "^5.0.0",
"xtend": "^4.0.1"
}
}

@@ -7,3 +7,3 @@ # Client OAuth 2.0

> Straight-forward execution of OAuth 2.0 flows and authenticated API requests.
> Straight-forward execution of OAuth 2.0 flows and authenticated API requests. 7.58 kB in browsers, after minification and gzipping, 75% from `url` and `querystring` dependencies.

@@ -34,2 +34,6 @@ ## Installation

**P.S.** The second argument to the constructor can inject a custom request function, and the third argument can inject a custom `Promise` implementation.
### Options (global and method-based)
* **clientId** The client id string assigned to you by the provider

@@ -41,4 +45,5 @@ * **clientSecret** The client secret string assigned to you by the provider (not required for `token`)

* **scopes** An array of scopes to authenticate against
* **state** Nonce sent back with the redirect when authorization is complete to verify authenticity (should be random for every request)
**Request options**
### Request options

@@ -48,3 +53,3 @@ * **body** An object to merge with the body of every request

* **headers** An object to merge with the headers of every request
* **options** Transport options from [popsicle](https://github.com/blakeembrey/popsicle#handling-requests)
* **transport** Change certain request transport behaviour (currently `rejectUnauthorized` and `agent`)

@@ -54,3 +59,4 @@ To re-create an access token instance and make requests on behalf on the user, you can create an access token instance by using the `createToken` method on a client instance.

```javascript
var token = githubAuth.createToken('access token', 'optional refresh token', 'optional token type', { optional: 'raw user data' })
// Can also just pass the raw `data` object in place of an argument.
var token = githubAuth.createToken('access token', 'optional refresh token', 'optional token type', { data: 'raw user data' })

@@ -60,13 +66,9 @@ // Refresh the users credentials and save the updated access token.

token.request({
// Sign a standard HTTP request object, updating URL with token or authorization headers.
token.sign({
method: 'get',
url: 'https://api.github.com/users'
})
.then(function (res) {
console.log(res) //=> { body: '...', status: 200, headers: { ... } }
})
}) //=> { method, url, headers, ... }
```
You can override the request mechanism if you need a custom implementation by setting `githubAuth.request = function (opts) { return new Promise(...) }`. You will need to make sure that the custom request mechanism supports the correct input and output objects.
**P.S.** All authorization methods accept `options` as the last argument, useful for overriding the global configuration on a per-request basis.

@@ -78,4 +80,4 @@

1. Redirect user to `githubAuth.code.getUri()`.
2. Parse response uri and get token using `githubAuth.code.getToken(uri)`.
1. Redirect user to `githubAuth.code.getUri([ options ])`.
2. Parse response uri and get token using `githubAuth.code.getToken(uri [, options ])`.

@@ -99,3 +101,4 @@ ```javascript

user.refresh().then(function (updatedUser) {
console.log(updatedUser === user) //=> true
console.log(updatedUser !== user) //=> true
console.log(updatedUser.accessToken)
})

@@ -119,4 +122,4 @@

1. Redirect user to `githubAuth.token.getUri()`.
2. Parse response uri for the access token using `githubAuth.token.getToken(uri)`.
1. Redirect user to `githubAuth.token.getUri([ options ])`.
2. Parse response uri for the access token using `githubAuth.token.getToken(uri [, options ])`.

@@ -147,3 +150,3 @@ ```javascript

1. Make a direct request for the access token on behalf of the user using `githubAuth.owner.getToken(username, password)`.
1. Make a direct request for the access token on behalf of the user using `githubAuth.owner.getToken(username, password [, options ])`.

@@ -161,3 +164,3 @@ ```javascript

1. Get the access token for the application by using `githubAuth.credentials.getToken()`.
1. Get the access token for the application by using `githubAuth.credentials.getToken([ options ])`.

@@ -175,2 +178,4 @@ ```javascript

1. Get the access token for the application by using `githubAuth.jwt.getToken(jwt [, options ])`.
```javascript

@@ -177,0 +182,0 @@ githubAuth.jwt.getToken('eyJhbGciOiJFUzI1NiJ9.eyJpc3Mi[...omitted for brevity...].J9l-ZhwP[...omitted for brevity...]')

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc