{"_id":"@dreamonkey/vue-auth0","_rev":"3-a075b741d8b1d4b47409731f4d89cadf","name":"@dreamonkey/vue-auth0","dist-tags":{"latest":"1.0.0"},"versions":{"0.0.1":{"name":"@dreamonkey/vue-auth0","version":"0.0.1","description":"@auth0/auth0-spa-js wrapper in the 'Vue way', with full TS support","keywords":["vue","vue-router","auth0","typescript","composable","guard"],"author":{"name":"Paolo Caleffi","email":"p.caleffi@dreamonkey.com","url":"https://github.com/IlCallo"},"license":"MIT","main":"dist/index.js","repository":{"type":"git","url":"git+https://github.com/dreamonkey/vue-auth0.git"},"bugs":{"url":"https://github.com/dreamonkey/vue-auth0/issues"},"engines":{"node":">= 12.22.1","npm":">= 6.14.12","yarn":">= 1.17.3"},"dependencies":{"@vueuse/core":"^7.5.3"},"devDependencies":{"@auth0/auth0-spa-js":"^1.19.0","@babel/types":"^7.16.8","@typescript-eslint/eslint-plugin":"^5.9.1","@typescript-eslint/parser":"^5.9.1","eslint":"^8.6.0","eslint-config-prettier":"^8.3.0","prettier":"^2.5.1","rimraf":"^3.0.2","typescript":"^4.5.4","vue":"^3.2.26","vue-router":"^4.0.0"},"peerDependencies":{"@auth0/auth0-spa-js":"^1.19.0","vue":"^3.0.0","vue-router":"^4.0.0"},"peerDependenciesMeta":{"vue-router":{"optional":true}},"publishConfig":{"access":"public"},"scripts":{"lint":"eslint --ext .js,.ts,.vue ./ --fix --report-unused-disable-directives","format":"prettier --write \"**/*.{json,md,graphql,vue,js,ts}\" --ignore-path .gitignore","build":"rimraf dist && tsc --declaration","deploy":"pnpm build && pnpm publish --tag latest"},"_resolved":"","_integrity":"","_from":"file:dreamonkey-vue-auth0-0.0.1.tgz","homepage":"https://github.com/dreamonkey/vue-auth0#readme","_id":"@dreamonkey/vue-auth0@0.0.1","_nodeVersion":"12.22.8","_npmVersion":"6.14.15","dist":{"integrity":"sha512-aXLCYKLJso87HdMALNt2/0AOjkS0ODM5torwJLYXr11xg8s98kwoTN8I/hT7PWrbL+IxNshmvYsTULu+G9YziA==","shasum":"2f038df6b9977e4f3cd4927eeee69b3043126bfc","tarball":"https://registry.npmjs.org/@dreamonkey/vue-auth0/-/vue-auth0-0.0.1.tgz","fileCount":12,"unpackedSize":40437,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh3ZpzCRA9TVsSAnZWagAAYJUP/3tGigJIGL3Q4VB866Wh\nMMo09YRBOHo5Mroza+Z7urHCV8lRagxnbkEWGuuDB3PPGWj5mY8ZCJwl4z0q\nzkBiX+Kg+IWTD6Mkrbso5DwvFGNlGngZnQSBcys5n3P5r1mBYmc0n05iYXKU\np2p/8kW9cYJDeaI1NS8Ve1IbB2oZl+f5OIjJWekvo9TEFB5mpR7CnqiAuz/m\nRIadHjaNyuvwRndw4sqLYOXuGL2LaRBsfdY4f+8NX1h8xfPAP1mckFv263s0\n4C0Q6PMCZ5FL54B/L+mxlCUtETCDcVaOLb+9LegSsZB4lFg9+MXxMp5/f9CM\ne83CXOn1Ic1HrfAvTuuuioHtmGI7cZifq1Saonw8BIDRYaKNUtzhAhKWTCtr\nf363jkCGFecMtgLBvTxXkfulzW+bUZ25CsnKIaZ1Av4xmZwkq0uC3etmOowQ\nYoUgjyMesUKiTyh0ZZbpgLMYumaG2U3/23drMx3U+QgRyDXgyeiOs59fx8zz\n5f4amqLv/4I6WvwScW1ZAxsaGDx5/nNDjERp4Z9xoj30CqIKW1YD7vEKJ52X\n16N/AzSgqH8dK0dTru4GeE65r7XZy9XcUQb1oiBG1MwFyHDn6UCHxq+bSO86\nk53w0BIMmul60W0SFeBTPFwmo9pKLs9e1ZGzdBHvW/cfYg8pdbLfdJf5u77k\nbn/u\r\n=2ntP\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCnA+hQMr1vUIULo0XIIr/ZTjMiNGvupt+593UiTTHv0QIhALK/BLwfVeDt+Eg1DKk+ytMP8FupCqdtG6sOZ3QAsKvb"}]},"_npmUser":{"name":"ilcallo","email":"p.caleffi@dreamonkey.com"},"directories":{},"maintainers":[{"name":"ilcallo","email":"p.caleffi@dreamonkey.com"},{"name":"mrkappa","email":"k.borghi@dreamonkey.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vue-auth0_0.0.1_1641912947701_0.893163239419388"},"_hasShrinkwrap":false},"0.0.2":{"name":"@dreamonkey/vue-auth0","version":"0.0.2","description":"@auth0/auth0-spa-js wrapper in the 'Vue way', with full TS support","keywords":["vue","vue-router","auth0","typescript","composable","guard"],"author":{"name":"Paolo Caleffi","email":"p.caleffi@dreamonkey.com","url":"https://github.com/IlCallo"},"license":"MIT","main":"dist/index.js","repository":{"type":"git","url":"git+https://github.com/dreamonkey/vue-auth0.git"},"bugs":{"url":"https://github.com/dreamonkey/vue-auth0/issues"},"engines":{"node":">= 12.22.1","npm":">= 6.14.12","yarn":">= 1.17.3"},"dependencies":{"@vueuse/core":"^7.5.3"},"devDependencies":{"@auth0/auth0-spa-js":"^1.19.0","@babel/types":"^7.16.8","@typescript-eslint/eslint-plugin":"^5.9.1","@typescript-eslint/parser":"^5.9.1","eslint":"^8.6.0","eslint-config-prettier":"^8.3.0","prettier":"^2.5.1","rimraf":"^3.0.2","typescript":"^4.5.4","vue":"^3.2.26","vue-router":"^4.0.0"},"peerDependencies":{"@auth0/auth0-spa-js":"^1.19.0","vue":"^3.0.0","vue-router":"^4.0.0"},"peerDependenciesMeta":{"vue-router":{"optional":true}},"publishConfig":{"access":"public"},"scripts":{"lint":"eslint --ext .js,.ts,.vue ./ --fix --report-unused-disable-directives","format":"prettier --write \"**/*.{json,md,graphql,vue,js,ts}\" --ignore-path .gitignore","build":"rimraf dist && tsc --declaration","deploy":"pnpm build && pnpm publish --tag latest"},"types":"./dist/index.d.ts","homepage":"https://github.com/dreamonkey/vue-auth0#readme","_id":"@dreamonkey/vue-auth0@0.0.2","_integrity":"sha512-3Fg6jwmzSrV2GDZk2gdUFJ/k17a97xE7bnEWwvm4mZGvbvyj0M+YcM8mUKbm1/UIrPaq17Yfe8cJWXZfbk2pzw==","_resolved":"/tmp/01999e67a2670f1c1db08d69fa7b1a53/dreamonkey-vue-auth0-0.0.2.tgz","_from":"file:dreamonkey-vue-auth0-0.0.2.tgz","_nodeVersion":"16.17.0","_npmVersion":"8.15.0","dist":{"integrity":"sha512-3Fg6jwmzSrV2GDZk2gdUFJ/k17a97xE7bnEWwvm4mZGvbvyj0M+YcM8mUKbm1/UIrPaq17Yfe8cJWXZfbk2pzw==","shasum":"4a85f0285207fcd828646be9d1f39b1f244b8576","tarball":"https://registry.npmjs.org/@dreamonkey/vue-auth0/-/vue-auth0-0.0.2.tgz","fileCount":12,"unpackedSize":29403,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAS8CM8Pf1fndAcQ0THoGcci+INbEjq06lyCPqOXxUrdAiBF/PkLRMe2nnwwLQS8fr3pt6ohQFRZdUn0Ix18tTB0lg=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjTsLEACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoY6w/9GKrcfNjMisSPhhvZyMUhNxp3WpCY2ZxjZpd4GthZMza2VdOt\r\nfdntYqQe0QQUitW31TXAyluTpDQ7MWx8bkXqzvj6UAA8s7TiRkhqKalbTDfd\r\n8AptWvuoMck0vD4/LlbF48M8cXe1u3vT5dBuq8YrOBpTEZzhYcf7dYZ/H4dr\r\nkAAuLbXijtBzvD7uB+m/LtCppUk7kG/K0s9kHtg0Jkaelq3px+ysMM5c+g9z\r\nTaOKjpyPTGKJjBLvF48CLDTmEgN5SQbe4F7ExfS4FHecwqur2gR9sHyMhjO+\r\nbDwEpqctYP5q9HnwFpqQbj0poYPFZKgzLcWG+nYagJE1VPml1+zUmaq228dp\r\nhleMVUPDiFhTP67rNTyme+73bLu1806eq2m03gM0hXF7tAcgilLVhEgLHu14\r\nWieWMUAN9PxFBXGNxV4ZnyTj/ResnZfiGmqEaM+3Fdfp6P8FTg9xwJNFGdfv\r\nFqeFdAUmWJWVRUsFLNIoVTXhxD3cW3x6EtYy0Jv1SOaQvaiILPcgS+9iivb7\r\nsIwCXiHhwfmJHwUczd1d4cjtLnLJOfBj1GjT+YIYbXNOHbOobAE945ic1YTC\r\n2BoQPp40wyNY0nu/Qe1TipkeWJcMh2F65sA36Jpx2K4xbHcIkyWHVVgF07ZA\r\n9Wl4Q3OD45rjRwObmPxPqIgds6/+Wb9Fqi4=\r\n=P6lX\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"ilcallo","email":"p.caleffi@dreamonkey.com"},"directories":{},"maintainers":[{"name":"ilcallo","email":"p.caleffi@dreamonkey.com"},{"name":"mrkappa","email":"k.borghi@dreamonkey.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vue-auth0_0.0.2_1666106051896_0.451239835271958"},"_hasShrinkwrap":false},"1.0.0":{"name":"@dreamonkey/vue-auth0","version":"1.0.0","description":"@auth0/auth0-spa-js wrapper in the 'Vue way', with full TS support","keywords":["vue","vue-router","auth0","typescript","composable","guard"],"author":{"name":"Paolo Caleffi","email":"p.caleffi@dreamonkey.com","url":"https://github.com/IlCallo"},"license":"MIT","main":"dist/index.js","repository":{"type":"git","url":"git+https://github.com/dreamonkey/vue-auth0.git"},"bugs":{"url":"https://github.com/dreamonkey/vue-auth0/issues"},"engines":{"node":">= 12.22.1","npm":">= 6.14.12","yarn":">= 1.17.3"},"dependencies":{"@vueuse/core":"^7.5.3"},"devDependencies":{"@auth0/auth0-spa-js":"^1.19.0","@babel/types":"^7.16.8","@typescript-eslint/eslint-plugin":"^5.9.1","@typescript-eslint/parser":"^5.9.1","eslint":"^8.6.0","eslint-config-prettier":"^8.3.0","prettier":"^2.5.1","rimraf":"^3.0.2","typescript":"^4.5.4","vue":"^3.2.26","vue-router":"^4.0.0"},"peerDependencies":{"@auth0/auth0-spa-js":"^1.19.0","vue":"^3.0.0","vue-router":"^4.0.0"},"peerDependenciesMeta":{"vue-router":{"optional":true}},"publishConfig":{"access":"public"},"scripts":{"lint":"eslint --ext .js,.ts,.vue ./ --fix --report-unused-disable-directives","format":"prettier --write \"**/*.{json,md,graphql,vue,js,ts}\" --ignore-path .gitignore","build":"rimraf dist && tsc --declaration","deploy":"pnpm build && pnpm publish --tag latest"},"types":"./dist/index.d.ts","homepage":"https://github.com/dreamonkey/vue-auth0#readme","_id":"@dreamonkey/vue-auth0@1.0.0","_integrity":"sha512-riVG7JqQJi0cMqO66p5j7zcWJPr08VczYAAc7Y2ImjgJ/O8E7W2/rLANjzkj74gbVmu4KgoaLu2NxjKpP3p1Kw==","_resolved":"/tmp/0e5d3226bef5bee06fc2872ca960d218/dreamonkey-vue-auth0-1.0.0.tgz","_from":"file:dreamonkey-vue-auth0-1.0.0.tgz","_nodeVersion":"16.17.0","_npmVersion":"8.15.0","dist":{"integrity":"sha512-riVG7JqQJi0cMqO66p5j7zcWJPr08VczYAAc7Y2ImjgJ/O8E7W2/rLANjzkj74gbVmu4KgoaLu2NxjKpP3p1Kw==","shasum":"112e4ab4ef3839d440ad45a3f7bc46bd3a43f3cc","tarball":"https://registry.npmjs.org/@dreamonkey/vue-auth0/-/vue-auth0-1.0.0.tgz","fileCount":12,"unpackedSize":29403,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCQTxsUMSVV1D3Z0NWcIFt19Ij/EmGClntQmU8q01cCagIhAICfko/ml4RdL99z80mAEnAEXUsuNxqU7zjocav5TKzT"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjTsL4ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrtnA//diT5gBiFuIJYzW5flUpPNMkT0zG1RjKLgDFZO2ttRZMXsiPu\r\nOveskEGyfYL0NYy4jxUM/+KMHqkORxuid740bly/9GAZ1q+kxxcupIJrDmX5\r\nDochPFMXn5/kofFQ783EULfcnLbDaOrBt8Oki88hZR/xVxMeDSra21bpIDiA\r\nKs8y8vyDGCcVSNisTfqSB3G9ambqSKcXMatmBVDRoyvDz2XNzwdPlBNyj9xQ\r\ndYjWvYck6EmH0wW8oHPo48yUTn895dr6mlgIE92KLX2QNGhxE/MY77l9Bfcf\r\n3BMxNyPkIPJZ1bGuFtIOjOiWX+ERzHRDkmo1/uZAc7vOCWqMcx99knb1D1tT\r\nHvYcUMwz5geEwlAv3OBCg5oxPdtzg9GOTAT6WQRuY2mJQx+UTH8q74mcUY78\r\nF11aZMMRXr1tXwBVJLM5mCpEsM2njxDTvvl3ou1htIKexDYN4RyBqCZSGqHz\r\nDHy3c0mfSzetOa6lNJsXwkIKLn829Uw/bOzCvFhRc2xsTx58WBXBNKEZs75G\r\n4Q4atwXIO1Rh5DEH0/HBkRz7cExmE2bMuiMwStibjdBgOEvFnSqcUkewM+1n\r\n1/VwMOpfsV/gVju7l5tbDt8WHGcEAZ74OObJ74rPy0pZfMk/joEa/fLVunWw\r\naTTmj1x3+sFZM4tVQpo9zSh7DffIcdtgrqs=\r\n=uVSJ\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"ilcallo","email":"p.caleffi@dreamonkey.com"},"directories":{},"maintainers":[{"name":"ilcallo","email":"p.caleffi@dreamonkey.com"},{"name":"mrkappa","email":"k.borghi@dreamonkey.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vue-auth0_1.0.0_1666106104208_0.8022884040261187"},"_hasShrinkwrap":false}},"time":{"created":"2022-01-11T14:55:47.639Z","0.0.1":"2022-01-11T14:55:47.889Z","modified":"2022-10-18T15:15:04.514Z","0.0.2":"2022-10-18T15:14:12.002Z","1.0.0":"2022-10-18T15:15:04.422Z"},"maintainers":[{"name":"ilcallo","email":"p.caleffi@dreamonkey.com"},{"name":"mrkappa","email":"k.borghi@dreamonkey.com"}],"description":"@auth0/auth0-spa-js wrapper in the 'Vue way', with full TS support","homepage":"https://github.com/dreamonkey/vue-auth0#readme","keywords":["vue","vue-router","auth0","typescript","composable","guard"],"repository":{"type":"git","url":"git+https://github.com/dreamonkey/vue-auth0.git"},"author":{"name":"Paolo Caleffi","email":"p.caleffi@dreamonkey.com","url":"https://github.com/IlCallo"},"bugs":{"url":"https://github.com/dreamonkey/vue-auth0/issues"},"license":"MIT","readme":"# vue-auth0\n\nThis is a wrapper around `@auth0/auth0-spa-js` meant to ease its usage into Vue3 projects.\nThis is heavily inspired by the [snippet](https://auth0.com/docs/quickstart/spa/vuejs#create-an-authentication-wrapper) into Auth0 official documentation, but with a couple more helpers.\n\nThis wrapper supports both JS and TS codebases.\n\n## Install\n\n```sh\nyarn add @dreamonkey/vue-auth0\n```\n\nInitialize the singleton instance\n\n```ts\nimport { Auth0Instance, initAuth0 } from '@dreamonkey/vue-auth0';\n// NEVER HARDCODE AND/OR COMMIT YOUR SECRETS\nimport { domain, clientId } from './env.json';\n\ndeclare module '@vue/runtime-core' {\n  interface ComponentCustomProperties {\n    $auth: Auth0Instance;\n  }\n}\n\n// Vue CLI/Vite project\nimport { createApp } from 'vue';\n\nconst app = createApp({});\n\napp.config.globalProperties.$auth = initAuth0({\n  client_id: clientId,\n  domain,\n});\n\n// Quasar CLI project (using boot files)\nexport default boot(({ app }) => {\n  app.config.globalProperties.$auth = initAuth0({\n    client_id: clientId,\n    domain,\n  });\n});\n```\n\nCheck out [`@auth0/auth0-spa-js` documentation](https://github.com/auth0/auth0-spa-js#documentation) to learn about initialization options, as `initAuth0` accepts all options from original `createAuth0Client` method.\n\nYou can then access the Auth0 singleton instance via `useAuth0` composable\n\n```ts\nimport { useAuth0 } from '@dreamonkey/vue-auth0';\n\nconst { user /*, ... other stuff */ } = useAuth0();\n```\n\nor, in templates or Option API, via the `$auth` global property\n\n```ts\n<button @click=\"$auth.loginWithRedirect()\">Login</button>\n```\n\n## Options\n\n`initAuth0` accepts a couple of custom options in addition to those of `createAuth0Client` method.\n\n### redirectUri (default: `window.location.origin`)\n\nOverwrites native `redirect_uri` option setting a sensible default for it.\nIf your redirect login flow starts from a page with URL `http://my-domain.com/landing`, the user will be redirected to `http://my-domain.com` when the flow completes.\n\n**Remember you need to add whichever URL is provided with `redirectUri` to \"Allowed Callback URLs\" list into your Auth0 configuration.**\n\n### onRedirectCallback\n\nWhen redirect login flow completes, this callback is called with any previously stored state as param.\nIf not specified, it replaces the current browser history entry with current `window.location.pathname`.\nThis can be used to redirect the user to the originally requested page after login took place (see Recipes section).\n\n## Reactive refs\n\nThese refs has been added for your ease, to consume Auth0 SDK in the \"Vue way\"\n\n### `user` (default: `undefined`)\n\nThe original `getUser()` async method served as a reactive reference.\nIt updates when either a login or logout action is performed.\nThe content after login depends on your Auth0 configuration.\n\n```ts\nconst { user } = useAuth0();\n// Before login\nconsole.log(user.value); // undefined\n// After login\nconsole.log(user.value); // { ... }\n```\n\nIts type is [`User`](https://auth0.github.io/auth0-spa-js/classes/user.html) by default, you can augment `Auth0User` type to specify custom properties or to remove optionality from existing keys.\n\n```ts\nimport '@dreamonkey/vue-auth0';\n\ndeclare module '@dreamonkey/vue-auth0' {\n  interface Auth0User {\n    twitter_handle: string; // <--- Specify a custom property which doesn't exist into User by default\n    name: string; // <--- Override User property, it won't be shown as optional anymore\n  }\n}\n```\n\n### `isAuthenticated` (default: `false`)\n\nThe original `isAuthenticated()` async method served as a reactive reference.\n`true` if the user is authenticated, `false` otherwise.\nHelpful to change the behaviour of your app depending on the user authentication status, eg. adding an header to all outgoing requests only when the user is authenticated\n\n```ts\nconst { isAuthenticated } = useAuth0();\n// Before login\nconsole.log(isAuthenticated.value); // false\n// After login\nconsole.log(isAuthenticated.value); // true\n```\n\n### `loading` (default: `true`)\n\n`true` if Auth0 client initialization is still taking place, `false` when initialization completes.\n\n### `popupOpen` (default: `false`)\n\n`true` if the login popup related to `loginWithPopup()` method is open, `false` otherwise.\n\n### `error` (default: `undefined`)\n\nContains the error generated by the underlying library in case something goes wrong.\n\n### `auth0Client` (default: `undefined`)\n\nReference to the underlying Auth0 client created with original `createAuth0Client()` method.\n\n## Methods\n\n### `getTokenSilently`\n\nOriginal `getTokenSilently` method with `detailedResponse` forced to `false`.\nThis is how the method behaved before version 1.19.0.\n\n### `getTokenSilentlyVerbose`\n\nOriginal `getTokenSilently` method with `detailedResponse` forced to `true`.\nSplitting the original method was required to support proper types, as wrapping a function and trying to infer its return type won't work if the original function has an overloaded signature.\n\n### `initializationCompleted`\n\nReturns a Promise resolving when initialization completes.\nUse this when you need to be sure initialization is completed and you cannot use `onInitializationCompleted` hook.\n\n```ts\nconst { initializationCompleted } = useAuth0();\n\nasync function doStuff() {\n  // business ah-ah\n  await initializationCompleted();\n  // profit!\n}\n```\n\n## Hooks\n\nSome common events hooks have been created, ensuring your code will be executed only after a given trigger condition is met.\nSince they're based on internal state refs rather than an event system, if the trigger condition is valid when the hook is registered (eg. login already happened) the callback will be executed immediately.\n\n### `onInitializationCompleted`\n\nTrigger: Auth0 client initialization completes.\nUse case: run code using Auth0 only after the client is initialized.\n\n`initializationCompleted` method could be used to achieve the same result, but with a different syntax.\n\n```ts\nconst { onInitializationCompleted } = useAuth0();\n\nonInitializationCompleted(() => {\n  // unless initialization errors occurred, auth0Client will always be defined here\n});\n```\n\n### `onLogin`\n\nTrigger: login process completes successfully.\nUse case: run code once the user logs in.\nUser data object is provided as a parameter for convenience.\n\nExamples:\n\n- initialize analytics only for authenticated users;\n- establish a websocket connection once the user is authenticated;\n- add an inactivity timeout.\n\n```ts\nconst { onLogin } = useAuth0();\n\nonLogin((user) => {\n  console.log(user); // { .. user data .. }\n});\n```\n\n### `onLogout`\n\nTrigger: logout process completes.\nUse case: run code once the user logs out.\n\nExamples:\n\n- cleanup user-related data;\n- interrupt a websocket connection reserved to authenticated users.\n\n```ts\nconst { onLogout } = useAuth0();\n\nonLogout(() => {\n  localStorage.removeItem('user-data');\n});\n```\n\n## Vue Router Guards\n\nIf you're using Vue Router, you'll often need to guard some routes depending on the user authentication status.\nThis package provides you some helpers to deal with common scenarios.\n\n### `authGuard`\n\nUse this helper to create guards relying on the user authentication status.\nThe first param your callback receives is a boolean representing the authentication status, while the second and third params are the deprecated `to` and `from` Vue Router guards params.\nThe returned guard is async as it awaits for the Auth0 client to be initialized before proceeding.\n\n```ts\nexport const redirectIfAuthenticatedGuard = authGuard((isAuthenticated) => {\n  if (isAuthenticated) {\n    return { name: 'home' };\n  }\n});\n```\n\n### `redirectToLoginGuard`\n\nTriggers `loginWithRedirect` if the user isn't authenticated, storing into `appState.targetUrl` the URL the user tried to access.\nYou can then access it into `onRedirectCallback` to redirect the user to the page he initially requested.\n\n## Recipes\n\nHere are some common use cases you may need in your projects.\nWe'll gladly accept PRs adding new recipes if the use case is common enough.\n\n### Add access token as Authorization header using Axios\n\n```ts\nimport { useAuth0 } from '@dreamonkey/vue-auth0';\nimport axios, { AxiosRequestConfig } from 'axios';\n\nasync function addAuthToken(config: AxiosRequestConfig) {\n  const { getTokenSilently } = useAuth0();\n  const token = await getTokenSilently();\n  addHeader(config, 'Authorization', `Bearer ${token}`);\n  return config;\n}\n\naxios.interceptors.request.use(addAuthToken);\n```\n\n### Redirect to requested page after login\n\n```ts\nimport { initAuth0 } from '@dreamonkey/vue-auth0';\nimport { useRouter } from 'vue-router';\nimport { domain, clientId } from './env.json';\n\nconst router = useRouter();\n\ninitAuth0<{ targetUrl?: string }>({\n  client_id: clientId,\n  domain,\n  onRedirectCallback: (appState) =>\n    router.push(appState?.targetUrl ?? window.location.pathname),\n});\n```\n\n```ts\nimport { RouteRecordRaw } from 'vue-router';\nimport { redirectToLoginGuard } from '@dreamonkey/vue-auth0';\n\nconst routes: RouteRecordRaw[] = [\n  {\n    path: '/',\n    component: () => import('layouts/authenticated.vue'),\n    beforeEnter: redirectToLoginGuard,\n    children: [\n      {\n        path: 'home',\n        name: 'home',\n        component: () => import('pages/home.vue'),\n      },\n    ],\n  },\n];\n```\n\n### Guard guest and authenticated pages\n\n```ts\nimport { RouteRecordRaw } from 'vue-router';\nimport { authGuard } from '@dreamonkey/vue-auth0';\n\nexport const redirectIfAuthenticatedGuard = authGuard((isAuthenticated) => {\n  if (isAuthenticated) {\n    return { name: 'home' };\n  }\n});\n\nexport const redirectIfGuestGuard = authGuard((isAuthenticated) => {\n  if (!isAuthenticated) {\n    return { name: 'landing' };\n  }\n});\n\nconst routes: RouteRecordRaw[] = [\n  {\n    path: '/',\n    redirect: () => ({ name: 'landing' }),\n  },\n  {\n    path: '/',\n    name: 'guest',\n    component: () => import('layouts/guest.vue'),\n    beforeEnter: redirectIfAuthenticatedGuard,\n    children: [\n      {\n        path: 'landing',\n        name: 'landing',\n        component: () => import('pages/landing.vue'),\n      },\n    ],\n  },\n  {\n    path: '/',\n    component: () => import('layouts/authenticated.vue'),\n    beforeEnter: redirectIfGuestGuard,\n    children: [\n      {\n        path: 'home',\n        name: 'home',\n        component: () => import('pages/home.vue'),\n      },\n    ],\n  },\n];\n```\n\n### Render a different page depending on authentication status\n\n```ts\nimport { RouteRecordRaw } from 'vue-router';\nimport { useAuth0 } from '@dreamonkey/vue-auth0';\n\nconst routes: RouteRecordRaw[] = [\n  {\n    path: '/home',\n    component: async () => {\n      const { user, initializationCompleted } = useAuth0();\n      await initializationCompleted();\n\n      if (!user.value) {\n        return import('pages/landing.vue');\n      }\n\n      switch (user.value.role) {\n        case 'admin':\n          return import('pages/home/admin.vue');\n        case 'manager':\n          return import('pages/home/manager.vue');\n        default:\n          return import('pages/home/user.vue');\n      }\n    },\n  },\n];\n```\n","readmeFilename":"README.md"}