@genesislcap/foundation-comms 15.28.1-FUI-0.6 → 15.28.1-reconnection-issues.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.
@@ -18,6 +18,17 @@ export interface HttpRequestInit extends RequestInit {
18
18
  * consumed by the deserializer afterwards.
19
19
  */
20
20
  onResponse?: (response: Response) => void;
21
+ /**
22
+ * Opt in to treating a redirected response as a real top-level browser navigation
23
+ * (`window.location.href = response.url`) instead of resolving/rejecting normally.
24
+ * @remarks
25
+ * Defaults to `false`. Only set this for an interactive call site that genuinely expects the
26
+ * server to redirect the browser itself (e.g. an SSO/OAuth hop). Background/XHR-style calls —
27
+ * such as the cookie-reauth POST issued from the WebSocket heartbeat — must leave this unset so
28
+ * a redirected response is evaluated like any other response instead of hard-navigating the app
29
+ * out from under itself and hanging forever.
30
+ */
31
+ followRedirectAsNavigation?: boolean;
21
32
  }
22
33
  /**
23
34
  * An interface representing an HTTP client that can make GET and POST requests and return a promise with the response data.
@@ -1 +1 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/connect/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAG/D;;;GAGG;AACH,MAAM,WAAW,eAAgB,SAAQ,WAAW;IAClD;;;;OAIG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;CAC3C;AAED;;;GAGG;AACH,MAAM,WAAW,IAAI;IACnB,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACpE,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,GAAG,OAAO,CAAC,CAAC,C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AM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAYD;;;;;;;;;;;GAWG;AACH,qBAAa,WAAY,YAAW,IAAI;IACV,OAAO,CAAC,UAAU;gBAAV,UAAU,EAAE,cAAc;IAEjD,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,GAAG,OAAO,CAAC,CAAC,CAAC;IAU7D,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,GAAG,OAAO,CAAC,CAAC,CAAC;YAU7D,cAAc;CAkB7B;AAED;;;GAGG;AACH,eAAO,MAAM,IAAI,4DAA4D,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sessionRefresh.d.ts","sourceRoot":"","sources":["../../../src/connect/sessionRefresh.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,oBAAY,oBAAoB;IAC9B,yCAAyC;IACzC,OAAO,YAAY;IACnB,wCAAwC;IACxC,MAAM,WAAW;IACjB,0CAA0C;IAC1C,oBAAoB,yBAAyB;IAC7C,gCAAgC;IAChC,aAAa,kBAAkB;CAChC;AA6DD;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,GAAE;IAAE,eAAe,CAAC,EAAE,OAAO,CAAA;CAAO,GAC1C,OAAO,CAAC,oBAAoB,CAAC,CA+B/B;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CASzE"}
1
+ {"version":3,"file":"sessionRefresh.d.ts","sourceRoot":"","sources":["../../../src/connect/sessionRefresh.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,oBAAY,oBAAoB;IAC9B,yCAAyC;IACzC,OAAO,YAAY;IACnB,wCAAwC;IACxC,MAAM,WAAW;IACjB,0CAA0C;IAC1C,oBAAoB,yBAAyB;IAC7C,gCAAgC;IAChC,aAAa,kBAAkB;CAChC;AAuED;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,GAAE;IAAE,eAAe,CAAC,EAAE,OAAO,CAAA;CAAO,GAC1C,OAAO,CAAC,oBAAoB,CAAC,CA4C/B;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CASzE"}
@@ -40,7 +40,7 @@ let DefaultHttp = class DefaultHttp {
40
40
  handleResponse(response, requestInit) {
41
41
  return __awaiter(this, void 0, void 0, function* () {
42
42
  var _a;
43
- if (response.redirected) {
43
+ if (response.redirected && requestInit.followRedirectAsNavigation) {
44
44
  window.location.href = response.url;
45
45
  return new Promise(() => { });
46
46
  }
@@ -59,6 +59,15 @@ function isAuthenticated() {
59
59
  return loginDetails.MESSAGE_TYPE === 'EVENT_LOGIN_DETAILS_ACK';
60
60
  });
61
61
  }
62
+ /**
63
+ * Narrows an unknown thrown value to an {@link HttpError} — i.e. a request that reached the
64
+ * server and got back a non-2xx (or redirected-to-non-2xx) response, as opposed to a genuine
65
+ * network failure (connection error, timeout, DNS failure, etc.) where `fetch` itself throws.
66
+ * @internal
67
+ */
68
+ function isHttpError(error) {
69
+ return error instanceof Error && typeof error.status === 'number';
70
+ }
62
71
  /**
63
72
  * Attempts to refresh the session via EVENT_LOGIN_AUTH.
64
73
  * @internal
@@ -102,7 +111,21 @@ export function tryRefreshSession() {
102
111
  if (yield isAuthenticated()) {
103
112
  return SessionRefreshResult.ALREADY_VALID;
104
113
  }
105
- const refreshSuccessful = yield performRefresh();
114
+ let refreshSuccessful;
115
+ try {
116
+ refreshSuccessful = yield performRefresh();
117
+ }
118
+ catch (error) {
119
+ // The reauth POST reached the server but got back a non-2xx response — e.g. the gateway
120
+ // redirected it to a login sub-app's 404 page once the session had expired server-side.
121
+ // Treat that the same as an EVENT_LOGIN_AUTH_ACK-less response below rather than letting it
122
+ // propagate as an unhandled rejection out of the fire-and-forget heartbeat path. A genuine
123
+ // network failure (fetch itself throwing) still propagates, per this function's contract.
124
+ if (!isHttpError(error)) {
125
+ throw error;
126
+ }
127
+ refreshSuccessful = false;
128
+ }
106
129
  if (!refreshSuccessful) {
107
130
  if (reloadOnFailure) {
108
131
  window.location.reload();
@@ -27883,6 +27883,33 @@
27883
27883
  "name": "HttpRequestInit",
27884
27884
  "preserveMemberOrder": false,
27885
27885
  "members": [
27886
+ {
27887
+ "kind": "PropertySignature",
27888
+ "canonicalReference": "@genesislcap/foundation-comms!HttpRequestInit#followRedirectAsNavigation:member",
27889
+ "docComment": "/**\n * Opt in to treating a redirected response as a real top-level browser navigation (`window.location.href = response.url`) instead of resolving/rejecting normally.\n *\n * @remarks\n *\n * Defaults to `false`. Only set this for an interactive call site that genuinely expects the server to redirect the browser itself (e.g. an SSO/OAuth hop). Background/XHR-style calls — such as the cookie-reauth POST issued from the WebSocket heartbeat — must leave this unset so a redirected response is evaluated like any other response instead of hard-navigating the app out from under itself and hanging forever.\n */\n",
27890
+ "excerptTokens": [
27891
+ {
27892
+ "kind": "Content",
27893
+ "text": "followRedirectAsNavigation?: "
27894
+ },
27895
+ {
27896
+ "kind": "Content",
27897
+ "text": "boolean"
27898
+ },
27899
+ {
27900
+ "kind": "Content",
27901
+ "text": ";"
27902
+ }
27903
+ ],
27904
+ "isReadonly": false,
27905
+ "isOptional": true,
27906
+ "releaseTag": "Public",
27907
+ "name": "followRedirectAsNavigation",
27908
+ "propertyTypeTokenRange": {
27909
+ "startIndex": 1,
27910
+ "endIndex": 2
27911
+ }
27912
+ },
27886
27913
  {
27887
27914
  "kind": "PropertySignature",
27888
27915
  "canonicalReference": "@genesislcap/foundation-comms!HttpRequestInit#onResponse:member",
@@ -3391,6 +3391,17 @@ export declare interface HttpRequestInit extends RequestInit {
3391
3391
  * consumed by the deserializer afterwards.
3392
3392
  */
3393
3393
  onResponse?: (response: Response) => void;
3394
+ /**
3395
+ * Opt in to treating a redirected response as a real top-level browser navigation
3396
+ * (`window.location.href = response.url`) instead of resolving/rejecting normally.
3397
+ * @remarks
3398
+ * Defaults to `false`. Only set this for an interactive call site that genuinely expects the
3399
+ * server to redirect the browser itself (e.g. an SSO/OAuth hop). Background/XHR-style calls —
3400
+ * such as the cookie-reauth POST issued from the WebSocket heartbeat — must leave this unset so
3401
+ * a redirected response is evaluated like any other response instead of hard-navigating the app
3402
+ * out from under itself and hanging forever.
3403
+ */
3404
+ followRedirectAsNavigation?: boolean;
3394
3405
  }
3395
3406
 
3396
3407
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/foundation-comms",
3
3
  "description": "Genesis Foundation UI Comms",
4
- "version": "15.28.1-FUI-0.6",
4
+ "version": "15.28.1-reconnection-issues.1",
5
5
  "sideEffects": false,
6
6
  "license": "SEE LICENSE IN license.txt",
7
7
  "main": "dist/esm/index.js",
@@ -77,24 +77,24 @@
77
77
  }
