@knowlearning/agents 0.6.4 → 0.7.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.
- package/agents/browser/auth.js +4 -9
- package/browser.js +0 -1
- package/node.js +0 -1
- package/package.json +1 -1
package/agents/browser/auth.js
CHANGED
|
@@ -9,20 +9,15 @@ function login() {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
function logout() {
|
|
12
|
-
|
|
12
|
+
// TODO: hit logout url to refresh cookie
|
|
13
13
|
window.location.reload()
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
async function getToken() {
|
|
17
|
+
// Browser tokens are 1 time use
|
|
17
18
|
const token = localStorage.getItem('token')
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const randArr = new Uint32Array(16)
|
|
21
|
-
crypto.getRandomValues(randArr)
|
|
22
|
-
const anonymousCredential = [...randArr].map(x => x.toString(16).padStart(2, '0')).join('')
|
|
23
|
-
localStorage.setItem('token', anonymousCredential)
|
|
24
|
-
return anonymousCredential
|
|
25
|
-
}
|
|
19
|
+
localStorage.removeItem('token')
|
|
20
|
+
return token
|
|
26
21
|
}
|
|
27
22
|
|
|
28
23
|
export {
|
package/browser.js
CHANGED
package/node.js
CHANGED