@sowell/quasar-app-extension-auth 0.1.8 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/.eslintignore +4 -0
  2. package/.eslintrc.js +13 -13
  3. package/.gitattributes +2 -0
  4. package/.github/workflows/main.yml +22 -0
  5. package/README.md +393 -28
  6. package/package.json +34 -19
  7. package/src/boot/axios.ts +17 -0
  8. package/src/boot/register.ts +8 -0
  9. package/src/boot/router-guards.ts +25 -0
  10. package/src/boot/router.ts +20 -0
  11. package/src/boot/store.ts +10 -0
  12. package/src/components/pages/Auth.vue +227 -0
  13. package/src/components/{ResetPassword.vue → pages/ResetPassword.vue} +40 -40
  14. package/src/i18n/en-US/index.ts +23 -0
  15. package/src/i18n/fr-FR/index.ts +23 -0
  16. package/src/i18n/index.ts +7 -0
  17. package/src/index.js +29 -24
  18. package/src/injects/api.ts +10 -0
  19. package/src/injects/index.ts +4 -0
  20. package/src/injects/prompts.ts +25 -0
  21. package/src/injects/router.ts +10 -0
  22. package/src/injects/store.ts +10 -0
  23. package/src/interfaces/Boot.ts +8 -0
  24. package/src/interfaces/TokenStateInterface.ts +11 -0
  25. package/src/interfaces/index.ts +2 -0
  26. package/src/prompts.js +40 -34
  27. package/src/routes/index.ts +22 -0
  28. package/src/shims-vue.d.ts +6 -0
  29. package/src/store/index.ts +56 -0
  30. package/tsconfig.json +14 -0
  31. package/.github/workflows/publish.yml +0 -23
  32. package/.prettierrc +0 -7
  33. package/.vscode/extensions.json +0 -12
  34. package/.vscode/settings.json +0 -22
  35. package/jsconfig.json +0 -7
  36. package/package-lock.json +0 -2344
  37. package/src/boot/axios.js +0 -19
  38. package/src/boot/navigation-guards.js +0 -16
  39. package/src/boot/register.js +0 -45
  40. package/src/components/Auth.vue +0 -275
  41. package/src/components/ResetCode.vue +0 -137
  42. package/src/components/prompt.js +0 -38
  43. package/src/config/setupHeaders.js +0 -6
  44. package/src/install.js +0 -10
  45. package/src/templates/.gitkeep +0 -0
  46. package/src/uninstall.js +0 -10
