@live-change/user-frontend 0.8.32 → 0.8.34

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.
@@ -2,30 +2,30 @@
2
2
  "version": "6.0",
3
3
  "nxVersion": "18.0.6",
4
4
  "deps": {
5
- "@live-change/cli": "0.8.22",
6
- "@live-change/dao": "0.8.22",
7
- "@live-change/dao-vue3": "0.8.22",
8
- "@live-change/dao-websocket": "0.8.22",
9
- "@live-change/email-service": "0.8.22",
10
- "@live-change/framework": "0.8.22",
11
- "@live-change/identicon-service": "0.8.22",
12
- "@live-change/image-frontend": "0.8.22",
13
- "@live-change/message-authentication-service": "0.8.22",
14
- "@live-change/notification-service": "0.8.22",
15
- "@live-change/password-authentication-service": "0.8.22",
16
- "@live-change/pattern": "0.8.22",
17
- "@live-change/secret-code-service": "0.8.22",
18
- "@live-change/secret-link-service": "0.8.22",
19
- "@live-change/security-frontend": "0.8.22",
20
- "@live-change/security-service": "0.8.22",
21
- "@live-change/session-service": "0.8.22",
22
- "@live-change/timer-service": "0.8.22",
23
- "@live-change/upload-service": "0.8.22",
24
- "@live-change/user-identification-service": "0.8.22",
25
- "@live-change/user-service": "0.8.22",
26
- "@live-change/vue3-components": "0.8.22",
27
- "@live-change/vue3-ssr": "0.8.22",
28
- "@vueuse/core": "^10.9.0",
5
+ "@live-change/cli": "0.8.33",
6
+ "@live-change/dao": "0.8.33",
7
+ "@live-change/dao-vue3": "0.8.33",
8
+ "@live-change/dao-websocket": "0.8.33",
9
+ "@live-change/email-service": "0.8.33",
10
+ "@live-change/framework": "0.8.33",
11
+ "@live-change/identicon-service": "0.8.33",
12
+ "@live-change/image-frontend": "0.8.33",
13
+ "@live-change/message-authentication-service": "0.8.33",
14
+ "@live-change/notification-service": "0.8.33",
15
+ "@live-change/password-authentication-service": "0.8.33",
16
+ "@live-change/pattern": "0.8.33",
17
+ "@live-change/secret-code-service": "0.8.33",
18
+ "@live-change/secret-link-service": "0.8.33",
19
+ "@live-change/security-frontend": "0.8.33",
20
+ "@live-change/security-service": "0.8.33",
21
+ "@live-change/session-service": "0.8.33",
22
+ "@live-change/timer-service": "0.8.33",
23
+ "@live-change/upload-service": "0.8.33",
24
+ "@live-change/user-identification-service": "0.8.33",
25
+ "@live-change/user-service": "0.8.33",
26
+ "@live-change/vue3-components": "0.8.33",
27
+ "@live-change/vue3-ssr": "0.8.33",
28
+ "@vueuse/core": "^10.11.0",
29
29
  "codeceptjs-assert": "^0.0.5",
30
30
  "codeceptjs-video-helper": "0.1.3",
31
31
  "compression": "^1.7.4",
@@ -40,10 +40,10 @@
40
40
  "unique-names-generator": "4.7.1",
41
41
  "v-shared-element": "3.1.1",
42
42
  "vue-meta": "^3.0.0-alpha.9",
43
- "vue-router": "^4.2.5",
43
+ "vue-router": "^4.3.3",
44
44
  "vue3-scroll-border": "0.1.6",
45
45
  "wtfnode": "^0.9.1",
46
- "@live-change/codeceptjs-helper": "0.8.22",
46
+ "@live-change/codeceptjs-helper": "0.8.33",
47
47
  "codeceptjs": "^3.5.12",
48
48
  "generate-password": "1.7.1",
49
49
  "playwright": "^1.41.2",
@@ -58,15 +58,7 @@
58
58
  "nonProjectFiles": [
59
59
  {
60
60
  "file": ".gitignore",
61
- "hash": "16142390958919539472"
62
- },
63
- {
64
- "file": "build-stats/ssr-srcentryserverjs-outDir-distserver.html",
65
- "hash": "17084642017258807740"
66
- },
67
- {
68
- "file": "build-stats/ssrManifest-outDir-distclient.html",
69
- "hash": "3717210539203410457"
61
+ "hash": "16223102139109646162"
70
62
  },
71
63
  {
72
64
  "file": "e2e/codecept.conf.js",
@@ -132,10 +124,6 @@
132
124
  "file": "e2e/steps_file.js",
133
125
  "hash": "2840236016458073038"
134
126
  },
135
- {
136
- "file": "front/components.d.ts",
137
- "hash": "16126346593933999340"
138
- },
139
127
  {
140
128
  "file": "front/index.html",
141
129
  "hash": "14592446545376477605"
@@ -162,7 +150,7 @@
162
150
  },
163
151
  {
164
152
  "file": "front/src/App.vue",
165
- "hash": "9444669136274040524"
153
+ "hash": "2987862695029806083"
166
154
  },
167
155
  {
168
156
  "file": "front/src/Index.vue",
@@ -238,7 +226,7 @@
238
226
  },
239
227
  {
240
228
  "file": "front/src/locale/LocaleSettings.vue",
241
- "hash": "8043550231211679672"
229
+ "hash": "15462056023784231614"
242
230
  },
243
231
  {
244
232
  "file": "front/src/locale/routes.js",
@@ -386,11 +374,11 @@
386
374
  },
387
375
  {
388
376
  "file": "front/src/sign/GoogleAuth.vue",
389
- "hash": "339885639525588130"
377
+ "hash": "5043472338996276712"
390
378
  },
391
379
  {
392
380
  "file": "front/src/sign/GoogleAuthReturn.vue",
393
- "hash": "16033219181863400422"
381
+ "hash": "11578892278379018497"
394
382
  },
395
383
  {
396
384
  "file": "front/src/sign/SignInEmail.vue",
@@ -418,15 +406,15 @@
418
406
  },
419
407
  {
420
408
  "file": "front/src/sign/routes.js",
421
- "hash": "13520340671954201795"
409
+ "hash": "731553876160166852"
422
410
  },
423
411
  {
424
412
  "file": "front/src/utils/countries.js",
425
413
  "hash": "6201169448865628496"
426
414
  },
427
415
  {
428
- "file": "front/src/utils/googleApi.js",
429
- "hash": "6876031073201770248"
416
+ "file": "front/src/utils/googleAuth.js",
417
+ "hash": "10682927559112869908"
430
418
  },
431
419
  {
432
420
  "file": "front/vite.config.js",
@@ -438,11 +426,11 @@
438
426
  },
439
427
  {
440
428
  "file": "package.json",
441
- "hash": "4486716430883503029"
429
+ "hash": "12911801514831005291"
442
430
  },
443
431
  {
444
432
  "file": "server/app.config.js",
445
- "hash": "6845178030219464653"
433
+ "hash": "18401554844996247569"
446
434
  },
447
435
  {
448
436
  "file": "server/init-functions.js",
@@ -462,7 +450,7 @@
462
450
  },
463
451
  {
464
452
  "file": "server/start.js",
465
- "hash": "8389694059221215231"
453
+ "hash": "12152681523604331573"
466
454
  }
467
455
  ]
468
456
  }
