@knowlearning/agents 0.9.13 → 0.9.14

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.
@@ -1,10 +1,13 @@
1
1
  const AUTH_HOST = 'https://auth.knowlearning.systems'
2
2
 
3
+ // auth token info is sent with pathnames of form /auth/VERIFICATION_STATE/PROVIDER_TOKEN
3
4
  if (window.location.pathname.startsWith('/auth/')) {
4
- const [state, token] = window.location.pathname.slice(6).split('/')
5
- const origin = localStorage.getItem(state)
5
+ const state_token = window.location.pathname.slice(6)
6
+ const [state] = state_token.split('/', 1)
7
+ const origin = window.localStorage.getItem(state)
6
8
  if (origin) {
7
- localStorage.setItem('token', token)
9
+ const token = state_token.slice(state.length + 1)
10
+ window.localStorage.setItem('token', token)
8
11
  window.location.href = origin
9
12
  }
10
13
  }
@@ -12,20 +15,20 @@ if (window.location.pathname.startsWith('/auth/')) {
12
15
  function login() {
13
16
  const provider = 'google'
14
17
  const state = Math.random().toString(36).substring(2)
15
- localStorage.setItem(state, window.location.href)
18
+ window.localStorage.setItem(state, window.location.href)
16
19
 
17
20
  window.location.href = `${AUTH_HOST}/${provider}/${state}/${encodeURIComponent(window.location.href)}`
18
21
  }
19
22
 
20
23
  function logout() {
21
24
  // Doing this will establish a new anonymous session
22
- localStorage.setItem('token', Math.random().toString(36).substring(2))
25
+ window.localStorage.setItem('token', Math.random().toString(36).substring(2))
23
26
  window.location.reload()
24
27
  }
25
28
 
26
29
  async function getToken() {
27
30
  const token = localStorage.getItem('token')
28
- localStorage.removeItem('token')
31
+ window.localStorage.removeItem('token')
29
32
  return token
30
33
  }
31
34
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowlearning/agents",
3
- "version": "0.9.13",
3
+ "version": "0.9.14",
4
4
  "description": "API for embedding applications in KnowLearning systems.",
5
5
  "main": "node.js",
6
6
  "browser": "browser.js",