@wandelbots/nova-js 4.10.0-nova-api-dev.26-9-0-dev-8 → 4.11.0-nova-api-dev.26-9-0-dev-8
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/dist/Nova-CPAS0kAw.d.mts.map +1 -1
- package/dist/v2/index.mjs +6 -1
- package/dist/v2/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/lib/Nova.ts +12 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wandelbots/nova-js",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.11.0-nova-api-dev.26-9-0-dev-8",
|
|
5
5
|
"description": "Official JS client for the Wandelbots API",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"packageManager": "pnpm@11.9.0+sha512.bd682d5d03fe525ef7c9fd6780c6884d1e756ac4c9c9fe00c538782824310dcf90e3ddc4f53835f06dfaebd5085e41855e0bcbb3b60de2ac5bbab89e5036f03b",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"@auth0/auth0-spa-js": "^2.24.1",
|
|
83
83
|
"@nats-io/jetstream": "^3.4.0",
|
|
84
84
|
"@nats-io/nats-core": "^3.4.0",
|
|
85
|
-
"axios": "^1.
|
|
85
|
+
"axios": "^1.20.0",
|
|
86
86
|
"path-to-regexp": "^8.4.2",
|
|
87
87
|
"reconnecting-websocket": "^4.4.0"
|
|
88
88
|
}
|
package/src/lib/Nova.ts
CHANGED
|
@@ -25,6 +25,14 @@ export type NovaConfig = {
|
|
|
25
25
|
accessToken?: string
|
|
26
26
|
} & Omit<BaseConfiguration, "isJsonMime" | "basePath">
|
|
27
27
|
|
|
28
|
+
/** Whether the page is already showing the given url, ignoring query and hash */
|
|
29
|
+
function isOnUrl(url: URL): boolean {
|
|
30
|
+
const trimSlashes = (path: string) => path.replace(/\/+$/, "")
|
|
31
|
+
return (
|
|
32
|
+
window.location.origin === url.origin &&
|
|
33
|
+
trimSlashes(window.location.pathname) === trimSlashes(url.pathname)
|
|
34
|
+
)
|
|
35
|
+
}
|
|
28
36
|
/**
|
|
29
37
|
*
|
|
30
38
|
* Client for connecting to a NOVA instance and controlling robots.
|
|
@@ -125,7 +133,7 @@ export class Nova {
|
|
|
125
133
|
// the original 403 error below.
|
|
126
134
|
}
|
|
127
135
|
|
|
128
|
-
if (redirectToAccessDenied) {
|
|
136
|
+
if (redirectToAccessDenied && !isOnUrl(this.instanceUrl)) {
|
|
129
137
|
// Send them to the instance url, which renders the access
|
|
130
138
|
// denied screen. Return a promise that never settles so the
|
|
131
139
|
// caller doesn't flash an error state before the navigation
|
|
@@ -133,6 +141,9 @@ export class Nova {
|
|
|
133
141
|
window.location.href = this.instanceUrl.href
|
|
134
142
|
return new Promise(() => {})
|
|
135
143
|
}
|
|
144
|
+
// Already on the instance url: redirecting again would reload
|
|
145
|
+
// the page forever, so the 403 bubbles for the page to render
|
|
146
|
+
// its own access denied state.
|
|
136
147
|
} else if (error.response?.status === 503) {
|
|
137
148
|
// Check if the server as a whole is down
|
|
138
149
|
const res = await fetch(window.location.href)
|