Binary file
@@ -14,13 +14,13 @@
14
14
  </div>
15
15
  </div>
16
16
  <div v-else-if="state === 'waiting'" class="text-center">
17
- Authentication will open in a new window.
17
+ Authentication will open in this window.
18
18
  </div>
19
19
  <div v-else-if="state === 'working'" class="text-center">
20
20
  Waiting for server...
21
21
  </div>
22
22
  <div v-else-if="state === 'error'" class="text-center">
23
- <div>Error during authentication</div>
23
+ <div>Error during authentication:</div>
24
24
  <div>{{ error }}</div>
25
25
  </div>
26
26
  <div v-else>
@@ -32,79 +32,53 @@
32
32
  </template>
33
33
 
34
34
  <script setup>
35
- import { loadGoogleAuth2 } from "../utils/googleApi.js"
36
35
  import { defineProps, toRefs, ref, onMounted, inject } from 'vue'
37
36
 
38
- import { useApi } from "@live-change/vue3-ssr"
39
- const api = useApi()
40
-
41
- import { useToast } from 'primevue/usetoast'
42
- const toast = useToast()
37
+ import { useRouter } from 'vue-router'
38
+ const router = useRouter()
43
39
 
44
40
  const workingZone = inject('workingZone')
45
41
 
46
- import { useRouter } from 'vue-router'
47
- const router = useRouter()
42
+ import { googleAuthRedirect } from '../utils/googleAuth.js'
48
43
 
49
44
  const props = defineProps({
50
45
  action: {
51
46
  type: String,
52
47
  default: 'signInOrSignUp'
48
+ },
49
+ accessType: {
50
+ type: String,
51
+ default: 'offline', //'online'
52
+ },
53
+ scope: {
54
+ type: Array,
55
+ default: () => ['profile', 'email']
53
56
  }
54
57
  })
