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

@nuxtjs/auth

Package Overview
Dependencies
Maintainers
5
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nuxtjs/auth - npm Package Compare versions

Comparing version 4.3.0 to 4.4.0

20

CHANGELOG.md

@@ -5,2 +5,22 @@ # Change Log

<a name="4.4.0"></a>
# [4.4.0](https://github.com/nuxt-community/auth-module/compare/v4.3.0...v4.4.0) (2018-05-18)
### Bug Fixes
* **storage:** use false value for unsetting token/user ([#160](https://github.com/nuxt-community/auth-module/issues/160)) ([0450b57](https://github.com/nuxt-community/auth-module/commit/0450b57)), closes [nuxt-community/auth-module#133](https://github.com/nuxt-community/auth-module/issues/133)
### Features
* **oauth2:** set axios token ([#175](https://github.com/nuxt-community/auth-module/issues/175)) ([6206803](https://github.com/nuxt-community/auth-module/commit/6206803))
### Reverts
* revert [#158](https://github.com/nuxt-community/auth-module/issues/158) due to conflicts ([2afe9ca](https://github.com/nuxt-community/auth-module/commit/2afe9ca))
<a name="4.3.0"></a>

@@ -7,0 +27,0 @@ # [4.3.0](https://github.com/nuxt-community/auth-module/compare/v4.2.1...v4.3.0) (2018-04-28)

14

lib/core/auth.js

@@ -30,7 +30,2 @@ import getProp from 'dotprop'

if (!routeOption(this.ctx.route, 'auth', false)) {
// Disable redirect on refresh / direct load of a page.
if (loggedIn && !this.ctx.from) {
return
}
this.redirect(loggedIn ? 'home' : 'logout')

@@ -154,5 +149,5 @@ }

if (!this.strategy.reset) {
this.setUser(null)
this.setToken(this.$state.strategy, null)
this.setRefreshToken(this.$state.strategy, null)
this.setUser(false)
this.setToken(this.$state.strategy, false)
this.setRefreshToken(this.$state.strategy, false)
return Promise.resolve()

@@ -275,4 +270,3 @@ }

}
if (!_endpoint.headers['Authorization'] && isSet(token)) {
if (!_endpoint.headers['Authorization'] && isSet(token) && token) {
_endpoint.headers['Authorization'] = token

@@ -279,0 +273,0 @@ }

@@ -159,2 +159,5 @@ import Vue from 'vue'

const value = localStorage.getItem(_key)
if (value === 'false') {
return false
}

@@ -199,5 +202,7 @@ return isJson ? JSON.parse(value) : value

const value = cookies[_key]
if (value === 'false') {
return false
}
return isJson ? JSON.parse(value) : value
}
}

@@ -35,3 +35,3 @@ export const isUnset = o => typeof o === 'undefined' || o === null

return Object.values(m.components).some(
component => component.options[key] === value
component => component.options && component.options[key] === value
)

@@ -38,0 +38,0 @@ } else {

@@ -36,3 +36,8 @@ const axios = require('axios')

formMiddleware(req, res, () => {
const { code } = req.body
const {
code,
redirect_uri: redirectUri = strategy.redirect_uri,
response_type: responseType = strategy.response_type,
grant_type: grantType = strategy.grant_type
} = req.body

@@ -50,2 +55,5 @@ if (!code) {

client_secret: clientSecret,
grant_type: grantType,
response_type: responseType,
redirect_uri: redirectUri,
code

@@ -52,0 +60,0 @@ },

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

const axios = require('axios')
const bodyParser = require('body-parser')
const { assignDefaults } = require('./_utils')
const { assignDefaults, addAuthorize } = require('./_utils')

@@ -18,63 +16,3 @@ module.exports = function laravelPassport (strategy) {

// Get client_secret, client_id and token_endpoint
const clientSecret = strategy.client_secret
const clientID = strategy.client_id
const tokenEndpoint = strategy.token_endpoint
// IMPORTANT: remove client_secret from generated bundle
delete strategy.client_secret
// Endpoint
const endpoint = `/_auth/oauth/${strategy._name}/authorize`
strategy.access_token_endpoint = endpoint
// Set response_type to code
strategy.response_type = 'code'
// Form parser
const formMiddleware = bodyParser.urlencoded()
// Register endpoint
this.options.serverMiddleware.unshift({
path: endpoint,
handler: (req, res, next) => {
if (req.method !== 'POST') {
return next()
}
formMiddleware(req, res, () => {
const {
code,
redirect_uri: redirectUri = strategy.redirect_uri,
response_type: responseType = strategy.response_type,
grant_type: grantType = strategy.grant_type
} = req.body
if (!code) {
return next()
}
axios
.request({
method: 'post',
url: tokenEndpoint,
data: {
client_id: clientID,
client_secret: clientSecret,
grant_type: grantType,
response_type: responseType,
redirect_uri: redirectUri,
code
},
headers: {
Accept: 'application/json'
}
})
.then(response => {
res.end(JSON.stringify(response.data))
})
.catch(error => next(error))
})
}
})
addAuthorize.call(this, strategy)
}

@@ -5,3 +5,4 @@ import { encodeQuery, parseQuery, randomString } from '../utilities'

token_type: 'Bearer',
response_type: 'token'
response_type: 'token',
tokenName: 'Authorization'
}

@@ -37,3 +38,7 @@

// Sync token
this.$auth.syncToken(this.name)
const token = this.$auth.syncToken(this.name)
// Set axios token
if (token) {
this._setToken(token)
}

@@ -48,2 +53,17 @@ // Handle callbacks on page load

_setToken (token) {
// Set Authorization token for all axios requests
this.$auth.ctx.app.$axios.setHeader(this.options.tokenName, token)
}
_clearToken () {
// Clear Authorization token for all axios requests
this.$auth.ctx.app.$axios.setHeader(this.options.tokenName, false)
}
async logout () {
this._clearToken()
return this.$auth.reset()
}
login () {

@@ -143,2 +163,5 @@ const opts = {

// Set axios token
this._setToken(token)
// Store refresh token

@@ -145,0 +168,0 @@ if (refreshToken && refreshToken.length) {

{
"name": "@nuxtjs/auth",
"version": "4.3.0",
"version": "4.4.0",
"description": "Authentication module for Nuxt.js",

@@ -56,9 +56,9 @@ "license": "MIT",

"babel-plugin-transform-decorators-legacy": "^1.3.4",
"body-parser": "^1.18.2",
"bootstrap-vue": "^2.0.0-rc.4",
"codecov": "^3.0.1",
"body-parser": "^1.18.3",
"bootstrap-vue": "^2.0.0-rc.10",
"codecov": "^3.0.2",
"cookie-parser": "^1.4.3",
"eslint": "^4.19.1",
"eslint-config-standard": "^11.0.0",
"eslint-plugin-import": "^2.10.0",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-jest": "^21.15.0",

@@ -72,8 +72,8 @@ "eslint-plugin-node": "^6.0.1",

"jest": "^22.4.3",
"jsdom": "^11.7.0",
"jsdom": "^11.10.0",
"nuxt-class-component": "^1.2.0",
"nuxt-edge": "^2.0.0-25377845.e2e124b",
"puppeteer": "^1.2.0",
"nuxt-edge": "^2.0.0-25440915.dcc92c6",
"puppeteer": "^1.4.0",
"standard-version": "latest"
}
}
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