@knowlearning/agents 0.9.163 → 0.9.164

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.
@@ -4,21 +4,17 @@ import { getToken, login, logout } from './auth.js'
4
4
  import GenericAgent from '../generic/index.js'
5
5
 
6
6
  const TEST_DOMAIN = 'tests.knowlearning.systems'
7
- const SECURE = window.location.protocol === 'https:'
8
- const DEVELOPMENT_HOST = `localhost:3200${ SECURE ? '1' : '2' }`
9
- const ENVIRONMENT_API_HOST = localStorage.getItem('API_HOST')
10
- const REMOTE_HOST = window.location.hostname === TEST_DOMAIN && ENVIRONMENT_API_HOST ? ENVIRONMENT_API_HOST : 'api.knowlearning.systems'
11
7
  const LANGUAGES = [...navigator.languages]
12
8
 
13
- function isLocal() { return localStorage.getItem('api') === 'local' }
14
-
15
- const API_HOST = isLocal() ? DEVELOPMENT_HOST : REMOTE_HOST
9
+ const API_HOST = localStorage.getItem('API_HOST') || 'api.knowlearning.systems'
10
+ // const API_HOST = 'api-test.knowlearning.systems'
11
+ // const API_HOST = 'localhost:8765'
16
12
 
17
13
  // TODO: remove this hack when we can set partitioned sid cookie through websocket handshake
18
14
  // deno is partly in the way on teh set side, and browser support is in the way for
19
15
  // the client side.
20
16
  async function ensureSidEstablished() {
21
- const response = await fetch(`http${ SECURE ? 's' : '' }://${API_HOST}/_sid-check`, { method: 'GET', credentials: 'include' })
17
+ const response = await fetch(`https://${API_HOST}/_sid-check`, { method: 'GET', credentials: 'include' })
22
18
  const hasLocalStorageSID = !!localStorage.getItem('sid')
23
19
  if (response.status === 201) {
24
20
  if (!hasLocalStorageSID) {
@@ -43,7 +39,7 @@ export default options => {
43
39
  ensureSidEstablished()
44
40
  const Connection = function () {
45
41
 
46
- const ws = new WebSocket(`ws${ SECURE ? 's' : '' }://${API_HOST}`)
42
+ const ws = new WebSocket(`wss://${API_HOST}`)
47
43
 
48
44
  this.send = message => ws.send(JSON.stringify(message))
49
45
  this.close = info => {
package/deno.js CHANGED
@@ -3,7 +3,7 @@ import Agent from './agents/generic/index.js'
3
3
 
4
4
  const AGENT_TOKEN = Deno.env.get('AGENT_TOKEN')
5
5
 
6
- const denoProcess = self
6
+ const denoProcess = globalThis
7
7
 
8
8
  denoProcess.addEventListener('message', ({ data }) => {
9
9
  if (!data) denoProcess.postMessage(undefined) // ping response
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowlearning/agents",
3
- "version": "0.9.163",
3
+ "version": "0.9.164",
4
4
  "description": "API for embedding applications in KnowLearning systems.",
5
5
  "main": "node.js",
6
6
  "browser": "browser.js",