55
58
 
56
- const { action } = toRefs(props)
59
+ const { action, accessType, scope } = toRefs(props)
57
60
  const state = ref('waiting')
58
61
  const error = ref(null)
59
62
 
60
- async function googleAuth() {
63
+ function googleAuth() {
61
64
  state.value = 'waiting'
62
- const auth = await loadGoogleAuth2()
63
- const googleRedirectUri = document.location.protocol + '//' + document.location.host
64
- + router.resolve({ name: 'user:googleAuthReturn', params: { action: action.value } }).href
65
- const response = await (auth.signIn({
66
- scope: 'profile email'
67
- }).catch(error => {
68
- if(error.error === 'popup_blocked_by_browser') {
69
- return auth.signIn({
70
- scope: 'profile email',
71
- ux_mode: 'redirect',
72
- redirect_uri: googleRedirectUri
73
- })
74
- }
75
- if(error.error === 'popup_closed_by_user') {
76
- toast.add({ severity: 'warning', summary: 'Canceled', detail: 'You closed login window', life: 3000 })
77
- state.value = 'canceled'
78
- return
79
- }
80
- throw error
65
+
66
+ workingZone.addPromise('google auth', new Promise((resolve, reject) => {
67
+ setTimeout(() => {
68
+ state.value = 'error'
69
+ error.value = 'redirect_timeout'
70
+ // return reject('redirect timeout?!')
71
+ return resolve()
72
+ }, 4000)
81
73
  }))
82
74
 
83
- state.value = 'working'
84
- try {
85
- const result = await workingZone.addPromise(`google ${action.value}`,
86
- api.command(['googleAuthentication', action.value], {
87
- accessToken: response.getAuthResponse().id_token
88
- })
89
- )
90
- //console.log("GAUTH RESULT", result)
91
- const { action: actionDone, user } = result
92
- while(api.client.value.user !== result.user) {
93
- await new Promise(resolve => setTimeout(resolve, 100))
94
- }
95
- if(actionDone === 'signIn') {
96
- router.push({ name: 'user:signInFinished' })
97
- } else if(actionDone === 'signUp') {
98
- router.push({ name: 'user:signUpFinished' })
99
- } else {
100
- console.error("Unknown action", actionDone)
101
- }
102
- } catch(error) {
103
- console.error("Google auth error", error)
104
- toast.add({ severity: 'error', summary: 'Error', detail: 'Error during google authentication', life: 3000 })
105
- state.value = 'error'
106
- error.value = error
107
- }
75
+ googleAuthRedirect({
76
+ scope: scope.value.join(' '),
77
+ redirectUri: document.location.protocol + '//' + document.location.host
78
+ + router.resolve({ name: 'user:googleAuthReturn', params: { action: action.value } }).href,
79
+ accessType: accessType.value
80
+ })
81
+
108
82
  }
109
83
 
110
84
  async function back() {
@@ -9,7 +9,8 @@
9
9
  <div v-if="state === 'canceled'" class="text-center">
10
10
  <div>Authentication canceled by user</div>
11
11
  <div class="flex flex-row">
12
- <Button @click="back" label="Go back" icon="pi pi-arrow-left" class="w-full p-button-secondary mb-1" />
12
+ <Button @click="back" label="Go back" icon="pi pi-arrow-left"
13
+ class="w-full p-button-secondary mb-1" />
13
14
  </div>
14
15
  </div>
15
16
  <div v-else-if="state === 'working'" class="text-center">
@@ -28,7 +29,6 @@
28
29
  </template>
29
30
 
30
31
  <script setup>
31
- import { loadGoogleAuth2 } from "../utils/googleApi.js"
32
32
  import { defineProps, toRefs, ref, onMounted, inject } from 'vue'
33
33
 
34
34
  import { useApi } from "@live-change/vue3-ssr"
@@ -39,8 +39,9 @@
39
39
 
40
40
  const workingZone = inject('workingZone')
41
41
 
42
- import { useRouter } from 'vue-router'
42
+ import { useRouter, useRoute } from 'vue-router'
43
43
  const router = useRouter()
44
+ const route = useRoute()
44
45
 
45
46
  const props = defineProps({
46
47
  action: {
@@ -53,24 +54,20 @@
53
54
  const state = ref('waiting')
54
55
  const error = ref(null)
55
56
 
56
-
57
57
  onMounted(async () => {
58
- const id_token = decodeURIComponent(
59
- document.location.hash
60
- .slice(1)
61
- .split('&')
62
- .map(p => p.split('='))
63
- .find(a => a[0] === 'id_token')
64
- [1]
65
- )
66
- if(!id_token) {
58
+ const query = route.query
59
+ console.log("QUERY", query)
60
+
61
+ if(!query.code) {
67
62
  state.value = 'canceled'
68
63
  return
69
64
  }
70
65
  try {
71
66
  const result = await workingZone.addPromise(`google ${action.value}`,
72
67
  api.command(['googleAuthentication', action.value], {
73
- accessToken: id_token
68
+ redirectUri: document.location.protocol + '//' + document.location.host
69
+ + router.resolve({ name: 'user:googleAuthReturn', params: { action: action.value } }).href,
70
+ ...query
74
71
  })
75
72
  )
76
73
  console.log("GAUTH RESULT", result)
@@ -5,6 +5,8 @@ export function routes(config = {}) {
5
5
 
6
6
  route({ name: 'user:googleAuth', path: prefix + 'google-auth/:action',
7
7
  component: () => import("./GoogleAuth.vue"), props: true, meta: { } }),
8
+ route({ name: 'user:googleAuthScopes', path: prefix + 'google-auth/:action/:scopes*',
9
+ component: () => import("./GoogleAuth.vue"), props: true, meta: { } }),
8
10
  route({ name: 'user:googleAuthReturn', path: prefix + 'google-auth-return/:action',
9
11
  component: () => import("./GoogleAuthReturn.vue"), props: true }),
10
12
 
@@ -0,0 +1,29 @@
1
+ export function getAuthorizationUri(config) {
2
+ const {
3
+ authorizationBase = 'https://accounts.google.com/o/oauth2/auth',
4
+ accessType = 'offline',
5
+ approvalPrompt = 'force',
6
+ scope,
7
+ responseType = 'code',
8
+ clientId = ENV_GOOGLE_CLIENT_ID,
9
+ redirectUri = 'urn:ietf:wg:oauth:2.0:oob',
10
+ } = config
11
+
12
+ const authorizationUri = authorizationBase +
13
+ `?access_type=${accessType}&approval_prompt=${approvalPrompt}` +
14
+ `&scope=${encodeURIComponent(scope)}&response_type=${responseType}`+
15
+ `&client_id=${encodeURIComponent(clientId)}`+
16
+ //`&state=${encodeURIComponent(clientId)}` +
17
+ `&redirect_uri=${encodeURIComponent(redirectUri)}`
18
+
19
+ return authorizationUri
20
+ }
21
+
22
+ export function googleAuthRedirect(opts) {
23
+ const authUri = getAuthorizationUri({
24
+ ...opts
25
+ })
26
+ console.log("AUTH URI", authUri)
27
+
28
+ setTimeout(() => window.location = authUri, 100)
29
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/user-frontend",
3
- "version": "0.8.32",
3
+ "version": "0.8.34",
4
4
  "scripts": {
5
5
  "memDev": "node --inspect --expose-gc server/start.js memDev --enableSessions --initScript ./init.js --dbAccess",
6
6
  "localDevInit": "rm tmp.db; node server/start.js localDev --enableSessions --initScript ./init.js",
@@ -22,30 +22,30 @@
22
22
  },
23
23
  "type": "module",
24
24
  "dependencies": {
25
- "@live-change/cli": "^0.8.32",
26
- "@live-change/dao": "^0.8.32",
27
- "@live-change/dao-vue3": "^0.8.32",
28
- "@live-change/dao-websocket": "^0.8.32",
29
- "@live-change/email-service": "^0.8.32",
30
- "@live-change/framework": "^0.8.32",
31
- "@live-change/identicon-service": "^0.8.32",
32
- "@live-change/image-frontend": "^0.8.32",
33
- "@live-change/message-authentication-service": "^0.8.32",
34
- "@live-change/notification-service": "^0.8.32",
35
- "@live-change/password-authentication-service": "^0.8.32",
36
- "@live-change/pattern": "^0.8.32",
37
- "@live-change/secret-code-service": "^0.8.32",
38
- "@live-change/secret-link-service": "^0.8.32",
39
- "@live-change/security-frontend": "^0.8.32",
40
- "@live-change/security-service": "^0.8.32",
41
- "@live-change/session-service": "^0.8.32",
42
- "@live-change/timer-service": "^0.8.32",
43
- "@live-change/upload-service": "^0.8.32",
44
- "@live-change/user-identification-service": "^0.8.32",
45
- "@live-change/user-service": "^0.8.32",
46
- "@live-change/vue3-components": "^0.8.32",
47
- "@live-change/vue3-ssr": "^0.8.32",
48
- "@vueuse/core": "^10.9.0",
25
+ "@live-change/cli": "^0.8.34",
26
+ "@live-change/dao": "^0.8.34",
27
+ "@live-change/dao-vue3": "^0.8.34",
28
+ "@live-change/dao-websocket": "^0.8.34",
29
+ "@live-change/email-service": "^0.8.34",
30
+ "@live-change/framework": "^0.8.34",
31
+ "@live-change/identicon-service": "^0.8.34",
32
+ "@live-change/image-frontend": "^0.8.34",
33
+ "@live-change/message-authentication-service": "^0.8.34",
34
+ "@live-change/notification-service": "^0.8.34",
35
+ "@live-change/password-authentication-service": "^0.8.34",
36
+ "@live-change/pattern": "^0.8.34",
37
+ "@live-change/secret-code-service": "^0.8.34",
38
+ "@live-change/secret-link-service": "^0.8.34",
39
+ "@live-change/security-frontend": "^0.8.34",
40
+ "@live-change/security-service": "^0.8.34",
41
+ "@live-change/session-service": "^0.8.34",
42
+ "@live-change/timer-service": "^0.8.34",
43
+ "@live-change/upload-service": "^0.8.34",
44
+ "@live-change/user-identification-service": "^0.8.34",
45
+ "@live-change/user-service": "^0.8.34",
46
+ "@live-change/vue3-components": "^0.8.34",
47
+ "@live-change/vue3-ssr": "^0.8.34",
48
+ "@vueuse/core": "^10.11.0",
49
49
  "codeceptjs-assert": "^0.0.5",
50
50
  "codeceptjs-video-helper": "0.1.3",
51
51
  "compression": "^1.7.4",
@@ -60,12 +60,12 @@
60
60
  "unique-names-generator": "4.7.1",
61
61
  "v-shared-element": "3.1.1",
62
62
  "vue-meta": "^3.0.0-alpha.9",
63
- "vue-router": "^4.2.5",
63
+ "vue-router": "^4.3.3",
64
64
  "vue3-scroll-border": "0.1.6",
65
65
  "wtfnode": "^0.9.1"
66
66
  },
67
67
  "devDependencies": {
68
- "@live-change/codeceptjs-helper": "^0.8.32",
68
+ "@live-change/codeceptjs-helper": "^0.8.34",
69
69
  "codeceptjs": "^3.5.12",
70
70
  "generate-password": "1.7.1",
71
71
  "playwright": "^1.41.2",
@@ -76,5 +76,5 @@
76
76
  "author": "Michał Łaszczewski <michal@laszczewski.pl>",
77
77
  "license": "BSD-3-Clause",
78
78
  "description": "",
79
- "gitHead": "9ea7767670a99404794087726223064c45d798d3"
79
+ "gitHead": "40e61928bf43b35352c76fc135f36a2d8bd76c4a"
80
80
  }
@@ -1,50 +0,0 @@
1
- let googPromise
2
-
3
- function loadGoogle() {
4
- if(googPromise) return googPromise
5
- let resolved = false
6
- googPromise = new Promise((resolve, reject) => {
7
- if (typeof window != 'undefined') {
8
- window.googAsyncInit = function () {
9
- if(resolved) return
10
- resolved = true
11
- resolve(gapi)
12
- }
13
-
14
- ;(function (d, s, id) {
15
- const fjs = d.getElementsByTagName(s)[0]
16
- if (d.getElementById(id)) return
17
- const js = d.createElement(s)
18
- js.id = id
19
- js.src = "https://apis.google.com/js/platform.js?onload=googAsyncInit"
20
- fjs.parentNode.insertBefore(js, fjs)
21
- }(document, 'script', 'google-jssdk'))
22
- } else {
23
- reject('unavailable')
24
- }
25
- })
26
- return googPromise
27
- }
28
-
29
- let googAuth2Promise
30
-
31
- async function loadGoogleAuth2() {
32
- if(googAuth2Promise) return googAuth2Promise
33
- let gapi = await loadGoogle()
34
- let resolved = false
35
- googAuth2Promise = new Promise((resolve, reject) => {
36
- gapi.load('auth2', function() {
37
- if(resolved) return
38
- resolved = true
39
- let client_id = ENV_GOOGLE_CLIENT_ID
40
- resolve(gapi.auth2.init({
41
- client_id
42
- }))
43
- })
44
- })
45
- return googAuth2Promise
46
- }
47
-
48
-
49
-
50
- export { loadGoogle, loadGoogleAuth2 }