@knowlearning/agents 0.6.3 → 0.7.1

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.
@@ -9,20 +9,12 @@ function login() {
9
9
  }
10
10
 
11
11
  function logout() {
12
- localStorage.removeItem('token')
12
+ // TODO: hit logout url to refresh cookie
13
13
  window.location.reload()
14
14
  }
15
15
 
16
16
  async function getToken() {
17
- const token = localStorage.getItem('token')
18
- if (token) return token
19
- else {
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
- }
17
+ return localStorage.getItem('token')
26
18
  }
27
19
 
28
20
  export {
package/agents/generic.js CHANGED
@@ -126,6 +126,9 @@ export default function Agent({ host, token, WebSocket, protocol='ws', uuid, fet
126
126
  if (message.error) console.warn('ERROR RESPONSE', message)
127
127
 
128
128
  if (!authed) {
129
+ // TODO: credential refresh flow instead of forcing login
130
+ if (message.error) return login()
131
+
129
132
  authed = true
130
133
  if (!user) { // this is the first authed websocket connection
131
134
  user = message.auth.user
package/browser.js CHANGED
@@ -1,4 +1,3 @@
1
- // TODO: export browser, node, deno, and generic agents
2
1
  export { default as GenericAgent } from './agents/generic.js'
3
2
  export { default as browserAgent } from './agents/browser/initialize.js'
4
3
  export { default as vuePersistentStore } from './persistence/vuex.js'
package/node.js CHANGED
@@ -1,3 +1,2 @@
1
- // TODO: export browser, node, deno, and generic agents
2
1
  export { default as NodeAgent } from '../agents/node.js'
3
2
  export { default as GenericAgent } from '../agents/generic.js'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowlearning/agents",
3
- "version": "0.6.3",
3
+ "version": "0.7.1",
4
4
  "description": "API for embedding applications in KnowLearning systems.",
5
5
  "main": "node.js",
6
6
  "browser": "browser.js",