package/src/prompts.js CHANGED
@@ -1,105 +1,111 @@
1
- /**
2
- * Quasar App Extension prompts script
3
- **/
1
+ "use strict";
4
2
  module.exports = function () {
5
3
  return [
6
4
  {
7
- name: "local_login_route",
5
+ name: "LOCAL_LOGIN_ROUTE",
8
6
  type: "input",
9
7
  required: true,
10
8
  message: "Route to authenticate (page)",
11
- default: "/login"
9
+ default: "/login",
12
10
  },
13
11
  {
14
- name: "local_success_redirection_route",
12
+ name: "LOCAL_SUCCESS_REDIRECTION_ROUTE",
15
13
  type: "input",
16
14
  required: true,
17
15
  message: "Route to be redirected once connected (page)",
18
- default: "/"
16
+ default: "/",
19
17
  },
20
18
  {
21
- name: "local_check_code_route",
19
+ name: "LOCAL_CHECK_CODE_ROUTE",
22
20
  type: "input",
23
21
  required: true,
24
22
  message: "Route to check the code (page)",
25
- default: "/check_code"
23
+ default: "/check_code",
26
24
  },
27
25
  {
28
- name: "local_update_password_route",
26
+ name: "LOCAL_UPDATE_PASSWORD_ROUTE",
29
27
  type: "input",
30
28
  required: true,
31
29
  message: "Route to update the password (page)",
32
- default: "/reset_password"
30
+ default: "/reset_password",
33
31
  },
34
32
  {
35
- name: "auth_server_base_url",
33
+ name: "AUTH_SERVER_BASE_URL",
36
34
  type: "input",
37
35
  required: true,
38
36
  message: "Basic Url for API",
39
- default: "http://localhost:3000"
37
+ default: "http://localhost:3000",
40
38
  },
41
39
  {
42
- name: "auth_server_signing_route",
40
+ name: "AUTH_SERVER_SIGNING_ROUTE",
43
41
  type: "input",
44
42
  required: true,
45
43
  message: "API endpoint for signin (without host)",
46
- default: "/users/sign_in"
44
+ default: "/users/sign_in",
47
45
  },
48
46
  {
49
- name: "auth_server_reset_password_route",
47
+ name: "AUTH_SERVER_RESET_PASSWORD_ROUTE",
50
48
  type: "input",
51
49
  required: true,
52
50
  message: "API endpoint for reset password (without host)",
53
- default: "/users/reset_password"
51
+ default: "/users/reset_password",
54
52
  },
55
53
  {
56
- name: "auth_server_update_password_route",
54
+ name: "AUTH_SERVER_UPDATE_PASSWORD_ROUTE",
57
55
  type: "input",
58
56
  required: true,
59
57
  message: "API endpoint for update password (without host)",
60
- default: "/users/passwords"
58
+ default: "/users/passwords",
61
59
  },
62
60
  {
63
- name: "auth_type",
61
+ name: "AUTH_TYPE",
64
62
  type: "input",
65
63
  required: true,
66
64
  message: "Authorization type",
67
- default: "Bearer"
65
+ default: "Bearer",
68
66
  },
69
67
  {
70
- name: "vuex_set_token_mutation",
68
+ name: "VUEX_SET_TOKEN_MUTATION",
71
69
  type: "input",
72
70
  required: true,
73
71
  message: "Vuex mutation to set token",
74
- default: "auth/setToken"
72
+ default: "auth/set_token",
75
73
  },
76
74
  {
77
- name: "vuex_clear_token_mutation",
75
+ name: "VUEX_CLEAR_TOKEN_MUTATION",
78
76
  type: "input",
79
77
  required: true,
80
78
  message: "Vuex mutation to clear token",
81
- default: "auth/clearToken"
79
+ default: "auth/clear_token",
82
80
  },
83
81
  {
84
- name: "vuex_set_infos_user_mutation",
82
+ name: "VUEX_SET_EMAIL_MUTATION",
83
+ type: "input",
84
+ required: true,
85
+ message:
86
+ "Vuex mutation to store user email when authenticated",
87
+ default: "auth/set_email_user"
88
+ },
89
+ {
90
+ name: "VUEX_SET_INFOS_USER_MUTATION",
85
91
  type: "input",
86
92
  required: true,
87
93
  message: "Vuex mutation to set user information to reset password",
88
- default: "auth/setInfosUser"
94
+ default: "auth/set_infos_user",
89
95
  },
90
96
  {
91
- name: "vuex_get_token_getter",
97
+ name: "VUEX_GET_TOKEN_GETTER",
92
98
  type: "input",
93
99
  required: true,
94
100
  message: "Vuex getter token",
95
- default: "auth/getToken"
101
+ default: "auth/get_token",
96
102
  },
97
103
  {
98
- name: "vuex_get_infos_user_getter",
104
+ name: "VUEX_GET_INFOS_USER_GETTER",
99
105
  type: "input",
100
106
  required: true,
101
107
  message: "Vuex getter user information",
102
- default: "auth/getInfosUser"
103
- }
104
- ]
105
- }
108
+ default: "auth/get_infos_user",
109
+ },
110
+ ];
111
+ };
@@ -0,0 +1,22 @@
1
+ // @ts-ignore
2
+ import prompts from "app/quasar.extensions.json";
3
+ import { RouteRecordRaw } from "vue-router";
4
+
5
+ const {
6
+ "@sowell/auth": { LOCAL_LOGIN_ROUTE, LOCAL_UPDATE_PASSWORD_ROUTE },
7
+ } = prompts;
8
+
9
+ const routes: RouteRecordRaw[] = [
10
+ {
11
+ path: LOCAL_LOGIN_ROUTE,
12
+ // @ts-ignore
13
+ component: () => import("@sowell/auth/pages/Auth.vue"),
14
+ },
15
+ {
16
+ path: LOCAL_UPDATE_PASSWORD_ROUTE,
17
+ // @ts-ignore
18
+ component: () => import("@sowell/auth/pages/ResetPassword.vue"),
19
+ },
20
+ ];
21
+
22
+ export default routes;
@@ -0,0 +1,6 @@
1
+ // Mocks all files ending in `.vue` showing them as plain Vue instances
2
+ declare module '*.vue' {
3
+ import { ComponentOptions } from 'vue';
4
+ const component: ComponentOptions;
5
+ export default component;
6
+ }
@@ -0,0 +1,56 @@
1
+ import { Module, GetterTree, MutationTree, ActionTree } from "vuex";
2
+ import { tokenStateInterface, payload } from "../interfaces";
3
+
4
+ const state: tokenStateInterface = {
5
+ raw: "",
6
+ payload: {
7
+ company_hp: undefined,
8
+ exp: undefined,
9
+ gm_key: "",
10
+ roles: [],
11
+ sub: null
12
+ }
13
+ }
14
+
15
+ const getters: GetterTree<tokenStateInterface, any> = {
16
+ getRaw(state) {
17
+ return state.raw
18
+ },
19
+ getPayload(state) {
20
+ return state.payload
21
+ },
22
+ getIsValid(state) {
23
+ if (state.payload.exp) {
24
+ return new Date(state.payload.exp * 1000) >= new Date() ? true : false;
25
+ } else {
26
+ return false
27
+ }
28
+ }
29
+ }
30
+
31
+ const mutations: MutationTree<tokenStateInterface> = {
32
+ setRaw(state, value: string) {
33
+ state.raw = value
34
+ },
35
+ setPayload(state, value: payload) {
36
+ state.payload = {...value}
37
+ }
38
+ }
39
+
40
+ const actions: ActionTree<tokenStateInterface, any> = {
41
+ updateRaw({ commit }, value: string) {
42
+ commit("setRaw", value);
43
+ const parseJwt = JSON.parse(window.atob(value.split(".")[1]));
44
+ commit("setPayload", parseJwt)
45
+ }
46
+ }
47
+
48
+ const tokenModule: Module<tokenStateInterface, any> = {
49
+ namespaced: true,
50
+ getters,
51
+ mutations,
52
+ actions,
53
+ state
54
+ }
55
+
56
+ export default tokenModule;
package/tsconfig.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "allowJs": true,
4
+ "target": "es6",
5
+ "module": "commonjs",
6
+ "strict": true,
7
+ "moduleResolution": "node",
8
+ "esModuleInterop": true,
9
+ "skipLibCheck": true,
10
+ "forceConsistentCasingInFileNames": true,
11
+ "resolveJsonModule": true,
12
+ "types": ["node"]
13
+ }
14
+ }
@@ -1,23 +0,0 @@
1
- name: "publish"
2
-
3
- on:
4
- push:
5
- branches:
6
- - master
7
-
8
- jobs:
9
- release:
10
- name: publish
11
- runs-on: ubuntu-latest
12
- steps:
13
- - name: checkout
14
- uses: actions/checkout@v2
15
- - name: node
16
- uses: actions/setup-node@v2
17
- with:
18
- node-version: "14"
19
- registry-url: https://registry.npmjs.org
20
- - name: publish
21
- run: yarn publish --access public
22
- env:
23
- NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
package/.prettierrc DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "semi": false,
3
- "tabWidth": 2,
4
- "singleQuote": false,
5
- "arrowParens": "always",
6
- "trailingComma": "none"
7
- }
@@ -1,12 +0,0 @@
1
- {
2
- "recommendations": [
3
- "dbaeumer.vscode-eslint",
4
- "esbenp.prettier-vscode",
5
- "octref.vetur"
6
- ],
7
- "unwantedRecommendations": [
8
- "hookyqr.beautify",
9
- "dbaeumer.jshint",
10
- "ms-vscode.vscode-typescript-tslint-plugin"
11
- ]
12
- }
@@ -1,22 +0,0 @@
1
- {
2
- "vetur.validation.template": false,
3
- "vetur.format.enable": false,
4
- "eslint.validate": ["javascript", "javascriptreact", "typescript", "vue"],
5
-
6
- "vetur.experimental.templateInterpolationService": true,
7
- "vetur.format.defaultFormatter.html": "js-beautify-html",
8
- "editor.defaultFormatter": "esbenp.prettier-vscode",
9
- "vetur.format.defaultFormatterOptions": {
10
- "js-beautify-html": {
11
- "wrap_attributes": "auto"
12
- }
13
- },
14
- "editor.tabSize": 2,
15
- "editor.formatOnSave": true,
16
- "[javascript, vue]": {
17
- "editor.formatOnSave": false
18
- },
19
- "editor.codeActionsOnSave": {
20
- "source.fixAll": true
21
- }
22
- }
package/jsconfig.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- // This must be specified if "paths" is set
4
- "baseUrl": "."
5
- // Relative to "baseUrl"
6
- }
7
- }