New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

oa2

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oa2 - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

.babelrc

35

package.json
{
"name": "oa2",
"version": "0.0.1",
"version": "0.1.0",
"description": "OAuth 1/2 made simple",
"main": "lib/index.js",
"main": "lib/oauth",
"scripts": {
"build": "rm -rf ./lib && babel src -d lib --ignore *.test.js",
"coverage": "jest --coverage",
"codacy": "npm run coverage && cat ./coverage/lcov.info | codacy-coverage && rm -rf ./coverage",
"lint": "eslint --fix src",
"prepublish": "npm run build",
"test": "jest"

@@ -24,3 +29,27 @@ },

},
"homepage": "https://github.com/SzybkiSasza/oa2#readme"
"homepage": "https://github.com/SzybkiSasza/oa2#readme",
"dependencies": {
"ajv": "^5.2.0",
"axios": "^0.16.2",
"babel-runtime": "^6.23.0",
"debug": "^2.6.8",
"lodash": "^4.17.4"
},
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-eslint": "^7.2.3",
"babel-jest": "^20.0.3",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.5.2",
"codacy-coverage": "^2.0.2",
"eslint": "^4.1.1",
"eslint-config-google": "^0.8.0",
"jest": "^20.0.4"
},
"jest": {
"testPathIgnorePatterns": [
"node_modules",
"lib"
]
}
}

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

# oa2
OAuth 1/2 made simple
# OA2 - OAuth made simple
**PLEASE NOTE - until the 1.0.0 release, the library is not fully working!!! Please relate to GitHub to see the progress**
Simple OAuth library supporting common OAuth scenarios and popular OAuth providers, with understandable API and fully supporting promises.
This library was created as an attempt to modernize existing popular OAuth libraries and simplify their config. What's more, support for retry scenarios (network failure, server reject) was added to make OAuth calls more resilient to failure.
## OAuth support
The library will support OAuth 1.0 and OAuth 2.0 in the final version
## Configuration
Library is initialized with the config specific for the particular OAuth version.
After initialization, second part of the config (call-specific, e.g. client credentials) should be passed with each call.
For the details, please refer to each OAuth version section.
### Backoff
Each OAuth call is wrapped in backoff code, to prevent any timeouts or server restrictions from affecting the client. By default, calls default backoff config. However, backoff can be adjusted to a specific needs by providing `backoff` key in module config (next to other, version-specific keys) as follows:
```javascript
const config = {
accessTokenURL: 'https://oauth-something.com/at',
// (...) rest of the config
backoff: {
retries: 5, // **DEFAULT: 10** Number of retries before throwing an error
factor: 2 // ** DEFAULT: 2** Exponential backoff factor
minTimeout: 300 // **DEFAULT: 1000** Minimum time before the next retry
maxTimeout: 5000 // **DEFAULT: 10000** Maximum time before the next retry, has to be bigger than minimum
randomize: // **DEFAULT: true** flag depicting whether next backoff time should be randomized or strictly follow exponential curve
}
}
```
For more details about this config, please refer to the README of the library used for managing the backoff: https://github.com/tim-kos/node-retry
## OAuth 1.0
OAuth 1.0 module fully supports one, two and three-legged authorization. For now, only `HMAC-SHA1` signatures are supported.
*Please create feature request, if any other signatures are needed*
### Configuration
Basic module configuration includes only two URLs. Config structure for the OAuth 1.0 is presented below:
```javascript
const config = {
accessTokenURL: 'https://oauth-service/at', // **REQUIRED**. URL used for obtaining access tokens.
authURL: 'https://oauth-service/auth', // URL used in three-legged auth - redirectURL
requestTokenURL: 'https://oauth-service/rt', // URL used in two and three-legged auth for obtaining request tokens
signatureMethod: 'HMAC-SHA1', // **DEFAULT: 'HMAC-SHA1'**. Signature method used.
version: '1.0' // **DEFAULT: '1.0'**. Protocol version.
}
```
### Usage
## OAuth 2.0
OAuth 2.0 module supports both refreshable (ones having `refresh_token`) and simple services.
### Configuration
Basic configuration is a bit more complicated than for the OAuth 1.0. Apart from the URLs, information about the scope is required.
The scope is a set of permissions the app will have. For the details, please refer to a particular OAuth provider documentation.
```javascript
const config = {
authURL: 'https://oauth-service/auth', // **REQUIRED** URL used in three-legged auth - redirectURL
tokenURL: 'https://oauth-service/token', // **REQUIRED** URL used to obtain tokens (access, refresh)
isrefreshable: true, // **DEFAULT: false** Flag depicting whether the OAuth client should be able to refresh tokens
responseType: 'code', // **DEFAULT: 'code'** Response type for the auth call, usually set to 'code'
scope: ['all'], // **REQUIRED** List of scopes to auth against
custom: { // Custom properties to be attached to every OAuth 2.0 request
my: 'property'
}
}
```
### Usage
## Tests
Tests are run using `jest` framework. To run the tests, type in the CLI:
`npm t`

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