@knowlearning/agents 0.9.11 → 0.9.13
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.
- package/agents/browser/auth.js +10 -3
- package/package.json +1 -1
- package/vue/3/components/scope.vue +5 -1
package/agents/browser/auth.js
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
const AUTH_HOST = 'https://auth.knowlearning.systems'
|
|
2
2
|
|
|
3
|
+
if (window.location.pathname.startsWith('/auth/')) {
|
|
4
|
+
const [state, token] = window.location.pathname.slice(6).split('/')
|
|
5
|
+
const origin = localStorage.getItem(state)
|
|
6
|
+
if (origin) {
|
|
7
|
+
localStorage.setItem('token', token)
|
|
8
|
+
window.location.href = origin
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
3
12
|
function login() {
|
|
4
13
|
const provider = 'google'
|
|
5
14
|
const state = Math.random().toString(36).substring(2)
|
|
6
|
-
|
|
7
|
-
localStorage.setItem('state', state)
|
|
15
|
+
localStorage.setItem(state, window.location.href)
|
|
8
16
|
|
|
9
17
|
window.location.href = `${AUTH_HOST}/${provider}/${state}/${encodeURIComponent(window.location.href)}`
|
|
10
18
|
}
|
|
@@ -16,7 +24,6 @@ function logout() {
|
|
|
16
24
|
}
|
|
17
25
|
|
|
18
26
|
async function getToken() {
|
|
19
|
-
// Browser tokens are 1 time use
|
|
20
27
|
const token = localStorage.getItem('token')
|
|
21
28
|
localStorage.removeItem('token')
|
|
22
29
|
return token
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<span v-if="state">{{value}}</span>
|
|
2
|
+
<span v-if="state">{{value ? value : placeholder }}</span>
|
|
3
3
|
<span v-else>loading...</span>
|
|
4
4
|
</template>
|
|
5
5
|
|
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
path: {
|
|
12
12
|
type: Array,
|
|
13
13
|
default: []
|
|
14
|
+
},
|
|
15
|
+
placeholder: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: ''
|
|
14
18
|
}
|
|
15
19
|
},
|
|
16
20
|
data() {
|