├── .github └── FUNDING.yml ├── .gitignore ├── LICENSE ├── README.md ├── build ├── build.js └── ts-test.js ├── demos ├── 2.x │ ├── .env.production │ ├── .env.sample │ ├── babel.config.js │ ├── package.json │ ├── public │ │ ├── img │ │ │ └── logo-dark-text.png │ │ └── index.html │ ├── src │ │ ├── config │ │ │ ├── index.js │ │ │ └── plugins.js │ │ ├── http │ │ │ └── index.js │ │ ├── main.js │ │ ├── pages │ │ │ ├── Index.vue │ │ │ ├── admin │ │ │ │ ├── Index.vue │ │ │ │ └── Users.vue │ │ │ ├── auth │ │ │ │ ├── Login.vue │ │ │ │ ├── Register.vue │ │ │ │ └── Social.vue │ │ │ ├── error │ │ │ │ ├── 403.vue │ │ │ │ ├── 404.vue │ │ │ │ └── Index.vue │ │ │ ├── site │ │ │ │ ├── Home.vue │ │ │ │ └── Users.vue │ │ │ └── user │ │ │ │ ├── Account.vue │ │ │ │ ├── Index.vue │ │ │ │ ├── Logout.vue │ │ │ │ ├── Unimpersonate.vue │ │ │ │ └── Users.vue │ │ ├── router │ │ │ └── index.js │ │ └── store │ │ │ ├── auth.js │ │ │ └── index.js │ └── vue.config.js └── 3.x │ ├── .env │ ├── .gitignore │ ├── babel.config.js │ ├── package.json │ ├── public │ ├── favicon.ico │ ├── img │ │ └── logo-dark-text.png │ └── index.html │ ├── src │ ├── composables │ │ └── useAuthComp.js │ ├── elements │ │ └── Layout.vue │ ├── http │ │ └── index.js │ ├── main.js │ ├── pages │ │ ├── Index.vue │ │ ├── admin │ │ │ ├── Index.vue │ │ │ └── Users.vue │ │ ├── auth │ │ │ ├── Login.vue │ │ │ ├── Register.vue │ │ │ └── Social.vue │ │ ├── error │ │ │ ├── 403.vue │ │ │ ├── 404.vue │ │ │ └── Index.vue │ │ ├── site │ │ │ ├── Home.vue │ │ │ └── Users.vue │ │ └── user │ │ │ ├── Account.vue │ │ │ ├── Index.vue │ │ │ ├── Logout.vue │ │ │ ├── Unimpersonate.vue │ │ │ └── Users.vue │ ├── plugins │ │ └── auth.js │ ├── router │ │ └── index.js │ ├── store │ │ └── index.js │ └── styles │ │ └── nova.css │ └── vue.config.js ├── dist ├── drivers │ ├── auth │ │ ├── basic.common.js │ │ ├── basic.esm.js │ │ ├── basic.js │ │ ├── basic.min.js │ │ ├── bearer.common.js │ │ ├── bearer.esm.js │ │ ├── bearer.js │ │ ├── bearer.min.js │ │ ├── devise.common.js │ │ ├── devise.esm.js │ │ ├── devise.js │ │ └── devise.min.js │ ├── http │ │ ├── axios.1.x.common.js │ │ ├── axios.1.x.esm.js │ │ ├── axios.1.x.js │ │ ├── axios.1.x.min.js │ │ ├── frisbee.1.x.common.js │ │ ├── frisbee.1.x.esm.js │ │ ├── frisbee.1.x.js │ │ ├── frisbee.1.x.min.js │ │ ├── vue-resource.1.x.common.js │ │ ├── vue-resource.1.x.esm.js │ │ ├── vue-resource.1.x.js │ │ └── vue-resource.1.x.min.js │ ├── oauth2 │ │ ├── facebook.common.js │ │ ├── facebook.esm.js │ │ ├── facebook.js │ │ ├── facebook.min.js │ │ ├── google.common.js │ │ ├── google.esm.js │ │ ├── google.js │ │ └── google.min.js │ └── router │ │ ├── vue-router.2.x.common.js │ │ ├── vue-router.2.x.esm.js │ │ ├── vue-router.2.x.js │ │ └── vue-router.2.x.min.js ├── v2 │ ├── vue-auth.common.js │ ├── vue-auth.esm.js │ ├── vue-auth.js │ └── vue-auth.min.js └── v3 │ ├── vue-auth.common.js │ ├── vue-auth.esm.js │ ├── vue-auth.js │ └── vue-auth.min.js ├── package.json ├── src ├── auth.js ├── drivers │ ├── auth │ │ ├── basic.js │ │ ├── bearer.js │ │ └── devise.js │ ├── http │ │ ├── axios.1.x.js │ │ ├── frisbee.1.x.js │ │ └── vue-resource.1.x.js │ ├── oauth2 │ │ ├── auth0.js │ │ ├── facebook.js │ │ └── google.js │ └── router │ │ └── vue-router.2.x.js ├── lib │ ├── cookie.js │ ├── storage.js │ ├── token.js │ └── utils.js ├── v2.js └── v3.js └── types └── index.d.ts /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: websanova 2 | patreon: websanova -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .env.local 3 | .tmp 4 | package-lock.json -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2020 Websanova (https://websanova.com) 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Vue Auth 2 | 3 | A simple light-weight authentication library for Vue.js 4 | 5 | 6 | ## Sponsor 7 | 8 | If you like this plugin please consider sponsoring. 9 | 10 | * [GitHub](https://github.com/sponsors/websanova) 11 | * [Patreon](https://patreon.com/websanova) 12 | 13 | 14 | ## Demo 15 | 16 | Check the [live demo](https://vue-auth.websanova.com) to see vue-auth in action. 17 | 18 | 19 | ## Upgrade 20 | 21 | The new 4.x version comes with support for Vue 3 along with one small change with how the plugin is setup. Otherwise it is fully backwards compatible and no other changes will be required. 22 | 23 | * [2.x to 3.x Upgrade Guide](https://websanova.com/docs/vue-auth/upgrades/2x-3x). 24 | * [3.x to 4.x Upgrade Guide](https://websanova.com/docs/vue-auth/upgrades/3x-4x). 25 | 26 | 27 | ## Issues 28 | 29 | For any issues or errors with the plugin or docs: 30 | 31 | * [Get in touch on Reddit](https://reddit.com/r/websanova) 32 | * [Submit an issue on GitHub](https://github.com/websanova/vue-auth/issues) 33 | 34 | 35 | ## Resources 36 | 37 | * [Home](https://websanova.com/docs/vue-auth) 38 | * [Intro](https://websanova.com/docs/vue-auth/intro) 39 | * [Guides](https://websanova.com/docs/vue-auth/guides) 40 | * [Recipes](https://websanova.com/docs/vue-auth/recipes) 41 | * [Methods](https://websanova.com/docs/vue-auth/methods) 42 | * [Options](https://websanova.com/docs/vue-auth/options) 43 | * [Upgrades](https://websanova.com/docs/vue-auth/upgrades) 44 | * [Changes](https://websanova.com/docs/vue-auth/changes) 45 | 46 | 47 | ## License 48 | 49 | MIT licensed 50 | 51 | Copyright (C) 2011-2020 Websanova https://websanova.com 52 | -------------------------------------------------------------------------------- /build/build.js: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | 3 | const fs = require('fs'); 4 | const zlib = require('zlib'); 5 | const rollup = require('rollup'); 6 | const uglify = require('uglify-js'); 7 | const babel = require('rollup-plugin-babel'); 8 | const replace = require('rollup-plugin-replace'); 9 | const {name, version, homepage} = require('../package.json'); 10 | const banner = `/*!\n * ${name} v${version}\n * ${homepage}\n * Released under the MIT License.\n */\n`; 11 | 12 | // Dirs 13 | 14 | const dirs = [ 15 | 'dist', 16 | 'dist/drivers', 17 | 'dist/drivers/auth', 18 | 'dist/drivers/http', 19 | 'dist/drivers/oauth2', 20 | 'dist/drivers/router', 21 | 'dist/v2', 22 | 'dist/v3' 23 | ]; 24 | 25 | dirs.forEach((dir) => { 26 | if (!fs.existsSync(dir)){ 27 | fs.mkdirSync(dir); 28 | } 29 | }); 30 | 31 | // Files 32 | 33 | const files = [{ 34 | input: 'src/v2.js', 35 | name: 'v2/vue-auth', 36 | }, { 37 | input: 'src/v3.js', 38 | name: 'v3/vue-auth', 39 | }, { 40 | input: 'src/drivers/auth/basic.js', 41 | name: 'drivers/auth/basic' 42 | }, { 43 | input: 'src/drivers/auth/bearer.js', 44 | name: 'drivers/auth/bearer' 45 | }, { 46 | input: 'src/drivers/auth/devise.js', 47 | name: 'drivers/auth/devise' 48 | }, { 49 | input: 'src/drivers/http/axios.1.x.js', 50 | name: 'drivers/http/axios.1.x' 51 | }, { 52 | input: 'src/drivers/http/frisbee.1.x.js', 53 | name: 'drivers/http/frisbee.1.x' 54 | }, { 55 | input: 'src/drivers/http/vue-resource.1.x.js', 56 | name: 'drivers/http/vue-resource.1.x' 57 | }, { 58 | input: 'src/drivers/oauth2/auth0.js', 59 | name: 'drivers/oauth2/auth0' 60 | }, { 61 | input: 'src/drivers/oauth2/facebook.js', 62 | name: 'drivers/oauth2/facebook' 63 | }, { 64 | input: 'src/drivers/oauth2/google.js', 65 | name: 'drivers/oauth2/google' 66 | }, { 67 | input: 'src/drivers/router/vue-router.2.x.js', 68 | name: 'drivers/router/vue-router.2.x' 69 | }]; 70 | 71 | 72 | files.forEach((file) => { 73 | 74 | rollup.rollup({ 75 | input: file.input, 76 | plugins: [babel(), replace({__VERSION__: version})] 77 | }) 78 | .then(bundle => 79 | bundle.generate({ 80 | banner, 81 | format: 'umd', 82 | name: 'VueAuth' 83 | }).then(({code}) => write(`dist/${file.name}.js`, code, bundle)) 84 | ) 85 | .then(bundle => 86 | write(`dist/${file.name}.min.js`, banner + '\n' + 87 | uglify.minify(read(`dist/${file.name}.js`)).code, bundle, true) 88 | ) 89 | .then(bundle => 90 | bundle.generate({ 91 | banner, 92 | format: 'es', 93 | }).then(({code}) => write(`dist/${file.name}.esm.js`, code, bundle)) 94 | ) 95 | .then(bundle => 96 | bundle.generate({ 97 | banner, 98 | format: 'cjs' 99 | }).then(({code}) => write(`dist/${file.name}.common.js`, code, bundle)) 100 | ) 101 | .catch(logError); 102 | 103 | }); 104 | 105 | function read(path) { 106 | return fs.readFileSync(path, 'utf8'); 107 | } 108 | 109 | function write(dest, code, bundle, zip) { 110 | return new Promise((resolve, reject) => { 111 | fs.writeFile(dest, code, err => { 112 | if (err) return reject(err); 113 | 114 | if (zip) { 115 | zlib.gzip(code, (err, zipped) => { 116 | if (err) return reject(err); 117 | console.log(blue(dest) + ' ' + getSize(code) + ' (' + getSize(zipped) + ' gzipped)'); 118 | }); 119 | } else { 120 | console.log(blue(dest) + ' ' + getSize(code)); 121 | } 122 | 123 | resolve(bundle); 124 | }); 125 | }); 126 | } 127 | 128 | function getSize(code) { 129 | return (code.length / 1024).toFixed(2) + 'kb'; 130 | } 131 | 132 | function logError(e) { 133 | console.log(e); 134 | } 135 | 136 | function blue(str) { 137 | return '\x1b[1m\x1b[34m' + str + '\x1b[39m\x1b[22m'; 138 | } -------------------------------------------------------------------------------- /build/ts-test.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import VueAuth from '@websanova/vue-auth' 3 | 4 | Vue.use(VueAuth, {}); -------------------------------------------------------------------------------- /demos/2.x/.env.production: -------------------------------------------------------------------------------- 1 | NODE_ENV=production 2 | 3 | VUE_APP_API_URL=https://api-starter.websanova.com/v1 -------------------------------------------------------------------------------- /demos/2.x/.env.sample: -------------------------------------------------------------------------------- 1 | NODE_ENV=local 2 | 3 | VUE_APP_API_URL=https://api-starter.websanova.com/v1 -------------------------------------------------------------------------------- /demos/2.x/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/app' 4 | ] 5 | } -------------------------------------------------------------------------------- /demos/2.x/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-auth", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint" 9 | }, 10 | "dependencies": { 11 | "vue": "2.6.12", 12 | "vuex": "3.5.1", 13 | "axios": "0.20.0", 14 | "core-js": "3.6.5", 15 | "vue-axios": "2.1.5", 16 | "vue-router": "3.4.3", 17 | "vue-resource": "1.5.1" 18 | }, 19 | "devDependencies": { 20 | "@vue/cli-plugin-babel": "4.5.6", 21 | "@vue/cli-plugin-eslint": "4.5.6", 22 | "@vue/cli-service": "4.5.6", 23 | "babel-eslint": "10.1.0", 24 | "eslint": "7.9.0", 25 | "eslint-plugin-vue": "6.2.2", 26 | "vue-template-compiler": "2.6.12", 27 | "sass-loader": "10.0.2", 28 | "node-sass": "4.14.1" 29 | }, 30 | "eslintConfig": { 31 | "root": true, 32 | "env": { 33 | "node": true 34 | }, 35 | "extends": [ 36 | "plugin:vue/essential", 37 | "eslint:recommended" 38 | ], 39 | "rules": {}, 40 | "parserOptions": { 41 | "parser": "babel-eslint" 42 | } 43 | }, 44 | "postcss": { 45 | "plugins": { 46 | "autoprefixer": {} 47 | } 48 | }, 49 | "browserslist": [ 50 | "> 1%", 51 | "last 2 versions", 52 | "not ie <= 8" 53 | ] 54 | } 55 | -------------------------------------------------------------------------------- /demos/2.x/public/img/logo-dark-text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/websanova/vue-auth/1b3fba4c7b55b0ca4c09b1dc25ac1e1a033a1bdf/demos/2.x/public/img/logo-dark-text.png -------------------------------------------------------------------------------- /demos/2.x/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Vue Auth 2.x Demo 8 | 9 | 10 | 11 | 16 | 17 |
18 | 19 | -------------------------------------------------------------------------------- /demos/2.x/src/config/index.js: -------------------------------------------------------------------------------- 1 | import './plugins'; 2 | 3 | export default {}; -------------------------------------------------------------------------------- /demos/2.x/src/config/plugins.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | 3 | import auth from '@websanova/vue-auth/src/v2.js'; 4 | import driverAuthBearer from '@websanova/vue-auth/src/drivers/auth/bearer.js'; 5 | import driverHttpAxios from '@websanova/vue-auth/src/drivers/http/axios.1.x.js'; 6 | // import driverHttpVueResource from '@websanova/vue-auth/src/drivers/http/vue-resource.1.x.js'; 7 | import driverRouterVueRouter from '@websanova/vue-auth/src/drivers/router/vue-router.2.x.js'; 8 | import driverOAuth2Google from '@websanova/vue-auth/src/drivers/oauth2/google.js'; 9 | import driverOAuth2Facebook from '@websanova/vue-auth/src/drivers/oauth2/facebook.js'; 10 | 11 | driverOAuth2Google.params.client_id = '547886745924-4vrbhl09fr3t771drtupacct6f788566.apps.googleusercontent.com'; 12 | driverOAuth2Facebook.params.client_id = '196729390739201'; 13 | 14 | Vue.use(auth, { 15 | plugins: { 16 | http: Vue.axios, // Axios 17 | // http: Vue.http, // Vue Resource 18 | router: Vue.router, 19 | }, 20 | drivers: { 21 | auth: driverAuthBearer, 22 | http: driverHttpAxios, // Axios 23 | // http: driverHttpVueResource, // Vue Resource 24 | router: driverRouterVueRouter, 25 | oauth2: { 26 | google: driverOAuth2Google, 27 | facebook: driverOAuth2Facebook, 28 | } 29 | }, 30 | options: { 31 | rolesKey: 'type', 32 | notFoundRedirect: {name: 'user-account'}, 33 | } 34 | }); -------------------------------------------------------------------------------- /demos/2.x/src/http/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | 3 | // Vue Resource 4 | // import VueResource from 'vue-resource'; 5 | 6 | // Vue.use(VueResource); 7 | // Vue.http.options.root = process.env.VUE_APP_API_URL; 8 | 9 | // Axios 10 | import axios from 'axios'; 11 | import VueAxios from 'vue-axios'; 12 | 13 | axios.defaults.baseURL = process.env.VUE_APP_API_URL; 14 | Vue.use(VueAxios, axios); 15 | 16 | export default { 17 | root: process.env.VUE_APP_API_URL 18 | }; -------------------------------------------------------------------------------- /demos/2.x/src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | 3 | import http from './http' 4 | import store from './store' 5 | import router from './router' 6 | import config from './config' 7 | 8 | import App from './pages/Index.vue'; 9 | 10 | Vue.config.productionTip = false; 11 | 12 | new Vue({ 13 | el: '#app', 14 | http: http, 15 | store: store, 16 | router: router, 17 | config: config, 18 | render: h => h(App) 19 | }); -------------------------------------------------------------------------------- /demos/2.x/src/pages/Index.vue: -------------------------------------------------------------------------------- 1 | 146 | 147 | 203 | 204 | -------------------------------------------------------------------------------- /demos/2.x/src/pages/admin/Index.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /demos/2.x/src/pages/admin/Users.vue: -------------------------------------------------------------------------------- 1 | 40 | 41 | -------------------------------------------------------------------------------- /demos/2.x/src/pages/auth/Login.vue: -------------------------------------------------------------------------------- 1 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /demos/2.x/src/pages/auth/Register.vue: -------------------------------------------------------------------------------- 1 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /demos/2.x/src/pages/auth/Social.vue: -------------------------------------------------------------------------------- 1 | 61 | 62 | -------------------------------------------------------------------------------- /demos/2.x/src/pages/error/403.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /demos/2.x/src/pages/error/404.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /demos/2.x/src/pages/error/Index.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /demos/2.x/src/pages/site/Home.vue: -------------------------------------------------------------------------------- 1 | 97 | 98 | -------------------------------------------------------------------------------- /demos/2.x/src/pages/site/Users.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | -------------------------------------------------------------------------------- /demos/2.x/src/pages/user/Account.vue: -------------------------------------------------------------------------------- 1 | 122 | 123 | -------------------------------------------------------------------------------- /demos/2.x/src/pages/user/Index.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /demos/2.x/src/pages/user/Logout.vue: -------------------------------------------------------------------------------- 1 | 34 | 35 | -------------------------------------------------------------------------------- /demos/2.x/src/pages/user/Unimpersonate.vue: -------------------------------------------------------------------------------- 1 | 34 | 35 | -------------------------------------------------------------------------------- /demos/2.x/src/pages/user/Users.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | -------------------------------------------------------------------------------- /demos/2.x/src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import VueRouter from 'vue-router' 3 | 4 | Vue.use(VueRouter) 5 | 6 | function loadView(view) { 7 | return () => import(`../pages/${view}.vue`); 8 | } 9 | 10 | Vue.router = new VueRouter({ 11 | hashbang: false, 12 | mode: 'history', 13 | base: __dirname, 14 | routes: [{ 15 | path: '/', 16 | name: 'site-home', 17 | component: loadView('site/Home'), 18 | meta: { 19 | auth: false 20 | } 21 | }, { 22 | path: '/users', 23 | name: 'site-users', 24 | component: loadView('site/Users'), 25 | meta: { 26 | auth: false 27 | } 28 | }, { 29 | path: '/login', 30 | name: 'auth-login', 31 | component: loadView('auth/Login'), 32 | meta: { 33 | auth: false 34 | } 35 | }, { 36 | path: '/social', 37 | name: 'auth-social', 38 | component: loadView('auth/Social'), 39 | }, { 40 | path: '/login/:type', 41 | name: 'auth-login-social', 42 | component: loadView('auth/Social'), 43 | }, { 44 | path: '/register', 45 | name: 'auth-register', 46 | component: loadView('auth/Register'), 47 | meta: { 48 | auth: false 49 | } 50 | }, { 51 | path: '/user', 52 | component: loadView('user/Index'), 53 | meta: { 54 | auth: { 55 | roles: ['user', 'admin'], 56 | rolesKey: 'type' 57 | } 58 | }, 59 | children: [{ 60 | path: '', 61 | name: 'user-landing', 62 | redirect: { 63 | name: 'user-account' 64 | } 65 | }, { 66 | path: 'account', 67 | name: 'user-account', 68 | component: loadView('user/Account') 69 | }, { 70 | path: 'unimpersonate', 71 | name: 'user-unimpersonate', 72 | component: loadView('user/Unimpersonate') 73 | }, { 74 | path: 'users', 75 | name: 'user-users', 76 | component: loadView('user/Users') 77 | }, { 78 | path: 'logout', 79 | name: 'user-logout', 80 | component: loadView('user/Logout') 81 | }] 82 | }, { 83 | path: '/admin', 84 | component: loadView('admin/Index'), 85 | meta: { 86 | auth: 'admin' 87 | }, 88 | children: [{ 89 | path: '/', 90 | name: 'admin-landing', 91 | redirect: { 92 | name: 'admin-users' 93 | } 94 | }, { 95 | path: 'users', 96 | name: 'admin-users', 97 | component: loadView('admin/Users') 98 | }] 99 | }, { 100 | path: '/', 101 | component: loadView('error/Index'), 102 | children: [{ 103 | path: '403', 104 | name: 'error-403', 105 | component: loadView('error/403'), 106 | }, { 107 | path: '*', 108 | name: 'error-404', 109 | component: loadView('error/404'), 110 | }] 111 | }] 112 | }); 113 | 114 | export default Vue.router; -------------------------------------------------------------------------------- /demos/2.x/src/store/auth.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | 3 | export default { 4 | namespaced: true, 5 | 6 | state() { 7 | return { 8 | 9 | }; 10 | }, 11 | 12 | actions: { 13 | fetch(data) { 14 | return Vue.auth.fetch(data); 15 | }, 16 | 17 | refresh(data) { 18 | return Vue.auth.refresh(data); 19 | }, 20 | 21 | login(ctx, data) { 22 | data = data || {}; 23 | 24 | return new Promise((resolve, reject) => { 25 | Vue.auth.login({ 26 | url: 'auth/login', 27 | data: data.body, 28 | remember: data.remember, 29 | staySignedIn: data.staySignedIn, 30 | }) 31 | .then((res) => { 32 | if (data.remember) { 33 | Vue.auth.remember(JSON.stringify({ 34 | name: ctx.getters.user.first_name 35 | })); 36 | } 37 | 38 | Vue.router.push({ 39 | name: ctx.getters.user.type + '-landing' 40 | }); 41 | 42 | resolve(res); 43 | }, reject); 44 | }); 45 | }, 46 | 47 | register(ctx, data) { 48 | data = data || {}; 49 | 50 | return new Promise((resolve, reject) => { 51 | Vue.auth.register({ 52 | url: 'auth/register', 53 | data: data.body, 54 | autoLogin: false, 55 | }) 56 | .then((res) => { 57 | if (data.autoLogin) { 58 | ctx.dispatch('login', data).then(resolve, reject); 59 | } 60 | }, reject); 61 | }); 62 | }, 63 | 64 | impersonate(ctx, data) { 65 | var props = this.getters['properties/data']; 66 | 67 | Vue.auth.impersonate({ 68 | url: 'auth/' + data.user.id + '/impersonate', 69 | redirect: 'user-account' 70 | }); 71 | }, 72 | 73 | unimpersonate(ctx) { 74 | Vue.auth.unimpersonate({ 75 | redirect: 'admin-users' 76 | }); 77 | }, 78 | 79 | logout(ctx) { 80 | return Vue.auth.logout(); 81 | }, 82 | }, 83 | 84 | getters: { 85 | user() { 86 | return Vue.auth.user(); 87 | }, 88 | 89 | impersonating() { 90 | return Vue.auth.impersonating(); 91 | } 92 | } 93 | } -------------------------------------------------------------------------------- /demos/2.x/src/store/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import Vuex from 'vuex'; 3 | 4 | import auth from './auth.js'; 5 | 6 | Vue.use(Vuex); 7 | 8 | const debug = process.env.NODE_ENV !== 'production'; 9 | 10 | export default new Vuex.Store({ 11 | modules: { 12 | auth 13 | }, 14 | 15 | strict: debug 16 | }); -------------------------------------------------------------------------------- /demos/2.x/vue.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | lintOnSave: false, 3 | 4 | devServer: { 5 | port: process.env.DEV_PORT || 8000, 6 | 7 | https: process.env.DEV_HTTPS === 'false' ? false : true, 8 | 9 | disableHostCheck: true, 10 | 11 | host: process.env.DEV_HOST || '0.0.0.0', 12 | 13 | public: (process.env.DEV_HOST || '0.0.0.0') || + (process.env.DEV_PORT || 8000) 14 | }, 15 | 16 | chainWebpack: (config) => { 17 | config 18 | .resolve 19 | .alias 20 | .set('@websanova/vue-auth', __dirname + '/../../'); 21 | } 22 | } -------------------------------------------------------------------------------- /demos/3.x/.env: -------------------------------------------------------------------------------- 1 | NODE_ENV=local 2 | 3 | VUE_APP_API_URL=https://api-starter.websanova.com/v1 -------------------------------------------------------------------------------- /demos/3.x/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | 6 | # local env files 7 | .env.local 8 | .env.*.local 9 | 10 | # Log files 11 | npm-debug.log* 12 | yarn-debug.log* 13 | yarn-error.log* 14 | pnpm-debug.log* 15 | 16 | # Editor directories and files 17 | .idea 18 | .vscode 19 | *.suo 20 | *.ntvs* 21 | *.njsproj 22 | *.sln 23 | *.sw? 24 | -------------------------------------------------------------------------------- /demos/3.x/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/cli-plugin-babel/preset' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /demos/3.x/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "4.x", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint" 9 | }, 10 | "dependencies": { 11 | "core-js": "3.6.5", 12 | "vue": "3.0.1", 13 | "vuex": "4.0.0-rc.1", 14 | "vue-router": "next", 15 | "axios": "0.20.0" 16 | }, 17 | "devDependencies": { 18 | "@vue/cli-plugin-babel": "~4.5.0", 19 | "@vue/cli-plugin-eslint": "~4.5.0", 20 | "@vue/cli-service": "~4.5.0", 21 | "@vue/compiler-sfc": "^3.0.0", 22 | "babel-eslint": "^10.1.0", 23 | "eslint": "^6.7.2", 24 | "eslint-plugin-vue": "^7.0.0-0" 25 | }, 26 | "eslintConfig": { 27 | "root": true, 28 | "env": { 29 | "node": true 30 | }, 31 | "extends": [ 32 | "plugin:vue/vue3-essential", 33 | "eslint:recommended" 34 | ], 35 | "parserOptions": { 36 | "parser": "babel-eslint" 37 | }, 38 | "rules": {} 39 | }, 40 | "browserslist": [ 41 | "> 1%", 42 | "last 2 versions", 43 | "not dead" 44 | ] 45 | } -------------------------------------------------------------------------------- /demos/3.x/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/websanova/vue-auth/1b3fba4c7b55b0ca4c09b1dc25ac1e1a033a1bdf/demos/3.x/public/favicon.ico -------------------------------------------------------------------------------- /demos/3.x/public/img/logo-dark-text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/websanova/vue-auth/1b3fba4c7b55b0ca4c09b1dc25ac1e1a033a1bdf/demos/3.x/public/img/logo-dark-text.png -------------------------------------------------------------------------------- /demos/3.x/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Vue Upload 3.x Demo 8 | 9 | 10 | 11 | 14 | 15 |
16 | 17 | -------------------------------------------------------------------------------- /demos/3.x/src/composables/useAuthComp.js: -------------------------------------------------------------------------------- 1 | import {useRouter} from 'vue-router'; 2 | import {useAuth } from '@websanova/vue-auth/src/v3.js'; 3 | 4 | export default function useAuthComp() { 5 | const auth = useAuth(); 6 | const router = useRouter(); 7 | 8 | function fetch(data) { 9 | return auth.fetch(data); 10 | } 11 | 12 | function refresh(data) { 13 | return auth.refresh(data); 14 | } 15 | 16 | function login(data) { 17 | data = data || {}; 18 | 19 | return new Promise((resolve, reject) => { 20 | auth.login({ 21 | url: 'auth/login', 22 | data: data.body, 23 | remember: data.remember, 24 | staySignedIn: data.staySignedIn, 25 | fetchUser: data.fetchUser, 26 | }) 27 | .then((res) => { 28 | if (data.remember) { 29 | auth.remember(JSON.stringify({ 30 | name: res.response.data.user.first_name 31 | })); 32 | } 33 | 34 | router.push({ 35 | name: res.data.data.type + '-landing' 36 | }); 37 | 38 | resolve(res); 39 | }, reject); 40 | }); 41 | }; 42 | 43 | function register(data) { 44 | data = data || {}; 45 | 46 | return new Promise((resolve, reject) => { 47 | auth.register({ 48 | url: 'auth/register', 49 | data: data.body, 50 | autoLogin: false, 51 | }) 52 | .then((res) => { 53 | if (data.autoLogin) { 54 | login(data).then(resolve, reject); 55 | } 56 | }, reject); 57 | }); 58 | } 59 | 60 | function impersonate(data) { 61 | return auth.impersonate({ 62 | url: 'auth/' + data.user.id + '/impersonate', 63 | redirect: { 64 | name: 'user-account' 65 | } 66 | }); 67 | } 68 | 69 | function unimpersonate() { 70 | return auth.unimpersonate({ 71 | redirect: { 72 | name: 'admin-users' 73 | } 74 | }); 75 | } 76 | 77 | function logout() { 78 | return auth.logout(); 79 | } 80 | 81 | function user() { 82 | return auth.user(); 83 | } 84 | 85 | function impersonating() { 86 | return auth.impersonating(); 87 | } 88 | 89 | return { 90 | fetch, 91 | refresh, 92 | login, 93 | register, 94 | impersonate, 95 | unimpersonate, 96 | logout, 97 | user, 98 | impersonating, 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /demos/3.x/src/elements/Layout.vue: -------------------------------------------------------------------------------- 1 | 34 | 35 | 44 | 45 | -------------------------------------------------------------------------------- /demos/3.x/src/http/index.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | 3 | axios.defaults.baseURL = process.env.VUE_APP_API_URL; 4 | 5 | export default (app) => { 6 | app.axios = axios; 7 | app.$http = axios; 8 | 9 | app.config.globalProperties.axios = axios; 10 | app.config.globalProperties.$http = axios; 11 | } -------------------------------------------------------------------------------- /demos/3.x/src/main.js: -------------------------------------------------------------------------------- 1 | import {createApp} from 'vue'; 2 | import App from './pages/Index.vue'; 3 | import http from './http'; 4 | import store from './store'; 5 | import router from './router'; 6 | import auth from './plugins/auth.js'; 7 | 8 | const app = createApp(App); 9 | 10 | app 11 | .use(http) 12 | .use(store) 13 | .use(router) 14 | .use(auth) 15 | .mount('#app'); -------------------------------------------------------------------------------- /demos/3.x/src/pages/Index.vue: -------------------------------------------------------------------------------- 1 | 91 | 92 | 222 | -------------------------------------------------------------------------------- /demos/3.x/src/pages/admin/Index.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /demos/3.x/src/pages/admin/Users.vue: -------------------------------------------------------------------------------- 1 | 49 | 50 | -------------------------------------------------------------------------------- /demos/3.x/src/pages/auth/Login.vue: -------------------------------------------------------------------------------- 1 | 77 | 78 | -------------------------------------------------------------------------------- /demos/3.x/src/pages/auth/Register.vue: -------------------------------------------------------------------------------- 1 | 103 | 104 | -------------------------------------------------------------------------------- /demos/3.x/src/pages/auth/Social.vue: -------------------------------------------------------------------------------- 1 | 54 | 55 | -------------------------------------------------------------------------------- /demos/3.x/src/pages/error/403.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /demos/3.x/src/pages/error/404.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /demos/3.x/src/pages/error/Index.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /demos/3.x/src/pages/site/Home.vue: -------------------------------------------------------------------------------- 1 | 121 | 122 | -------------------------------------------------------------------------------- /demos/3.x/src/pages/site/Users.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | -------------------------------------------------------------------------------- /demos/3.x/src/pages/user/Account.vue: -------------------------------------------------------------------------------- 1 | 155 | 156 | -------------------------------------------------------------------------------- /demos/3.x/src/pages/user/Index.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /demos/3.x/src/pages/user/Logout.vue: -------------------------------------------------------------------------------- 1 | 28 | 29 | -------------------------------------------------------------------------------- /demos/3.x/src/pages/user/Unimpersonate.vue: -------------------------------------------------------------------------------- 1 | 28 | 29 | -------------------------------------------------------------------------------- /demos/3.x/src/pages/user/Users.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | -------------------------------------------------------------------------------- /demos/3.x/src/plugins/auth.js: -------------------------------------------------------------------------------- 1 | import {createAuth} from '@websanova/vue-auth/src/v3.js'; 2 | import driverAuthBearer from '@websanova/vue-auth/src/drivers/auth/bearer.js'; 3 | import driverHttpAxios from '@websanova/vue-auth/src/drivers/http/axios.1.x.js'; 4 | import driverRouterVueRouter from '@websanova/vue-auth/src/drivers/router/vue-router.2.x.js'; 5 | import driverOAuth2Google from '@websanova/vue-auth/src/drivers/oauth2/google.js'; 6 | import driverOAuth2Facebook from '@websanova/vue-auth/src/drivers/oauth2/facebook.js'; 7 | 8 | driverOAuth2Google.params.client_id = '547886745924-4vrbhl09fr3t771drtupacct6f788566.apps.googleusercontent.com'; 9 | driverOAuth2Facebook.params.client_id = '196729390739201'; 10 | 11 | export default (app) => { 12 | app.use(createAuth({ 13 | plugins: { 14 | http: app.axios, 15 | router: app.router, 16 | }, 17 | drivers: { 18 | http: driverHttpAxios, 19 | auth: driverAuthBearer, 20 | router: driverRouterVueRouter, 21 | oauth2: { 22 | google: driverOAuth2Google, 23 | facebook: driverOAuth2Facebook, 24 | } 25 | }, 26 | options: { 27 | rolesKey: 'type', 28 | notFoundRedirect: {name: 'user-account'}, 29 | } 30 | })); 31 | } -------------------------------------------------------------------------------- /demos/3.x/src/router/index.js: -------------------------------------------------------------------------------- 1 | import {createRouter, createWebHistory} from 'vue-router'; 2 | 3 | function loadView(view) { 4 | return () => import(`../pages/${view}.vue`); 5 | } 6 | 7 | const router = createRouter({ 8 | hashbang: false, 9 | history: createWebHistory(), 10 | routes: [{ 11 | path: '/', 12 | name: 'site-home', 13 | component: loadView('site/Home'), 14 | meta: { 15 | auth: false 16 | } 17 | }, { 18 | path: '/users', 19 | name: 'site-users', 20 | component: loadView('site/Users'), 21 | meta: { 22 | auth: false 23 | } 24 | }, { 25 | path: '/login', 26 | name: 'auth-login', 27 | component: loadView('auth/Login'), 28 | meta: { 29 | auth: false 30 | } 31 | }, { 32 | path: '/social', 33 | name: 'auth-social', 34 | component: loadView('auth/Social'), 35 | }, { 36 | path: '/login/:type', 37 | name: 'auth-login-social', 38 | component: loadView('auth/Social'), 39 | }, { 40 | path: '/register', 41 | name: 'auth-register', 42 | component: loadView('auth/Register'), 43 | meta: { 44 | auth: false 45 | } 46 | }, { 47 | path: '/user', 48 | component: loadView('user/Index'), 49 | meta: { 50 | auth: true 51 | }, 52 | children: [{ 53 | path: '', 54 | name: 'user-landing', 55 | redirect: { 56 | name: 'user-account' 57 | } 58 | }, { 59 | path: 'account', 60 | name: 'user-account', 61 | component: loadView('user/Account') 62 | }, { 63 | path: 'unimpersonate', 64 | name: 'user-unimpersonate', 65 | component: loadView('user/Unimpersonate') 66 | }, { 67 | path: 'users', 68 | name: 'user-users', 69 | component: loadView('user/Users') 70 | }, { 71 | path: 'logout', 72 | name: 'user-logout', 73 | component: loadView('user/Logout') 74 | }] 75 | }, { 76 | path: '/admin', 77 | component: loadView('admin/Index'), 78 | meta: { 79 | auth: 'admin' 80 | }, 81 | children: [{ 82 | path: '/', 83 | name: 'admin-landing', 84 | redirect: { 85 | name: 'admin-users' 86 | } 87 | }, { 88 | path: 'users', 89 | name: 'admin-users', 90 | component: loadView('admin/Users') 91 | }] 92 | }, { 93 | path: '/', 94 | component: loadView('error/Index'), 95 | children: [{ 96 | path: '403', 97 | name: 'error-403', 98 | component: loadView('error/403'), 99 | }, { 100 | path: '/:pathNotFound(.*)*', 101 | name: 'error-404', 102 | component: loadView('error/404'), 103 | }] 104 | }] 105 | }); 106 | 107 | export default (app) => { 108 | app.router = router; 109 | 110 | app.use(router); 111 | } -------------------------------------------------------------------------------- /demos/3.x/src/store/index.js: -------------------------------------------------------------------------------- 1 | import {createStore} from 'vuex'; 2 | 3 | const debug = process.env.NODE_ENV !== 'production'; 4 | 5 | const store = createStore({ 6 | modules: {}, 7 | 8 | strict: debug 9 | }); 10 | 11 | export default store; -------------------------------------------------------------------------------- /demos/3.x/src/styles/nova.css: -------------------------------------------------------------------------------- 1 | /************************************** 2 | * default: #3a3a3a; 3 | * primary: #6699ff; 4 | * muted : #dadada; 5 | * 6 | * layout : #eaeaea; 7 | * 8 | * 9 | **************************************/ 10 | 11 | /************************************** 12 | * DEFAULT 13 | **************************************/ 14 | * { 15 | box-sizing: border-box; 16 | } 17 | 18 | img { 19 | vertical-align: middle; 20 | } 21 | 22 | body { 23 | margin: 0px; 24 | padding: 0px; 25 | padding-bottom: 100px; 26 | color: #3a3a3a; 27 | font-size: 1em; 28 | } 29 | 30 | /************************************** 31 | * MEDIA 32 | **************************************/ 33 | .media { 34 | display: flex; 35 | flex-wrap: wrap; 36 | justify-content: space-between; 37 | padding: 5px 0; 38 | } 39 | 40 | .media:not(:last-child) { 41 | margin-bottom: 10px; 42 | } 43 | 44 | .media > div { 45 | display: flex; 46 | flex: 1; 47 | flex-flow: row wrap; 48 | } 49 | 50 | .media > .media-tight { 51 | flex: none; 52 | word-break: keep-all; 53 | white-space: nowrap 54 | } 55 | 56 | .media > .media-middle { 57 | align-items: center; 58 | } 59 | 60 | .media > .media-right { 61 | justify-content: right; 62 | } 63 | 64 | /************************************** 65 | * TEXT 66 | **************************************/ 67 | body, 68 | button, 69 | select { 70 | font-family: Roboto,Verdana,Arial,Sans-Serif; 71 | } 72 | 73 | .text-bold {font-weight: bold} 74 | .text-center {text-align: center} 75 | 76 | a, 77 | .text-link { 78 | display: inline-block; 79 | cursor: pointer; 80 | text-decoration: none; 81 | color: #6699ff; 82 | } 83 | 84 | a:hover, 85 | .text-link:hover, 86 | .text-link.active { 87 | text-decoration: underline; 88 | } 89 | 90 | .text-muted {color: #dadada} 91 | .text-danger {color: #ff0000} 92 | .text-default {color: #3a3a3a} 93 | .text-primary {color: #6699ff} 94 | 95 | .text-sm {font-size: 0.8em;} 96 | 97 | /************************************** 98 | * SPACER 99 | **************************************/ 100 | ul.spacer { 101 | margin: 0px; 102 | padding: 0px; 103 | } 104 | 105 | ul.spacer > li { 106 | display: inline-block; 107 | vertical-align: middle; 108 | } 109 | 110 | ul.spacer > li > * { 111 | display: inline-block; 112 | } 113 | 114 | ul.spacer > li:not(:last-child)::after { 115 | content: ''; 116 | margin: 0 5px; 117 | color: #eaeaea; 118 | cursor: default !important; 119 | pointer-events: none; 120 | } 121 | 122 | ul.spacer-pipe > li:not(:last-child)::after { 123 | content: '|'; 124 | } 125 | 126 | /************************************** 127 | * DISPLAY 128 | **************************************/ 129 | .px-1 {padding-left: 0.5em !important; padding-right: 0.5em !important;} 130 | .px-2 {padding-left: 0.8em !important; padding-right: 0.8em !important;} 131 | .px-3 {padding-left: 1.3em !important; padding-right: 1.3em !important;} 132 | .px-4 {padding-left: 2em !important; padding-right: 2em !important;} 133 | 134 | .py-0 {padding-top: 0em !important; padding-bottom: 0em !important;} 135 | .py-1 {padding-top: 0.5em !important; padding-bottom: 0.5em !important;} 136 | .py-2 {padding-top: 0.8em !important; padding-bottom: 0.8em !important;} 137 | .py-3 {padding-top: 1.3em !important; padding-bottom: 1.3em !important;} 138 | .py-4 {padding-top: 2em !important; padding-bottom: 2em !important;} 139 | 140 | .mx-1 {margin-left: 0.5em !important; margin-right: 0.5em !important;} 141 | .mx-2 {margin-left: 0.8em !important; margin-right: 0.8em !important;} 142 | .mx-3 {margin-left: 1.3em !important; margin-right: 1.3em !important;} 143 | .mx-4 {margin-left: 2em !important; margin-right: 2em !important;} 144 | 145 | .my-0 {margin-top: 0em !important; margin-bottom: 0em !important;} 146 | .my-1 {margin-top: 0.5em !important; margin-bottom: 0.5em !important;} 147 | .my-2 {margin-top: 0.8em !important; margin-bottom: 0.8em !important;} 148 | .my-3 {margin-top: 1.3em !important; margin-bottom: 1.3em !important;} 149 | .my-4 {margin-top: 2em !important; margin-bottom: 2em !important;} 150 | 151 | .mb-1 {margin-bottom: 0.5em !important;} 152 | .mb-2 {margin-bottom: 0.8em !important;} 153 | .mb-3 {margin-bottom: 1.3em !important;} 154 | .mb-4 {margin-bottom: 2em !important;} 155 | 156 | /************************************** 157 | * SPACING 158 | **************************************/ 159 | 160 | .w-100 {width:100%;} 161 | 162 | /************************************** 163 | * SPINNER 164 | **************************************/ 165 | .spinner::before { 166 | content: '+'; 167 | margin: 0 5px; 168 | display: inline-block; 169 | animation-name: spin; 170 | animation-duration: 1s; 171 | animation-iteration-count: infinite; 172 | animation-timing-function: linear; 173 | } 174 | 175 | @keyframes spin { 176 | from {transform:rotate(0deg)} 177 | to {transform:rotate(360deg)} 178 | } 179 | 180 | /************************************** 181 | * HEADER 182 | **************************************/ 183 | .header { 184 | height: 30px; 185 | line-height:30px 186 | } 187 | 188 | .header > img, 189 | .header > a > img { 190 | height: 30px 191 | } 192 | 193 | /************************************** 194 | * CONTAINER 195 | **************************************/ 196 | .container { 197 | margin: 0 auto; 198 | padding: 0 30px; 199 | max-width: 600px 200 | } 201 | 202 | .container-xs { 203 | max-width: 200px 204 | } 205 | 206 | .container-sm { 207 | max-width: 400px 208 | } 209 | 210 | .container-lg { 211 | max-width: 800px 212 | } 213 | 214 | .container-xl { 215 | max-width: 1000px 216 | } 217 | 218 | /************************************** 219 | * THUMBNAIL 220 | **************************************/ 221 | .thumbnail { 222 | display: inline-block; 223 | width: 150px; 224 | height: 150px; 225 | line-height: 142px; 226 | padding: 2px; 227 | text-align: center; 228 | border: solid #eaeaea 1px; 229 | } 230 | 231 | .thumbnail > img { 232 | width: 100%; 233 | } 234 | 235 | .thumbnail-sm { 236 | width: 100px; 237 | height: 100px; 238 | line-height: 92px; 239 | } 240 | 241 | 242 | /************************************** 243 | * HR 244 | **************************************/ 245 | hr { 246 | margin: 15px 0; 247 | border-top: none; 248 | border-bottom-color: #eaeaea 249 | } 250 | 251 | /************************************** 252 | * HEADING 253 | **************************************/ 254 | h1 { 255 | margin: 15px 0 256 | } 257 | 258 | /************************************** 259 | * BUTTON 260 | **************************************/ 261 | .btn, 262 | button { 263 | font-size: 0.8em; 264 | padding: 4px 8px 265 | } 266 | 267 | .btn-sm { 268 | font-size: 0.6em; 269 | padding: 2px 6px; 270 | } 271 | 272 | /************************************** 273 | * INPUT 274 | **************************************/ 275 | .input-group { 276 | margin-bottom: 10px; 277 | } 278 | 279 | .input-group > input[type=text], 280 | .input-group > input[type=password] { 281 | width: 100%; 282 | padding: 5px; 283 | } 284 | 285 | 286 | /************************************** 287 | * SELECT 288 | **************************************/ 289 | select { 290 | font-size: 0.8em; 291 | padding: 4px 8px 292 | } -------------------------------------------------------------------------------- /demos/3.x/vue.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | lintOnSave: false, 3 | 4 | devServer: { 5 | port: process.env.DEV_PORT || 8000, 6 | 7 | https: process.env.DEV_HTTPS === 'false' ? false : true, 8 | 9 | disableHostCheck: true, 10 | 11 | host: process.env.DEV_HOST || '0.0.0.0', 12 | 13 | public: (process.env.DEV_HOST || '0.0.0.0') || + (process.env.DEV_PORT || 8000) 14 | }, 15 | 16 | chainWebpack: (config) => { 17 | config 18 | .resolve 19 | .alias 20 | .set('@websanova/vue-auth', __dirname + '/../../'); 21 | } 22 | } -------------------------------------------------------------------------------- /dist/drivers/auth/basic.common.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | 'use strict'; 8 | 9 | var basic = { 10 | request: function (req, token) { 11 | this.drivers.http.setHeaders.call(this, req, { 12 | Authorization: token 13 | }); 14 | }, 15 | response: function (res) { 16 | var headers = this.drivers.http.getHeaders.call(this, res), 17 | token = headers.Authorization || headers.authorization; 18 | return token; 19 | } 20 | }; 21 | 22 | module.exports = basic; 23 | -------------------------------------------------------------------------------- /dist/drivers/auth/basic.esm.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | var basic = { 8 | request: function (req, token) { 9 | this.drivers.http.setHeaders.call(this, req, { 10 | Authorization: token 11 | }); 12 | }, 13 | response: function (res) { 14 | var headers = this.drivers.http.getHeaders.call(this, res), 15 | token = headers.Authorization || headers.authorization; 16 | return token; 17 | } 18 | }; 19 | 20 | export default basic; 21 | -------------------------------------------------------------------------------- /dist/drivers/auth/basic.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | (function (global, factory) { 8 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : 9 | typeof define === 'function' && define.amd ? define(factory) : 10 | (global.VueAuth = factory()); 11 | }(this, (function () { 'use strict'; 12 | 13 | var basic = { 14 | request: function (req, token) { 15 | this.drivers.http.setHeaders.call(this, req, { 16 | Authorization: token 17 | }); 18 | }, 19 | response: function (res) { 20 | var headers = this.drivers.http.getHeaders.call(this, res), 21 | token = headers.Authorization || headers.authorization; 22 | return token; 23 | } 24 | }; 25 | 26 | return basic; 27 | 28 | }))); 29 | -------------------------------------------------------------------------------- /dist/drivers/auth/basic.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.VueAuth=e()}(this,function(){"use strict";return{request:function(t,e){this.drivers.http.setHeaders.call(this,t,{Authorization:e})},response:function(t){t=this.drivers.http.getHeaders.call(this,t);return t.Authorization||t.authorization}}}); -------------------------------------------------------------------------------- /dist/drivers/auth/bearer.common.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | 'use strict'; 8 | 9 | var bearer = { 10 | request: function (req, token) { 11 | this.drivers.http.setHeaders.call(this, req, { 12 | Authorization: 'Bearer ' + token 13 | }); 14 | }, 15 | response: function (res) { 16 | var headers = this.drivers.http.getHeaders.call(this, res), 17 | token = headers.Authorization || headers.authorization; 18 | if (token) { 19 | token = token.split(/Bearer:?\s?/i); 20 | return token[token.length > 1 ? 1 : 0].trim(); 21 | } 22 | } 23 | }; 24 | 25 | module.exports = bearer; 26 | -------------------------------------------------------------------------------- /dist/drivers/auth/bearer.esm.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | var bearer = { 8 | request: function (req, token) { 9 | this.drivers.http.setHeaders.call(this, req, { 10 | Authorization: 'Bearer ' + token 11 | }); 12 | }, 13 | response: function (res) { 14 | var headers = this.drivers.http.getHeaders.call(this, res), 15 | token = headers.Authorization || headers.authorization; 16 | if (token) { 17 | token = token.split(/Bearer:?\s?/i); 18 | return token[token.length > 1 ? 1 : 0].trim(); 19 | } 20 | } 21 | }; 22 | 23 | export default bearer; 24 | -------------------------------------------------------------------------------- /dist/drivers/auth/bearer.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | (function (global, factory) { 8 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : 9 | typeof define === 'function' && define.amd ? define(factory) : 10 | (global.VueAuth = factory()); 11 | }(this, (function () { 'use strict'; 12 | 13 | var bearer = { 14 | request: function (req, token) { 15 | this.drivers.http.setHeaders.call(this, req, { 16 | Authorization: 'Bearer ' + token 17 | }); 18 | }, 19 | response: function (res) { 20 | var headers = this.drivers.http.getHeaders.call(this, res), 21 | token = headers.Authorization || headers.authorization; 22 | if (token) { 23 | token = token.split(/Bearer:?\s?/i); 24 | return token[token.length > 1 ? 1 : 0].trim(); 25 | } 26 | } 27 | }; 28 | 29 | return bearer; 30 | 31 | }))); 32 | -------------------------------------------------------------------------------- /dist/drivers/auth/bearer.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.VueAuth=t()}(this,function(){"use strict";return{request:function(e,t){this.drivers.http.setHeaders.call(this,e,{Authorization:"Bearer "+t})},response:function(e){e=this.drivers.http.getHeaders.call(this,e),e=e.Authorization||e.authorization;if(e)return(e=e.split(/Bearer:?\s?/i))[1= parseInt(this.token().split('|')[4], 10)) { 35 | return token.join('|'); 36 | } 37 | } 38 | } 39 | }; 40 | 41 | module.exports = devise; 42 | -------------------------------------------------------------------------------- /dist/drivers/auth/devise.esm.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | var devise = { 8 | tokens: ['Token-Type', 'Access-Token', 'Client', 'Uid', 'Expiry', 'token-type', 'access-token', 'client', 'uid', 'expiry'], 9 | request: function (req, token) { 10 | var headers = {}, 11 | tokens = token.split('|'); 12 | var auth = this.drivers.deviseAuth || this.drivers.auth; 13 | auth.tokens.forEach(function (tokenName, index) { 14 | if (tokens[index]) { 15 | headers[tokenName] = tokens[index]; 16 | } 17 | }); 18 | this.drivers.http.setHeaders.call(this, req, headers); 19 | }, 20 | response: function (res) { 21 | var token = [], 22 | headers = this.drivers.http.getHeaders.call(this, res); 23 | if (headers['access-token'] || headers['Access-Token']) { 24 | var auth = this.drivers.deviseAuth || this.drivers.auth; 25 | auth.tokens.forEach(function (tokenName) { 26 | if (headers[tokenName]) { 27 | token.push(headers[tokenName]); 28 | } 29 | }); 30 | 31 | // Check if access-token more recent than last one 32 | if (!this.token() || parseInt(token[4], 10) >= parseInt(this.token().split('|')[4], 10)) { 33 | return token.join('|'); 34 | } 35 | } 36 | } 37 | }; 38 | 39 | export default devise; 40 | -------------------------------------------------------------------------------- /dist/drivers/auth/devise.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | (function (global, factory) { 8 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : 9 | typeof define === 'function' && define.amd ? define(factory) : 10 | (global.VueAuth = factory()); 11 | }(this, (function () { 'use strict'; 12 | 13 | var devise = { 14 | tokens: ['Token-Type', 'Access-Token', 'Client', 'Uid', 'Expiry', 'token-type', 'access-token', 'client', 'uid', 'expiry'], 15 | request: function (req, token) { 16 | var headers = {}, 17 | tokens = token.split('|'); 18 | var auth = this.drivers.deviseAuth || this.drivers.auth; 19 | auth.tokens.forEach(function (tokenName, index) { 20 | if (tokens[index]) { 21 | headers[tokenName] = tokens[index]; 22 | } 23 | }); 24 | this.drivers.http.setHeaders.call(this, req, headers); 25 | }, 26 | response: function (res) { 27 | var token = [], 28 | headers = this.drivers.http.getHeaders.call(this, res); 29 | if (headers['access-token'] || headers['Access-Token']) { 30 | var auth = this.drivers.deviseAuth || this.drivers.auth; 31 | auth.tokens.forEach(function (tokenName) { 32 | if (headers[tokenName]) { 33 | token.push(headers[tokenName]); 34 | } 35 | }); 36 | 37 | // Check if access-token more recent than last one 38 | if (!this.token() || parseInt(token[4], 10) >= parseInt(this.token().split('|')[4], 10)) { 39 | return token.join('|'); 40 | } 41 | } 42 | } 43 | }; 44 | 45 | return devise; 46 | 47 | }))); 48 | -------------------------------------------------------------------------------- /dist/drivers/auth/devise.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.VueAuth=t()}(this,function(){"use strict";return{tokens:["Token-Type","Access-Token","Client","Uid","Expiry","token-type","access-token","client","uid","expiry"],request:function(e,t){var s={},i=t.split("|");(this.drivers.deviseAuth||this.drivers.auth).tokens.forEach(function(e,t){i[t]&&(s[e]=i[t])}),this.drivers.http.setHeaders.call(this,e,s)},response:function(e){var t=[],s=this.drivers.http.getHeaders.call(this,e);if((s["access-token"]||s["Access-Token"])&&((this.drivers.deviseAuth||this.drivers.auth).tokens.forEach(function(e){s[e]&&t.push(s[e])}),!this.token()||parseInt(t[4],10)>=parseInt(this.token().split("|")[4],10)))return t.join("|")}}}); -------------------------------------------------------------------------------- /dist/drivers/http/axios.1.x.common.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | 'use strict'; 8 | 9 | var axios_1_x = { 10 | init: function () { 11 | if (!this.plugins.http) { 12 | return 'drivers/http/axios.js: http plugin has not been set.'; 13 | } 14 | }, 15 | interceptor: function (req, res) { 16 | var _this = this; 17 | if (req) { 18 | this.plugins.http.interceptors.request.use(function (request) { 19 | req.call(_this, request); 20 | return request; 21 | }, function (error) { 22 | req.call(_this, error.request); 23 | return Promise.reject(error); 24 | }); 25 | } 26 | if (res) { 27 | this.plugins.http.interceptors.response.use(function (response) { 28 | res.call(_this, response); 29 | return response; 30 | }, function (error) { 31 | if (error && error.response) { 32 | res.call(_this, error.response); 33 | } 34 | return Promise.reject(error); 35 | }); 36 | } 37 | }, 38 | invalidToken: function (res) { 39 | if (res.status === 401) { 40 | return true; 41 | } 42 | }, 43 | httpData: function (res) { 44 | return res.data || {}; 45 | }, 46 | http: function (data) { 47 | return this.plugins.http(data); 48 | }, 49 | getHeaders: function (res) { 50 | return res.headers; 51 | }, 52 | setHeaders: function (req, headers) { 53 | req.headers = Object.assign({}, req.headers, headers); 54 | } 55 | }; 56 | 57 | module.exports = axios_1_x; 58 | -------------------------------------------------------------------------------- /dist/drivers/http/axios.1.x.esm.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | var axios_1_x = { 8 | init: function () { 9 | if (!this.plugins.http) { 10 | return 'drivers/http/axios.js: http plugin has not been set.'; 11 | } 12 | }, 13 | interceptor: function (req, res) { 14 | var _this = this; 15 | if (req) { 16 | this.plugins.http.interceptors.request.use(function (request) { 17 | req.call(_this, request); 18 | return request; 19 | }, function (error) { 20 | req.call(_this, error.request); 21 | return Promise.reject(error); 22 | }); 23 | } 24 | if (res) { 25 | this.plugins.http.interceptors.response.use(function (response) { 26 | res.call(_this, response); 27 | return response; 28 | }, function (error) { 29 | if (error && error.response) { 30 | res.call(_this, error.response); 31 | } 32 | return Promise.reject(error); 33 | }); 34 | } 35 | }, 36 | invalidToken: function (res) { 37 | if (res.status === 401) { 38 | return true; 39 | } 40 | }, 41 | httpData: function (res) { 42 | return res.data || {}; 43 | }, 44 | http: function (data) { 45 | return this.plugins.http(data); 46 | }, 47 | getHeaders: function (res) { 48 | return res.headers; 49 | }, 50 | setHeaders: function (req, headers) { 51 | req.headers = Object.assign({}, req.headers, headers); 52 | } 53 | }; 54 | 55 | export default axios_1_x; 56 | -------------------------------------------------------------------------------- /dist/drivers/http/axios.1.x.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | (function (global, factory) { 8 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : 9 | typeof define === 'function' && define.amd ? define(factory) : 10 | (global.VueAuth = factory()); 11 | }(this, (function () { 'use strict'; 12 | 13 | var axios_1_x = { 14 | init: function () { 15 | if (!this.plugins.http) { 16 | return 'drivers/http/axios.js: http plugin has not been set.'; 17 | } 18 | }, 19 | interceptor: function (req, res) { 20 | var _this = this; 21 | if (req) { 22 | this.plugins.http.interceptors.request.use(function (request) { 23 | req.call(_this, request); 24 | return request; 25 | }, function (error) { 26 | req.call(_this, error.request); 27 | return Promise.reject(error); 28 | }); 29 | } 30 | if (res) { 31 | this.plugins.http.interceptors.response.use(function (response) { 32 | res.call(_this, response); 33 | return response; 34 | }, function (error) { 35 | if (error && error.response) { 36 | res.call(_this, error.response); 37 | } 38 | return Promise.reject(error); 39 | }); 40 | } 41 | }, 42 | invalidToken: function (res) { 43 | if (res.status === 401) { 44 | return true; 45 | } 46 | }, 47 | httpData: function (res) { 48 | return res.data || {}; 49 | }, 50 | http: function (data) { 51 | return this.plugins.http(data); 52 | }, 53 | getHeaders: function (res) { 54 | return res.headers; 55 | }, 56 | setHeaders: function (req, headers) { 57 | req.headers = Object.assign({}, req.headers, headers); 58 | } 59 | }; 60 | 61 | return axios_1_x; 62 | 63 | }))); 64 | -------------------------------------------------------------------------------- /dist/drivers/http/axios.1.x.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.VueAuth=e()}(this,function(){"use strict";return{init:function(){if(!this.plugins.http)return"drivers/http/axios.js: http plugin has not been set."},interceptor:function(e,n){var r=this;e&&this.plugins.http.interceptors.request.use(function(t){return e.call(r,t),t},function(t){return e.call(r,t.request),Promise.reject(t)}),n&&this.plugins.http.interceptors.response.use(function(t){return n.call(r,t),t},function(t){return t&&t.response&&n.call(r,t.response),Promise.reject(t)})},invalidToken:function(t){if(401===t.status)return!0},httpData:function(t){return t.data||{}},http:function(t){return this.plugins.http(t)},getHeaders:function(t){return t.headers},setHeaders:function(t,e){t.headers=Object.assign({},t.headers,e)}}}); -------------------------------------------------------------------------------- /dist/drivers/http/frisbee.1.x.common.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | 'use strict'; 8 | 9 | var frisbee_1_x = { 10 | init: function () { 11 | if (!this.plugins.http) { 12 | return 'drivers/http/frisbee.js: http plugin has not been set.'; 13 | } 14 | }, 15 | interceptor: function (req, res) { 16 | var _this = this; 17 | this.plugins.http.interceptor.register({ 18 | request: function (path, options) { 19 | req.call(_this, options); 20 | return [path, options]; 21 | }, 22 | requestError: err => { 23 | req.call(_this, err.request); 24 | return Promise.reject(err); 25 | }, 26 | response: response => { 27 | res.call(_this, response); 28 | return response; 29 | }, 30 | responseError: err => { 31 | res.call(_this, err.response); 32 | return Promise.reject(err); 33 | } 34 | }); 35 | }, 36 | invalidToken: res => { 37 | if (res.status === 401) { 38 | return true; 39 | } 40 | }, 41 | httpData: res => { 42 | return res.body || {}; 43 | }, 44 | http: function (data) { 45 | return this.plugins.http[data.method.toLowerCase()](data.url, data); 46 | }, 47 | getHeaders: res => { 48 | return res.headers; 49 | }, 50 | setHeaders: (req, headers) => { 51 | req.headers = Object.assign({}, req.headers, headers); 52 | } 53 | }; 54 | 55 | module.exports = frisbee_1_x; 56 | -------------------------------------------------------------------------------- /dist/drivers/http/frisbee.1.x.esm.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | var frisbee_1_x = { 8 | init: function () { 9 | if (!this.plugins.http) { 10 | return 'drivers/http/frisbee.js: http plugin has not been set.'; 11 | } 12 | }, 13 | interceptor: function (req, res) { 14 | var _this = this; 15 | this.plugins.http.interceptor.register({ 16 | request: function (path, options) { 17 | req.call(_this, options); 18 | return [path, options]; 19 | }, 20 | requestError: err => { 21 | req.call(_this, err.request); 22 | return Promise.reject(err); 23 | }, 24 | response: response => { 25 | res.call(_this, response); 26 | return response; 27 | }, 28 | responseError: err => { 29 | res.call(_this, err.response); 30 | return Promise.reject(err); 31 | } 32 | }); 33 | }, 34 | invalidToken: res => { 35 | if (res.status === 401) { 36 | return true; 37 | } 38 | }, 39 | httpData: res => { 40 | return res.body || {}; 41 | }, 42 | http: function (data) { 43 | return this.plugins.http[data.method.toLowerCase()](data.url, data); 44 | }, 45 | getHeaders: res => { 46 | return res.headers; 47 | }, 48 | setHeaders: (req, headers) => { 49 | req.headers = Object.assign({}, req.headers, headers); 50 | } 51 | }; 52 | 53 | export default frisbee_1_x; 54 | -------------------------------------------------------------------------------- /dist/drivers/http/frisbee.1.x.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | (function (global, factory) { 8 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : 9 | typeof define === 'function' && define.amd ? define(factory) : 10 | (global.VueAuth = factory()); 11 | }(this, (function () { 'use strict'; 12 | 13 | var frisbee_1_x = { 14 | init: function () { 15 | if (!this.plugins.http) { 16 | return 'drivers/http/frisbee.js: http plugin has not been set.'; 17 | } 18 | }, 19 | interceptor: function (req, res) { 20 | var _this = this; 21 | this.plugins.http.interceptor.register({ 22 | request: function (path, options) { 23 | req.call(_this, options); 24 | return [path, options]; 25 | }, 26 | requestError: err => { 27 | req.call(_this, err.request); 28 | return Promise.reject(err); 29 | }, 30 | response: response => { 31 | res.call(_this, response); 32 | return response; 33 | }, 34 | responseError: err => { 35 | res.call(_this, err.response); 36 | return Promise.reject(err); 37 | } 38 | }); 39 | }, 40 | invalidToken: res => { 41 | if (res.status === 401) { 42 | return true; 43 | } 44 | }, 45 | httpData: res => { 46 | return res.body || {}; 47 | }, 48 | http: function (data) { 49 | return this.plugins.http[data.method.toLowerCase()](data.url, data); 50 | }, 51 | getHeaders: res => { 52 | return res.headers; 53 | }, 54 | setHeaders: (req, headers) => { 55 | req.headers = Object.assign({}, req.headers, headers); 56 | } 57 | }; 58 | 59 | return frisbee_1_x; 60 | 61 | }))); 62 | -------------------------------------------------------------------------------- /dist/drivers/http/frisbee.1.x.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.VueAuth=t()}(this,function(){"use strict";return{init:function(){if(!this.plugins.http)return"drivers/http/frisbee.js: http plugin has not been set."},interceptor:function(r,t){var s=this;this.plugins.http.interceptor.register({request:function(e,t){return r.call(s,t),[e,t]},requestError:e=>(r.call(s,e.request),Promise.reject(e)),response:e=>(t.call(s,e),e),responseError:e=>(t.call(s,e.response),Promise.reject(e))})},invalidToken:e=>{if(401===e.status)return!0},httpData:e=>e.body||{},http:function(e){return this.plugins.http[e.method.toLowerCase()](e.url,e)},getHeaders:e=>e.headers,setHeaders:(e,t)=>{e.headers=Object.assign({},e.headers,t)}}}); -------------------------------------------------------------------------------- /dist/drivers/http/vue-resource.1.x.common.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | 'use strict'; 8 | 9 | var vueResource_1_x = { 10 | init: function () { 11 | if (!this.plugins.http) { 12 | return 'drivers/http/vue-resource.1.x.js: http plugin has not been set.'; 13 | } 14 | }, 15 | interceptor: function (req, res) { 16 | var _this = this; 17 | this.plugins.http.interceptors.push(function (request, next) { 18 | if (req) { 19 | req.call(_this, request); 20 | } 21 | next(function (response) { 22 | if (res) { 23 | res.call(_this, response, request); 24 | } 25 | }); 26 | }); 27 | }, 28 | invalidToken: function (res) { 29 | if (res.status === 401) { 30 | return true; 31 | } 32 | }, 33 | httpData: function (res) { 34 | return res.data || {}; 35 | }, 36 | http: function (data) { 37 | return this.plugins.http(data); 38 | }, 39 | getHeaders: function (res) { 40 | var i, 41 | data = {}, 42 | headers = res.headers.map; 43 | for (i in headers) { 44 | data[i] = headers[i][0]; 45 | } 46 | return data; 47 | }, 48 | setHeaders: function (req, headers) { 49 | var i; 50 | for (i in headers) { 51 | req.headers.set(i, headers[i]); 52 | } 53 | } 54 | }; 55 | 56 | module.exports = vueResource_1_x; 57 | -------------------------------------------------------------------------------- /dist/drivers/http/vue-resource.1.x.esm.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | var vueResource_1_x = { 8 | init: function () { 9 | if (!this.plugins.http) { 10 | return 'drivers/http/vue-resource.1.x.js: http plugin has not been set.'; 11 | } 12 | }, 13 | interceptor: function (req, res) { 14 | var _this = this; 15 | this.plugins.http.interceptors.push(function (request, next) { 16 | if (req) { 17 | req.call(_this, request); 18 | } 19 | next(function (response) { 20 | if (res) { 21 | res.call(_this, response, request); 22 | } 23 | }); 24 | }); 25 | }, 26 | invalidToken: function (res) { 27 | if (res.status === 401) { 28 | return true; 29 | } 30 | }, 31 | httpData: function (res) { 32 | return res.data || {}; 33 | }, 34 | http: function (data) { 35 | return this.plugins.http(data); 36 | }, 37 | getHeaders: function (res) { 38 | var i, 39 | data = {}, 40 | headers = res.headers.map; 41 | for (i in headers) { 42 | data[i] = headers[i][0]; 43 | } 44 | return data; 45 | }, 46 | setHeaders: function (req, headers) { 47 | var i; 48 | for (i in headers) { 49 | req.headers.set(i, headers[i]); 50 | } 51 | } 52 | }; 53 | 54 | export default vueResource_1_x; 55 | -------------------------------------------------------------------------------- /dist/drivers/http/vue-resource.1.x.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | (function (global, factory) { 8 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : 9 | typeof define === 'function' && define.amd ? define(factory) : 10 | (global.VueAuth = factory()); 11 | }(this, (function () { 'use strict'; 12 | 13 | var vueResource_1_x = { 14 | init: function () { 15 | if (!this.plugins.http) { 16 | return 'drivers/http/vue-resource.1.x.js: http plugin has not been set.'; 17 | } 18 | }, 19 | interceptor: function (req, res) { 20 | var _this = this; 21 | this.plugins.http.interceptors.push(function (request, next) { 22 | if (req) { 23 | req.call(_this, request); 24 | } 25 | next(function (response) { 26 | if (res) { 27 | res.call(_this, response, request); 28 | } 29 | }); 30 | }); 31 | }, 32 | invalidToken: function (res) { 33 | if (res.status === 401) { 34 | return true; 35 | } 36 | }, 37 | httpData: function (res) { 38 | return res.data || {}; 39 | }, 40 | http: function (data) { 41 | return this.plugins.http(data); 42 | }, 43 | getHeaders: function (res) { 44 | var i, 45 | data = {}, 46 | headers = res.headers.map; 47 | for (i in headers) { 48 | data[i] = headers[i][0]; 49 | } 50 | return data; 51 | }, 52 | setHeaders: function (req, headers) { 53 | var i; 54 | for (i in headers) { 55 | req.headers.set(i, headers[i]); 56 | } 57 | } 58 | }; 59 | 60 | return vueResource_1_x; 61 | 62 | }))); 63 | -------------------------------------------------------------------------------- /dist/drivers/http/vue-resource.1.x.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | !function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):t.VueAuth=n()}(this,function(){"use strict";return{init:function(){if(!this.plugins.http)return"drivers/http/vue-resource.1.x.js: http plugin has not been set."},interceptor:function(e,i){var r=this;this.plugins.http.interceptors.push(function(n,t){e&&e.call(r,n),t(function(t){i&&i.call(r,t,n)})})},invalidToken:function(t){if(401===t.status)return!0},httpData:function(t){return t.data||{}},http:function(t){return this.plugins.http(t)},getHeaders:function(t){var n,e={},i=t.headers.map;for(n in i)e[n]=i[n][0];return e},setHeaders:function(t,n){for(var e in n)t.headers.set(e,n[e])}}}); -------------------------------------------------------------------------------- /dist/drivers/oauth2/facebook.common.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | 'use strict'; 8 | 9 | var facebook = { 10 | url: 'https://www.facebook.com/v2.5/dialog/oauth', 11 | params: { 12 | client_id: '', 13 | redirect_uri: 'login/facebook', 14 | response_type: 'code', 15 | scope: 'email', 16 | state: {} 17 | } 18 | }; 19 | 20 | module.exports = facebook; 21 | -------------------------------------------------------------------------------- /dist/drivers/oauth2/facebook.esm.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | var facebook = { 8 | url: 'https://www.facebook.com/v2.5/dialog/oauth', 9 | params: { 10 | client_id: '', 11 | redirect_uri: 'login/facebook', 12 | response_type: 'code', 13 | scope: 'email', 14 | state: {} 15 | } 16 | }; 17 | 18 | export default facebook; 19 | -------------------------------------------------------------------------------- /dist/drivers/oauth2/facebook.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | (function (global, factory) { 8 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : 9 | typeof define === 'function' && define.amd ? define(factory) : 10 | (global.VueAuth = factory()); 11 | }(this, (function () { 'use strict'; 12 | 13 | var facebook = { 14 | url: 'https://www.facebook.com/v2.5/dialog/oauth', 15 | params: { 16 | client_id: '', 17 | redirect_uri: 'login/facebook', 18 | response_type: 'code', 19 | scope: 'email', 20 | state: {} 21 | } 22 | }; 23 | 24 | return facebook; 25 | 26 | }))); 27 | -------------------------------------------------------------------------------- /dist/drivers/oauth2/facebook.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | !function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define(o):e.VueAuth=o()}(this,function(){"use strict";return{url:"https://www.facebook.com/v2.5/dialog/oauth",params:{client_id:"",redirect_uri:"login/facebook",response_type:"code",scope:"email",state:{}}}}); -------------------------------------------------------------------------------- /dist/drivers/oauth2/google.common.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | 'use strict'; 8 | 9 | var google = { 10 | url: 'https://accounts.google.com/o/oauth2/auth', 11 | params: { 12 | client_id: '', 13 | redirect_uri: 'login/google', 14 | response_type: 'code', 15 | scope: 'email', 16 | state: {} 17 | } 18 | }; 19 | 20 | module.exports = google; 21 | -------------------------------------------------------------------------------- /dist/drivers/oauth2/google.esm.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | var google = { 8 | url: 'https://accounts.google.com/o/oauth2/auth', 9 | params: { 10 | client_id: '', 11 | redirect_uri: 'login/google', 12 | response_type: 'code', 13 | scope: 'email', 14 | state: {} 15 | } 16 | }; 17 | 18 | export default google; 19 | -------------------------------------------------------------------------------- /dist/drivers/oauth2/google.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | (function (global, factory) { 8 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : 9 | typeof define === 'function' && define.amd ? define(factory) : 10 | (global.VueAuth = factory()); 11 | }(this, (function () { 'use strict'; 12 | 13 | var google = { 14 | url: 'https://accounts.google.com/o/oauth2/auth', 15 | params: { 16 | client_id: '', 17 | redirect_uri: 'login/google', 18 | response_type: 'code', 19 | scope: 'email', 20 | state: {} 21 | } 22 | }; 23 | 24 | return google; 25 | 26 | }))); 27 | -------------------------------------------------------------------------------- /dist/drivers/oauth2/google.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.VueAuth=t()}(this,function(){"use strict";return{url:"https://accounts.google.com/o/oauth2/auth",params:{client_id:"",redirect_uri:"login/google",response_type:"code",scope:"email",state:{}}}}); -------------------------------------------------------------------------------- /dist/drivers/router/vue-router.2.x.common.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | 'use strict'; 8 | 9 | var vueRouter_2_x = { 10 | init: function () { 11 | if (!this.plugins.router) { 12 | return 'drivers/router/vue-router.2.x.js: router plugin has not been set.'; 13 | } 14 | }, 15 | beforeEach: function (routerBeforeEach, transitionEach, setTransitions, getAuthMeta) { 16 | var _this = this; 17 | this.plugins.router.beforeEach(function (transition, location, next) { 18 | setTransitions(transition); 19 | routerBeforeEach.call(_this, function () { 20 | var auth = getAuthMeta(transition); 21 | transitionEach.call(_this, transition, auth, function (redirect) { 22 | if (!redirect) { 23 | (next || transition.next)(); 24 | return; 25 | } 26 | 27 | // router v2.x 28 | if (next) { 29 | next(redirect); 30 | } else { 31 | this.router._routerReplace.call(this, redirect); 32 | } 33 | }); 34 | }); 35 | }); 36 | }, 37 | routerReplace: function (data) { 38 | this.plugins.router.replace.call(router, data); 39 | }, 40 | routerGo: function (data) { 41 | var router = this.plugins.router; 42 | (router.push || router.go).call(router, data).catch(function (err) {}); 43 | } 44 | }; 45 | 46 | module.exports = vueRouter_2_x; 47 | -------------------------------------------------------------------------------- /dist/drivers/router/vue-router.2.x.esm.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | var vueRouter_2_x = { 8 | init: function () { 9 | if (!this.plugins.router) { 10 | return 'drivers/router/vue-router.2.x.js: router plugin has not been set.'; 11 | } 12 | }, 13 | beforeEach: function (routerBeforeEach, transitionEach, setTransitions, getAuthMeta) { 14 | var _this = this; 15 | this.plugins.router.beforeEach(function (transition, location, next) { 16 | setTransitions(transition); 17 | routerBeforeEach.call(_this, function () { 18 | var auth = getAuthMeta(transition); 19 | transitionEach.call(_this, transition, auth, function (redirect) { 20 | if (!redirect) { 21 | (next || transition.next)(); 22 | return; 23 | } 24 | 25 | // router v2.x 26 | if (next) { 27 | next(redirect); 28 | } else { 29 | this.router._routerReplace.call(this, redirect); 30 | } 31 | }); 32 | }); 33 | }); 34 | }, 35 | routerReplace: function (data) { 36 | this.plugins.router.replace.call(router, data); 37 | }, 38 | routerGo: function (data) { 39 | var router = this.plugins.router; 40 | (router.push || router.go).call(router, data).catch(function (err) {}); 41 | } 42 | }; 43 | 44 | export default vueRouter_2_x; 45 | -------------------------------------------------------------------------------- /dist/drivers/router/vue-router.2.x.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | (function (global, factory) { 8 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : 9 | typeof define === 'function' && define.amd ? define(factory) : 10 | (global.VueAuth = factory()); 11 | }(this, (function () { 'use strict'; 12 | 13 | var vueRouter_2_x = { 14 | init: function () { 15 | if (!this.plugins.router) { 16 | return 'drivers/router/vue-router.2.x.js: router plugin has not been set.'; 17 | } 18 | }, 19 | beforeEach: function (routerBeforeEach, transitionEach, setTransitions, getAuthMeta) { 20 | var _this = this; 21 | this.plugins.router.beforeEach(function (transition, location, next) { 22 | setTransitions(transition); 23 | routerBeforeEach.call(_this, function () { 24 | var auth = getAuthMeta(transition); 25 | transitionEach.call(_this, transition, auth, function (redirect) { 26 | if (!redirect) { 27 | (next || transition.next)(); 28 | return; 29 | } 30 | 31 | // router v2.x 32 | if (next) { 33 | next(redirect); 34 | } else { 35 | this.router._routerReplace.call(this, redirect); 36 | } 37 | }); 38 | }); 39 | }); 40 | }, 41 | routerReplace: function (data) { 42 | this.plugins.router.replace.call(router, data); 43 | }, 44 | routerGo: function (data) { 45 | var router = this.plugins.router; 46 | (router.push || router.go).call(router, data).catch(function (err) {}); 47 | } 48 | }; 49 | 50 | return vueRouter_2_x; 51 | 52 | }))); 53 | -------------------------------------------------------------------------------- /dist/drivers/router/vue-router.2.x.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.VueAuth=t()}(this,function(){"use strict";return{init:function(){if(!this.plugins.router)return"drivers/router/vue-router.2.x.js: router plugin has not been set."},beforeEach:function(n,u,o,i){var c=this;this.plugins.router.beforeEach(function(t,e,r){o(t),n.call(c,function(){var e=i(t);u.call(c,t,e,function(e){e?r?r(e):this.router._routerReplace.call(this,e):(r||t.next)()})})})},routerReplace:function(e){this.plugins.router.replace.call(router,e)},routerGo:function(e){var t=this.plugins.router;(t.push||t.go).call(t,e).catch(function(e){})}}}); -------------------------------------------------------------------------------- /dist/v2/vue-auth.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * @websanova/vue-auth v4.2.1 3 | * https://websanova.com/docs/vue-auth 4 | * Released under the MIT License. 5 | */ 6 | 7 | !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.VueAuth=e()}(this,function(){"use strict";function s(t){return null!==t&&"object"==typeof t&&t.constructor!==Array}function c(t){return"string"==typeof t||"number"==typeof t?[t]:t}function u(t,e){var n,r,o,i={};for(o in e=e||{},t)s(t[o])&&"FormData"!==t[o].constructor.name?i[o]=u(t[o],{}):i[o]=t[o];for(n=0,r=(e=e.constructor!==Array?[e]:e).length;n{n.push(t+"="+encodeURIComponent(e.params[t]))}),window.open(e.url+"?"+n.join("&"),(e.window||{}).name||"_self",(e.window||{}).specs||{},!1!==(e.window||{}).replace)},j.prototype.enableImpersonate=function(){v.impersonating()&&(v.currentToken=null)},j.prototype.disableImpersonate=function(){v.impersonating()&&(v.currentToken=v.options.tokenDefaultKey)},"undefined"!=typeof window&&window.Vue&&window.Vue.use(_),_}); -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "4.2.1", 3 | "name": "@websanova/vue-auth", 4 | "description": "A simple light-weight authentication library for Vue.js", 5 | "keywords": ["vue", "vue.js", "vuejs", "plugin", "jwt", "auth", "authentication", "authorize", "authenticate", "bearer", "basic", "axios", "http", "api", "json", "web", "token"], 6 | "homepage": "https://websanova.com/docs/vue-auth", 7 | "author": { 8 | "name": "Websanova", 9 | "url": "http://websanova.com", 10 | "username": "websanova", 11 | "email": "rob@websanova.com" 12 | }, 13 | "main": "dist/v3/vue-auth.common.js", 14 | "module": "dist/v3/vue-auth.esm.js", 15 | "unpkg": "dist/v3/vue-auth.min.js", 16 | "jsdelivr": "dist/v3/vue-auth.min.js", 17 | 18 | "types": "types/index.d.ts", 19 | "repository": { 20 | "type": "git", 21 | "url": "https://github.com/websanova/vue-auth" 22 | }, 23 | "license": "(MIT OR GPL)", 24 | "scripts": { 25 | "clear": "rm -rf dist/*", 26 | "build": "npm run clear; node build/build.js", 27 | "test-ts": "./node_modules/typescript/bin/tsc ./build/ts-test.js --allowJS --outDir ./tmp" 28 | }, 29 | "devDependencies": { 30 | "typescript": "4.0.3", 31 | "@babel/core": "^7.2.2", 32 | "@babel/preset-env": "^7.2.0", 33 | "babel-loader": "^8.0.4", 34 | "uglify-js": "^3.4.9", 35 | "rollup": "^0.66.0", 36 | "rollup-plugin-babel": "^4.1.0", 37 | "rollup-plugin-replace": "^2.1.0" 38 | } 39 | } -------------------------------------------------------------------------------- /src/drivers/auth/basic.js: -------------------------------------------------------------------------------- 1 | export default { 2 | 3 | request: function (req, token) { 4 | this.drivers.http.setHeaders.call(this, req, { 5 | Authorization: token 6 | }); 7 | }, 8 | 9 | response: function (res) { 10 | var headers = this.drivers.http.getHeaders.call(this, res), 11 | token = headers.Authorization || headers.authorization; 12 | 13 | return token; 14 | } 15 | }; -------------------------------------------------------------------------------- /src/drivers/auth/bearer.js: -------------------------------------------------------------------------------- 1 | export default { 2 | 3 | request: function (req, token) { 4 | this.drivers.http.setHeaders.call(this, req, { 5 | Authorization: 'Bearer ' + token 6 | }); 7 | }, 8 | 9 | response: function (res) { 10 | var headers = this.drivers.http.getHeaders.call(this, res), 11 | token = headers.Authorization || headers.authorization; 12 | 13 | if (token) { 14 | token = token.split(/Bearer:?\s?/i); 15 | 16 | return token[token.length > 1 ? 1 : 0].trim(); 17 | } 18 | } 19 | }; -------------------------------------------------------------------------------- /src/drivers/auth/devise.js: -------------------------------------------------------------------------------- 1 | export default { 2 | 3 | tokens: [ 4 | 'Token-Type', 'Access-Token', 'Client', 'Uid', 'Expiry', 5 | 'token-type', 'access-token', 'client', 'uid', 'expiry' 6 | ], 7 | 8 | request: function (req, token) { 9 | var headers = {}, 10 | tokens = token.split('|'); 11 | 12 | var auth = this.drivers.deviseAuth || this.drivers.auth; 13 | 14 | auth.tokens.forEach(function (tokenName, index) { 15 | if (tokens[index]) { 16 | headers[tokenName] = tokens[index]; 17 | } 18 | }); 19 | 20 | this.drivers.http.setHeaders.call(this, req, headers); 21 | }, 22 | 23 | response: function (res) { 24 | var token = [], 25 | headers = this.drivers.http.getHeaders.call(this, res); 26 | 27 | if (headers['access-token'] || headers['Access-Token']) { 28 | var auth = this.drivers.deviseAuth || this.drivers.auth; 29 | 30 | auth.tokens.forEach(function (tokenName) { 31 | if (headers[tokenName]) { 32 | token.push(headers[tokenName]); 33 | } 34 | }); 35 | 36 | // Check if access-token more recent than last one 37 | if (!this.token() || parseInt(token[4], 10) >= parseInt(this.token().split('|')[4], 10)) { 38 | return token.join('|'); 39 | } 40 | } 41 | } 42 | }; -------------------------------------------------------------------------------- /src/drivers/http/axios.1.x.js: -------------------------------------------------------------------------------- 1 | export default { 2 | 3 | init: function () { 4 | if ( ! this.plugins.http) { 5 | return 'drivers/http/axios.js: http plugin has not been set.' 6 | } 7 | }, 8 | 9 | interceptor: function (req, res) { 10 | var _this = this; 11 | 12 | if (req) { 13 | this.plugins.http.interceptors.request.use(function (request) { 14 | req.call(_this, request); 15 | 16 | return request; 17 | }, function (error) { 18 | req.call(_this, error.request); 19 | 20 | return Promise.reject(error); 21 | }); 22 | } 23 | 24 | if (res) { 25 | this.plugins.http.interceptors.response.use(function (response) { 26 | res.call(_this, response); 27 | 28 | return response; 29 | }, function (error) { 30 | if (error && error.response) { 31 | res.call(_this, error.response); 32 | } 33 | 34 | return Promise.reject(error); 35 | }); 36 | } 37 | }, 38 | 39 | invalidToken: function (res) { 40 | if (res.status === 401) { 41 | return true; 42 | } 43 | }, 44 | 45 | httpData: function (res) { 46 | return res.data || {}; 47 | }, 48 | 49 | http: function (data) { 50 | return this.plugins.http(data); 51 | }, 52 | 53 | getHeaders: function (res) { 54 | return res.headers; 55 | }, 56 | 57 | setHeaders: function (req, headers) { 58 | req.headers = Object.assign({}, req.headers, headers); 59 | } 60 | } -------------------------------------------------------------------------------- /src/drivers/http/frisbee.1.x.js: -------------------------------------------------------------------------------- 1 | export default { 2 | 3 | init: function () { 4 | if ( ! this.plugins.http) { 5 | return 'drivers/http/frisbee.js: http plugin has not been set.' 6 | } 7 | }, 8 | 9 | interceptor: function (req, res) { 10 | var _this = this; 11 | 12 | this.plugins.http.interceptor.register({ 13 | request: function (path, options) { 14 | req.call(_this, options); 15 | 16 | return [path, options]; 17 | }, 18 | requestError: err => { 19 | req.call(_this, err.request); 20 | 21 | return Promise.reject(err); 22 | }, 23 | response: response => { 24 | res.call(_this, response); 25 | 26 | return response; 27 | }, 28 | responseError: err => { 29 | res.call(_this, err.response); 30 | 31 | return Promise.reject(err); 32 | } 33 | }); 34 | }, 35 | 36 | invalidToken: res => { 37 | if (res.status === 401) { 38 | return true; 39 | } 40 | }, 41 | 42 | httpData: res => { 43 | return res.body || {}; 44 | }, 45 | 46 | http: function (data) { 47 | return this.plugins.http[data.method.toLowerCase()](data.url, data); 48 | }, 49 | 50 | getHeaders: res => { 51 | return res.headers; 52 | }, 53 | 54 | setHeaders: (req, headers) => { 55 | req.headers = Object.assign({}, req.headers, headers); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/drivers/http/vue-resource.1.x.js: -------------------------------------------------------------------------------- 1 | export default { 2 | 3 | init: function () { 4 | if ( ! this.plugins.http) { 5 | return 'drivers/http/vue-resource.1.x.js: http plugin has not been set.'; 6 | } 7 | }, 8 | 9 | interceptor: function (req, res) { 10 | var _this = this; 11 | 12 | this.plugins.http.interceptors.push(function (request, next) { 13 | if (req) { req.call(_this, request); } 14 | 15 | next(function (response) { 16 | if (res) { res.call(_this, response, request); } 17 | }); 18 | }); 19 | }, 20 | 21 | invalidToken: function (res) { 22 | if (res.status === 401) { 23 | return true; 24 | } 25 | }, 26 | 27 | httpData: function (res) { 28 | return res.data || {}; 29 | }, 30 | 31 | http: function (data) { 32 | return this.plugins.http(data); 33 | }, 34 | 35 | getHeaders: function (res) { 36 | var i, 37 | data = {}, 38 | headers = res.headers.map; 39 | 40 | for (i in headers) { 41 | data[i] = headers[i][0]; 42 | } 43 | 44 | return data; 45 | }, 46 | 47 | setHeaders: function (req, headers) { 48 | var i; 49 | 50 | for (i in headers) { 51 | req.headers.set(i, headers[i]); 52 | } 53 | } 54 | }; -------------------------------------------------------------------------------- /src/drivers/oauth2/auth0.js: -------------------------------------------------------------------------------- 1 | export default { 2 | url: '', 3 | 4 | params: { 5 | client_id: '', 6 | redirect_uri: 'login/auth0', 7 | response_type: 'code', 8 | scope: 'openid profile email', 9 | state: {}, 10 | } 11 | } -------------------------------------------------------------------------------- /src/drivers/oauth2/facebook.js: -------------------------------------------------------------------------------- 1 | export default { 2 | url: 'https://www.facebook.com/v2.5/dialog/oauth', 3 | 4 | params: { 5 | client_id: '', 6 | redirect_uri: 'login/facebook', 7 | response_type: 'code', 8 | scope: 'email', 9 | state: {}, 10 | } 11 | } -------------------------------------------------------------------------------- /src/drivers/oauth2/google.js: -------------------------------------------------------------------------------- 1 | export default { 2 | url: 'https://accounts.google.com/o/oauth2/auth', 3 | 4 | params: { 5 | client_id: '', 6 | redirect_uri: 'login/google', 7 | response_type: 'code', 8 | scope: 'email', 9 | state: {}, 10 | } 11 | } -------------------------------------------------------------------------------- /src/drivers/router/vue-router.2.x.js: -------------------------------------------------------------------------------- 1 | export default { 2 | 3 | init: function () { 4 | if ( ! this.plugins.router) { 5 | return 'drivers/router/vue-router.2.x.js: router plugin has not been set.'; 6 | } 7 | }, 8 | 9 | beforeEach: function (routerBeforeEach, transitionEach, setTransitions, getAuthMeta) { 10 | var _this = this; 11 | 12 | this.plugins.router.beforeEach(function (transition, location, next) { 13 | setTransitions(transition); 14 | 15 | routerBeforeEach.call(_this, function () { 16 | var auth = getAuthMeta(transition); 17 | 18 | transitionEach.call(_this, transition, auth, function (redirect) { 19 | if (!redirect) { 20 | (next || transition.next)(); 21 | return; 22 | } 23 | 24 | // router v2.x 25 | if (next) { 26 | next(redirect); 27 | } else { 28 | this.router._routerReplace.call(this, redirect); 29 | } 30 | }); 31 | }); 32 | }) 33 | }, 34 | 35 | routerReplace: function (data) { 36 | this.plugins.router.replace.call(router, data); 37 | }, 38 | 39 | routerGo: function (data) { 40 | var router = this.plugins.router; 41 | 42 | (router.push || router.go).call(router, data).catch(function (err){}); 43 | } 44 | }; -------------------------------------------------------------------------------- /src/lib/cookie.js: -------------------------------------------------------------------------------- 1 | function setCookie (key, value, params) { 2 | var i, 3 | cookie = key + '=' + value + ';'; 4 | 5 | for (i in params) { 6 | 7 | // Just skip if unset or false. 8 | if (params[i] === false || params[i] === undefined) { 9 | continue; 10 | } 11 | 12 | // If null and an option method exists such ex: "getCookieDomain". 13 | else if (params[i] === null) { 14 | if (this.options['getCookie' + i]) { 15 | cookie += ' ' + i + '=' + this.options['getCookie' + i]() + ';'; 16 | } 17 | } 18 | 19 | // If true just set the flag as in "Secure;". 20 | else if (params[i] === true) { 21 | cookie += ' ' + i + ';'; 22 | } 23 | 24 | // Default key/val. 25 | else { 26 | cookie += ' ' + i + '=' + params[i] + ';'; 27 | } 28 | } 29 | 30 | document.cookie = cookie; 31 | } 32 | 33 | function getDate(val) { 34 | if (typeof val === 'string') { 35 | return val; 36 | } 37 | else if (val !== null && val !== undefined) { 38 | return (new Date((new Date()).getTime() + val)).toUTCString(); 39 | } 40 | 41 | return val; 42 | } 43 | 44 | function set(key, value, expires) { 45 | var params = this.options.cookie; 46 | 47 | params.Expires = expires === true ? '' : getDate(params.Expires); 48 | 49 | setCookie.call(this, key, value, params); 50 | } 51 | 52 | function get(key) { 53 | var i, ii, 54 | cookie = document.cookie; 55 | 56 | cookie = cookie 57 | .replace(/;\s+/g, ';') 58 | .split(';') 59 | .map(function(s) { 60 | return s.replace(/\s+=\s+/g, '=').split('='); 61 | }); 62 | 63 | for (i = 0, ii = cookie.length; i < ii; i++) { 64 | if (cookie[i][0] && cookie[i][0] === key) { 65 | return cookie[i][1]; 66 | } 67 | } 68 | 69 | return null; 70 | } 71 | 72 | function remove(key) { 73 | var params = Object.assign({}, this.options.cookie); 74 | 75 | params.Expires = getDate(-12096e5); 76 | 77 | setCookie.call(this, key, '', params); 78 | } 79 | 80 | export { 81 | get, 82 | set, 83 | remove 84 | }; 85 | -------------------------------------------------------------------------------- /src/lib/storage.js: -------------------------------------------------------------------------------- 1 | function set(key, value, expires) { 2 | if (expires) { 3 | sessionStorage.setItem(key, value); 4 | } 5 | else { 6 | localStorage.setItem(key, value); 7 | } 8 | } 9 | 10 | function get(key) { 11 | return sessionStorage.getItem(key) || localStorage.getItem(key); 12 | } 13 | 14 | function remove(key) { 15 | localStorage.removeItem(key); 16 | sessionStorage.removeItem(key); 17 | } 18 | 19 | export { 20 | get, 21 | set, 22 | remove, 23 | }; -------------------------------------------------------------------------------- /src/lib/token.js: -------------------------------------------------------------------------------- 1 | import * as __utils from './utils.js'; 2 | import * as __cookie from './cookie.js'; 3 | import * as __storage from './storage.js'; 4 | 5 | function getTokenKey(key) { 6 | key = key || this.currentToken; 7 | 8 | if (key) { 9 | return key; 10 | } 11 | 12 | if (this.impersonating()) { 13 | return this.options.tokenImpersonateKey; 14 | } 15 | 16 | return this.options.tokenDefaultKey; 17 | } 18 | 19 | function processToken(action, key, token, expires) { 20 | var i = 0, 21 | ts = this.options.stores, 22 | ii = ts.length, 23 | args = [getTokenKey.call(this, key)]; 24 | 25 | if (action === 'set') { 26 | args.push(token); 27 | args.push(expires === true ? true : false); 28 | } 29 | 30 | for (; i < ii; i++) { 31 | if (typeof(ts[i][action]) === 'function') { 32 | return ts[i][action].apply(this, args); 33 | } 34 | 35 | if ( 36 | ts[i] === 'storage' && 37 | __utils.isLocalStorage() && 38 | __utils.isSessionStorage() 39 | ) { 40 | return __storage[action].apply(this, args); 41 | } 42 | 43 | if ( 44 | ts[i] === 'cookie' && 45 | __utils.isCookieStorage() 46 | ) { 47 | return __cookie[action].apply(this, args); 48 | } 49 | } 50 | } 51 | 52 | function get(key) { 53 | return processToken.call(this, 'get', key); 54 | } 55 | 56 | function set(key, token, expires) { 57 | return processToken.call(this, 'set', key, token, expires); 58 | } 59 | 60 | function remove(key) { 61 | return processToken.call(this, 'remove', key); 62 | } 63 | 64 | export { 65 | get, 66 | set, 67 | remove 68 | }; 69 | -------------------------------------------------------------------------------- /src/lib/utils.js: -------------------------------------------------------------------------------- 1 | function isObject(val) { 2 | if (val !== null && typeof val === 'object' && val.constructor !== Array ) { 3 | return true; 4 | } 5 | 6 | return false; 7 | } 8 | 9 | function toArray(val) { 10 | return (typeof val) === 'string' || (typeof val) === 'number' ? [val] : val; 11 | } 12 | 13 | function extend(mainObj, appendObj) { 14 | var i, ii, key, data = {}; 15 | 16 | appendObj = appendObj || {}; 17 | 18 | for (key in mainObj) { 19 | if (isObject(mainObj[key]) && mainObj[key].constructor.name !== 'FormData') { 20 | data[key] = extend(mainObj[key], {}); 21 | } 22 | else { 23 | data[key] = mainObj[key]; 24 | } 25 | } 26 | 27 | if (appendObj.constructor !== Array) { 28 | appendObj = [appendObj]; 29 | } 30 | 31 | for (i = 0, ii = appendObj.length; i < ii; i++) { 32 | for (key in appendObj[i]) { 33 | if (isObject(appendObj[i][key]) && appendObj[i][key].constructor.name !== 'FormData') { 34 | data[key] = extend(mainObj[key] || {}, [appendObj[i][key]]); 35 | } 36 | else { 37 | data[key] = appendObj[i][key]; 38 | } 39 | } 40 | } 41 | 42 | return data; 43 | } 44 | 45 | function compare(one, two) { 46 | var i, ii, key; 47 | 48 | if (Object.prototype.toString.call(one) === '[object Object]' && Object.prototype.toString.call(two) === '[object Object]') { 49 | for (key in one) { 50 | if (compare(one[key], two[key])) { 51 | return true; 52 | } 53 | } 54 | 55 | return false; 56 | } 57 | 58 | one = toArray(one); 59 | two = toArray(two); 60 | 61 | if (!one || !two || one.constructor !== Array || two.constructor !== Array) { 62 | return false; 63 | } 64 | 65 | for (i = 0, ii = one.length; i < ii; i++) { 66 | if (two.indexOf(one[i]) >= 0) { 67 | return true; 68 | } 69 | } 70 | 71 | return false; 72 | } 73 | 74 | function isLocalStorage() { 75 | try { 76 | if (!window.localStorage) { 77 | throw 'exception'; 78 | } 79 | 80 | localStorage.setItem('storage_test', 1); 81 | localStorage.removeItem('storage_test'); 82 | 83 | return true; 84 | } catch (e) { 85 | return false; 86 | } 87 | } 88 | 89 | function isSessionStorage() { 90 | try { 91 | if (!window.sessionStorage) { 92 | throw 'exception'; 93 | } 94 | 95 | sessionStorage.setItem('storage_test', 1); 96 | sessionStorage.removeItem('storage_test'); 97 | 98 | return true; 99 | } catch (e) { 100 | return false; 101 | } 102 | } 103 | 104 | function isCookieStorage() { 105 | return true; 106 | } 107 | 108 | function getProperty (obj, desc) { 109 | var arr = desc.split('.'); 110 | 111 | while (arr.length) { 112 | obj = obj[arr.shift()]; 113 | } 114 | 115 | return obj; 116 | } 117 | 118 | export { 119 | extend, 120 | compare, 121 | toArray, 122 | isObject, 123 | isLocalStorage, 124 | isCookieStorage, 125 | isSessionStorage, 126 | getProperty, 127 | }; -------------------------------------------------------------------------------- /src/v2.js: -------------------------------------------------------------------------------- 1 | import Auth from './auth.js'; 2 | 3 | function plugin(Vue, options) { 4 | Vue.auth = new Auth(Vue, options); 5 | 6 | Object.defineProperties(Vue.prototype, { 7 | $auth: { 8 | get: function () { 9 | return Vue.auth; 10 | } 11 | } 12 | }); 13 | } 14 | 15 | if (typeof window !== 'undefined' && window.Vue) { 16 | window.Vue.use(plugin); 17 | } 18 | 19 | export default plugin; -------------------------------------------------------------------------------- /src/v3.js: -------------------------------------------------------------------------------- 1 | import {inject } from 'vue' 2 | import {reactive} from 'vue'; 3 | import Auth from './auth.js'; 4 | 5 | const authKey = 'auth'; 6 | 7 | // NOTE: Create pseudo Vue object for Vue 2 backwards compatibility. 8 | 9 | function Vue (obj) { 10 | var data = obj.data(); 11 | 12 | this.state = reactive(data.state); 13 | } 14 | 15 | Auth.prototype.install = function (app, key) { 16 | app.provide(key || authKey, this); 17 | 18 | app.config.globalProperties.$auth = this; 19 | } 20 | 21 | // 22 | 23 | export function createAuth(options) { 24 | return new Auth(Vue, options); 25 | } 26 | 27 | export function useAuth(key) { 28 | return inject(key ? key : authKey); 29 | } -------------------------------------------------------------------------------- /types/index.d.ts: -------------------------------------------------------------------------------- 1 | import {Vue} from 'vue/types/vue'; 2 | import {PluginObject} from 'vue/types'; 3 | 4 | // 5 | 6 | type Redirect = {path: string} | {name: string} | string; 7 | 8 | // 9 | 10 | interface RequestOptions { 11 | data?: {}; 12 | params?: {}; 13 | url?: string; 14 | method?: string; 15 | } 16 | 17 | interface RedirectInterface { 18 | type: string; 19 | from: any; 20 | to: any; 21 | } 22 | 23 | // 24 | 25 | interface UserInterface { 26 | // Depends on app 27 | } 28 | 29 | interface FetchOptions extends RequestOptions { 30 | redirect?: Redirect; 31 | } 32 | 33 | interface RefreshOptions extends RequestOptions { 34 | // 35 | } 36 | 37 | interface RegisterOptions extends LoginOptions { 38 | autoLogin?: boolean 39 | } 40 | 41 | interface LoginOptions extends RequestOptions { 42 | fetchUser?: boolean; 43 | staySignedIn?: boolean; 44 | remember?: string; 45 | redirect?: Redirect; 46 | } 47 | 48 | interface LogoutOptions extends RequestOptions { 49 | makeRequest?: boolean; 50 | redirect?: Redirect; 51 | } 52 | 53 | interface Oauth2Options extends RequestOptions { 54 | code?: boolean; 55 | provider?: string; 56 | redirect?: Redirect; 57 | staySignedIn?: boolean; 58 | remember?: string; 59 | fetchUser?: boolean; 60 | window?: { 61 | name?: string, 62 | specs?: any, 63 | replace?: boolean, 64 | }; 65 | } 66 | 67 | interface ImpersonateOptions extends RequestOptions { 68 | redirect?: Redirect; 69 | } 70 | 71 | interface UnimpersonateOptions extends RequestOptions { 72 | redirect?: Redirect; 73 | makeRequest?: boolean; 74 | } 75 | 76 | // 77 | 78 | interface VueAuth extends PluginObject { 79 | 80 | /** 81 | * Returns binded boolean property to know when auth is fully loaded. 82 | * 83 | * @return {boolean} 84 | */ 85 | ready(): boolean 86 | 87 | /** 88 | * Same as the the ready method to check when auth is fully loaded. 89 | * However this returns a Promise instead of a boolean to allow further 90 | * processing. Basically a shortcut for having a watch on the "ready" method. 91 | * 92 | * @return {Promise} 93 | */ 94 | load(): Promise; 95 | 96 | /** 97 | * Returns a redirect object if any redirect occurred. This happens when trying 98 | * to reach an authenticated page when logged out or forbidden. A redirect occurs 99 | * by default to the login page with the to/from redirect router reference. 100 | * 101 | * @return {any} 102 | */ 103 | redirect(): RedirectInterface; 104 | 105 | /** 106 | * Return the user data from retrieved from either the login or user fetch request. 107 | * The user data can also be set manaully by passing in an object. 108 | * 109 | * @param {any} data - Manually set user data. 110 | * @return {any} 111 | */ 112 | user(data?: any): UserInterface; 113 | 114 | /** 115 | * Check a users access access against their role in the user data that was fetched. 116 | * Can also optionally pass in a role string or object to check against for something 117 | * more specific. This is useful for toggling elements in a component for admin/user access. 118 | * 119 | * @param {any} role - Set role/privilege to check. 120 | * @param {string} key - Use a different key on the user object than the default defined in the default options. 121 | * @return {boolean} 122 | */ 123 | check(role?: any, key?: string): boolean; 124 | 125 | /** 126 | * Check if it is in impersonating mode. 127 | * 128 | * @return {boolean} 129 | */ 130 | impersonating(): boolean 131 | 132 | /** 133 | * Fetch the current token or set a new one. 134 | * 135 | * @param {string} name - Specify the token to fetch or name to set. 136 | * @param {string} token - If setting a token specify the token data/string. 137 | * @param {boolean} expires - If setting a token specify if it's expring after the session or not. 138 | * @return {string} 139 | */ 140 | token(name?: string, token?: string, expires?: boolean): string 141 | 142 | /** 143 | * Fetch the user (again) allowing the users data to be reset (from the api). 144 | * 145 | * @param {FetchOptions} option - Set of options passed to http call. 146 | * @return {Promise} 147 | */ 148 | fetch(options: FetchOptions): Promise; 149 | 150 | /** 151 | * Refresh the app token from the backend api. 152 | * The options object is passed directly to the http method. 153 | * 154 | * @param {RefreshOptions} option - Set of options passed to http call. 155 | * @return {Promise} 156 | */ 157 | refresh(options: RefreshOptions): Promise; 158 | 159 | /** 160 | * Register call. 161 | * 162 | * @param {RegisterOptions} options - Set of options passed to http call. 163 | * @return {Promise} 164 | */ 165 | register(options: RegisterOptions): Promise; 166 | 167 | /** 168 | * Login call. 169 | * 170 | * @param {LoginOptions} options - Set of options passed to http call. 171 | * @return {Promise} 172 | */ 173 | login(options: LoginOptions): Promise; 174 | 175 | /** 176 | * Store some basic data to remember a user. Useful for showing a welcome back 177 | * message when a user returns to login and is not actually logged in yet. 178 | * 179 | * Note that this is stored in either local storage or a cookie depending on the 180 | * storage type selected and should be converted to a string if setting an object. 181 | * 182 | * @param {string} val - Set of options passed to http call. 183 | * @return {string} 184 | */ 185 | remember(val?: string): string; 186 | 187 | /** 188 | * Clears the stored remember data. 189 | * 190 | * @return {void} 191 | */ 192 | unremember(): void; 193 | 194 | /** 195 | * Logout call. 196 | * 197 | * @param {LogoutOptions} options - Set of options passed to http call. 198 | * @return {Promise} 199 | */ 200 | logout(options: LogoutOptions): Promise; 201 | 202 | /** 203 | * Impersonate call. 204 | * 205 | * @param {ImpersonateOptions} options - Set of options passed to http call. 206 | * @return {Promise} 207 | */ 208 | impersonate(options: ImpersonateOptions): Promise; 209 | 210 | /** 211 | * Unimpersonate call. 212 | * 213 | * @param {UnimpersonateOptions} options - Set of options passed to http call. 214 | * @return {Promise} 215 | */ 216 | unimpersonate(options: UnimpersonateOptions): Promise; 217 | 218 | /** 219 | * Oauth2 social login call. 220 | * 221 | * @param {Oauth2Options} options - Set of options passed to http call. 222 | * @return {Promise} 223 | */ 224 | oauth2(options: Oauth2Options): Promise; 225 | oauth2(provider: string, options: Oauth2Options): Promise; 226 | 227 | /** 228 | * Disable impersonating mode. 229 | * 230 | * Useful if an admin call needs to be made while impersonating. 231 | * 232 | * @return {void} 233 | */ 234 | disableImpersonate(): void; 235 | 236 | /** 237 | * Re-enable impersonating mode. 238 | * 239 | * @return {void} 240 | */ 241 | enableImpersonate(): void; 242 | } 243 | 244 | interface VueAuthCreateOptions { 245 | plugins: any, 246 | drivers: any, 247 | options?: any, 248 | } 249 | 250 | declare function createAuth(options: VueAuthCreateOptions): VueAuth & { install: (app: unknown) => void }; 251 | 252 | declare function useAuth(key?: string): VueAuth; 253 | 254 | declare module 'vue/types/vue' { 255 | interface Vue { 256 | $auth: VueAuth; 257 | } 258 | } 259 | --------------------------------------------------------------------------------