@sowell/quasar-app-extension-auth 0.2.0 → 0.2.4

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 (48) 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 +378 -10
  6. package/package.json +35 -19
  7. package/src/assets/Logo.svg +6 -0
  8. package/src/boot/axios.ts +17 -0
  9. package/src/boot/register.ts +8 -0
  10. package/src/boot/router-guards.ts +25 -0
  11. package/src/boot/router.ts +20 -0
  12. package/src/boot/store.ts +10 -0
  13. package/src/components/pages/Auth.vue +265 -0
  14. package/src/components/pages/ResetPassword.vue +123 -0
  15. package/src/i18n/en-US/index.ts +24 -0
  16. package/src/i18n/fr-FR/index.ts +24 -0
  17. package/src/i18n/index.ts +7 -0
  18. package/src/index.js +29 -25
  19. package/src/injects/api.ts +10 -0
  20. package/src/injects/index.ts +4 -0
  21. package/src/injects/prompts.ts +25 -0
  22. package/src/injects/router.ts +10 -0
  23. package/src/injects/store.ts +10 -0
  24. package/src/interfaces/Boot.ts +8 -0
  25. package/src/interfaces/TokenStateInterface.ts +11 -0
  26. package/src/interfaces/index.ts +2 -0
  27. package/src/prompts.js +42 -38
  28. package/src/routes/index.ts +23 -0
  29. package/src/shims-vue.d.ts +6 -0
  30. package/src/store/index.ts +66 -0
  31. package/tsconfig.json +14 -0
  32. package/.github/workflows/publish.yml +0 -22
  33. package/.prettierrc +0 -7
  34. package/.vscode/extensions.json +0 -12
  35. package/.vscode/settings.json +0 -22
  36. package/jsconfig.json +0 -7
  37. package/package-lock.json +0 -2344
  38. package/src/boot/axios.js +0 -17
  39. package/src/boot/navigation-guards.js +0 -16
  40. package/src/boot/register.js +0 -45
  41. package/src/components/Auth.vue +0 -279
  42. package/src/components/ResetCode.vue +0 -140
  43. package/src/components/ResetPassword.vue +0 -139
  44. package/src/components/prompt.js +0 -40
  45. package/src/config/setupHeaders.js +0 -6
  46. package/src/install.js +0 -10
  47. package/src/templates/.gitkeep +0 -0
  48. package/src/uninstall.js +0 -10
package/src/prompts.js CHANGED
@@ -1,113 +1,117 @@
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_email_or_phonenumber_user_mutation",
82
+ name: "VUEX_SET_EMAIL_MUTATION",
85
83
  type: "input",
86
84
  required: true,
87
- message:
88
- "Vuex mutation to store user email or phone number when authenticated",
89
- default: "auth/setEmailUser"
85
+ message: "Vuex mutation to store user email when authenticated",
86
+ default: "auth/set_email_user",
90
87
  },
91
88
  {
92
- name: "vuex_set_infos_user_mutation",
89
+ name: "VUEX_SET_INFOS_USER_MUTATION",
93
90
  type: "input",
94
91
  required: true,
95
92
  message: "Vuex mutation to set user information to reset password",
96
- default: "auth/setInfosUser"
93
+ default: "auth/set_infos_user",
97
94
  },
98
95
  {
99
- name: "vuex_get_token_getter",
96
+ name: "VUEX_GET_TOKEN_GETTER",
100
97
  type: "input",
101
98
  required: true,
102
99
  message: "Vuex getter token",
103
- default: "auth/getToken"
100
+ default: "auth/get_token",
104
101
  },
105
102
  {
106
- name: "vuex_get_infos_user_getter",
103
+ name: "VUEX_GET_INFOS_USER_GETTER",
107
104
  type: "input",
108
105
  required: true,
109
106
  message: "Vuex getter user information",
110
- default: "auth/getInfosUser"
111
- }
112
- ]
113
- }
107
+ default: "auth/get_infos_user",
108
+ },
109
+ {
110
+ name: "X_REQUESTED_ROLES",
111
+ type: "input",
112
+ required: true,
113
+ message: "Role required for the application",
114
+ default: "",
115
+ },
116
+ ];
117
+ };
@@ -0,0 +1,23 @@
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
+ name:"update_password",
18
+ // @ts-ignore
19
+ component: () => import("@sowell/auth/pages/ResetPassword.vue"),
20
+ },
21
+ ];
22
+
23
+ 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,66 @@
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
+ reset(state) {
39
+ state.raw = ""
40
+ state.payload = {
41
+ company_hp: undefined,
42
+ exp: undefined,
43
+ gm_key: "",
44
+ roles: [],
45
+ sub: null
46
+ }
47
+ }
48
+ }
49
+
50
+ const actions: ActionTree<tokenStateInterface, any> = {
51
+ updateRaw({ commit }, value: string) {
52
+ commit("setRaw", value);
53
+ const parseJwt = JSON.parse(window.atob(value.split(".")[1]));
54
+ commit("setPayload", parseJwt)
55
+ }
56
+ }
57
+
58
+ const tokenModule: Module<tokenStateInterface, any> = {
59
+ namespaced: true,
60
+ getters,
61
+ mutations,
62
+ actions,
63
+ state
64
+ }
65
+
66
+ 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,22 +0,0 @@
1
- name: "release"
2
-
3
- on:
4
- release:
5
- types: [published]
6
-
7
- jobs:
8
- release:
9
- name: release
10
- runs-on: ubuntu-latest
11
- steps:
12
- - name: checkout
13
- uses: actions/checkout@v2
14
- - name: node
15
- uses: actions/setup-node@v2
16
- with:
17
- node-version: "14"
18
- registry-url: https://registry.npmjs.org
19
- - name: publish
20
- run: yarn publish --access public
21
- env:
22
- 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
- }