78
78
  },
79
79
  "devDependencies": {
80
- "@genesislcap/foundation-testing": "15.28.1-FUI-0.6",
81
- "@genesislcap/genx": "15.28.1-FUI-0.6",
82
- "@genesislcap/rollup-builder": "15.28.1-FUI-0.6",
83
- "@genesislcap/ts-builder": "15.28.1-FUI-0.6",
84
- "@genesislcap/uvu-playwright-builder": "15.28.1-FUI-0.6",
85
- "@genesislcap/vite-builder": "15.28.1-FUI-0.6",
86
- "@genesislcap/webpack-builder": "15.28.1-FUI-0.6",
80
+ "@genesislcap/foundation-testing": "15.28.1-reconnection-issues.1",
81
+ "@genesislcap/genx": "15.28.1-reconnection-issues.1",
82
+ "@genesislcap/rollup-builder": "15.28.1-reconnection-issues.1",
83
+ "@genesislcap/ts-builder": "15.28.1-reconnection-issues.1",
84
+ "@genesislcap/uvu-playwright-builder": "15.28.1-reconnection-issues.1",
85
+ "@genesislcap/vite-builder": "15.28.1-reconnection-issues.1",
86
+ "@genesislcap/webpack-builder": "15.28.1-reconnection-issues.1",
87
87
  "@types/js-cookie": "^3.0.2",
88
88
  "@types/json-schema": "^7.0.11",
89
89
  "@types/webappsec-credential-management": "^0.6.2",
90
90
  "sinon": "^17.0.1"
91
91
  },
92
92
  "dependencies": {
93
- "@genesislcap/foundation-broadcast-channel": "15.28.1-FUI-0.6",
94
- "@genesislcap/foundation-logger": "15.28.1-FUI-0.6",
95
- "@genesislcap/foundation-user": "15.28.1-FUI-0.6",
96
- "@genesislcap/foundation-utils": "15.28.1-FUI-0.6",
97
- "@genesislcap/web-core": "15.28.1-FUI-0.6",
93
+ "@genesislcap/foundation-broadcast-channel": "15.28.1-reconnection-issues.1",
94
+ "@genesislcap/foundation-logger": "15.28.1-reconnection-issues.1",
95
+ "@genesislcap/foundation-user": "15.28.1-reconnection-issues.1",
96
+ "@genesislcap/foundation-utils": "15.28.1-reconnection-issues.1",
97
+ "@genesislcap/web-core": "15.28.1-reconnection-issues.1",
98
98
  "@microsoft/fast-element": "1.14.0",
99
99
  "@microsoft/fast-foundation": "2.50.0",
100
100
  "bowser": "^2.11.0",