Comparing version 0.0.1 to 0.1.0
{ | ||
"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" | ||
] | ||
} | ||
} |
100
README.md
@@ -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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
125763
15
181
99
5
9
+ Addedajv@^5.2.0
+ Addedaxios@^0.16.2
+ Addedbabel-runtime@^6.23.0
+ Addeddebug@^2.6.8
+ Addedlodash@^4.17.4
+ Addedajv@5.5.2(transitive)
+ Addedaxios@0.16.2(transitive)
+ Addedbabel-runtime@6.26.0(transitive)
+ Addedco@4.6.0(transitive)
+ Addedcore-js@2.6.12(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addedfast-deep-equal@1.1.0(transitive)
+ Addedfast-json-stable-stringify@2.1.0(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedjson-schema-traverse@0.3.1(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedms@2.0.0(transitive)
+ Addedregenerator-runtime@0.11.1(transitive)