@xh/hoist 64.0.1 → 64.0.4
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/CHANGELOG.md +23 -1
- package/appcontainer/AppContainerModel.ts +2 -2
- package/build/types/core/HoistComponent.d.ts +4 -8
- package/build/types/core/HoistProps.d.ts +3 -1
- package/build/types/core/elem.d.ts +1 -3
- package/build/types/core/types/Types.d.ts +1 -0
- package/build/types/desktop/cmp/appOption/AutoRefreshAppOption.d.ts +1 -0
- package/build/types/desktop/cmp/appOption/ThemeAppOption.d.ts +1 -0
- package/build/types/icon/Icon.d.ts +7 -4
- package/build/types/security/BaseOAuthClient.d.ts +63 -46
- package/build/types/security/{TokenInfo.d.ts → Token.d.ts} +5 -4
- package/build/types/security/authzero/AuthZeroClient.d.ts +12 -7
- package/build/types/security/authzero/index.d.ts +1 -0
- package/build/types/security/msal/MsalClient.d.ts +63 -10
- package/build/types/security/msal/index.d.ts +1 -0
- package/build/types/svc/FetchService.d.ts +5 -5
- package/build/types/utils/react/LayoutPropUtils.d.ts +4 -4
- package/core/HoistComponent.ts +4 -8
- package/core/HoistProps.ts +4 -1
- package/core/elem.ts +0 -4
- package/core/types/Types.ts +1 -0
- package/desktop/cmp/input/ButtonGroupInput.ts +4 -3
- package/icon/Icon.ts +7 -4
- package/kit/blueprint/styles.scss +31 -18
- package/mobile/appcontainer/ToastSource.ts +2 -1
- package/package.json +1 -1
- package/security/BaseOAuthClient.ts +148 -165
- package/security/{TokenInfo.ts → Token.ts} +12 -9
- package/security/authzero/AuthZeroClient.ts +92 -80
- package/security/authzero/index.ts +7 -0
- package/security/msal/MsalClient.ts +204 -94
- package/security/msal/index.ts +7 -0
- package/svc/FetchService.ts +14 -11
- package/svc/IdentityService.ts +1 -1
- package/svc/LocalStorageService.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/utils/react/LayoutPropUtils.ts +4 -4
package/svc/FetchService.ts
CHANGED
|
@@ -46,7 +46,7 @@ export class FetchService extends HoistService {
|
|
|
46
46
|
NO_JSON_RESPONSES = [StatusCodes.NO_CONTENT, StatusCodes.RESET_CONTENT];
|
|
47
47
|
|
|
48
48
|
private autoAborters = {};
|
|
49
|
-
defaultHeaders: (PlainObject | ((arg: FetchOptions) => PlainObject))[] = [];
|
|
49
|
+
defaultHeaders: (PlainObject | ((arg: FetchOptions) => Awaitable<PlainObject>))[] = [];
|
|
50
50
|
defaultTimeout = (30 * SECONDS) as any;
|
|
51
51
|
|
|
52
52
|
/**
|
|
@@ -54,7 +54,7 @@ export class FetchService extends HoistService {
|
|
|
54
54
|
* @param headers - to be sent with all fetch requests, or a function to generate.
|
|
55
55
|
* @deprecated use addDefaultHeaders instead.
|
|
56
56
|
*/
|
|
57
|
-
setDefaultHeaders(headers: PlainObject | ((arg: FetchOptions) => PlainObject)) {
|
|
57
|
+
setDefaultHeaders(headers: PlainObject | ((arg: FetchOptions) => Awaitable<PlainObject>)) {
|
|
58
58
|
apiDeprecated('setDefaultHeaders', {v: '66', msg: 'Use addDefaultHeaders instead'});
|
|
59
59
|
this.addDefaultHeaders(headers);
|
|
60
60
|
}
|
|
@@ -63,7 +63,7 @@ export class FetchService extends HoistService {
|
|
|
63
63
|
* Add default headers to be sent with all subsequent requests.
|
|
64
64
|
* @param headers - to be sent with all fetch requests, or a function to generate.
|
|
65
65
|
*/
|
|
66
|
-
addDefaultHeaders(headers: PlainObject | ((arg: FetchOptions) => PlainObject)) {
|
|
66
|
+
addDefaultHeaders(headers: PlainObject | ((arg: FetchOptions) => Awaitable<PlainObject>)) {
|
|
67
67
|
this.defaultHeaders.push(headers);
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -79,8 +79,8 @@ export class FetchService extends HoistService {
|
|
|
79
79
|
* Send a request via the underlying fetch API.
|
|
80
80
|
* @returns Promise which resolves to a Fetch Response.
|
|
81
81
|
*/
|
|
82
|
-
fetch(opts: FetchOptions): Promise<FetchResponse> {
|
|
83
|
-
opts = this.
|
|
82
|
+
async fetch(opts: FetchOptions): Promise<FetchResponse> {
|
|
83
|
+
opts = await this.withDefaultsAsync(opts);
|
|
84
84
|
return this.managedFetchAsync(opts);
|
|
85
85
|
}
|
|
86
86
|
|
|
@@ -88,8 +88,8 @@ export class FetchService extends HoistService {
|
|
|
88
88
|
* Send an HTTP request and decode the response as JSON.
|
|
89
89
|
* @returns the decoded JSON object, or null if the response has status in {@link NO_JSON_RESPONSES}.
|
|
90
90
|
*/
|
|
91
|
-
fetchJson(opts: FetchOptions): Promise<any> {
|
|
92
|
-
opts = this.
|
|
91
|
+
async fetchJson(opts: FetchOptions): Promise<any> {
|
|
92
|
+
opts = await this.withDefaultsAsync(opts, {Accept: 'application/json'});
|
|
93
93
|
return this.managedFetchAsync(opts, async r => {
|
|
94
94
|
if (this.NO_JSON_RESPONSES.includes(r.status)) return null;
|
|
95
95
|
|
|
@@ -157,14 +157,17 @@ export class FetchService extends HoistService {
|
|
|
157
157
|
//-----------------------
|
|
158
158
|
// Implementation
|
|
159
159
|
//-----------------------
|
|
160
|
-
private
|
|
160
|
+
private async withDefaultsAsync(
|
|
161
|
+
opts: FetchOptions,
|
|
162
|
+
extraHeaders: PlainObject = null
|
|
163
|
+
): Promise<FetchOptions> {
|
|
161
164
|
const method = opts.method ?? (opts.params ? 'POST' : 'GET'),
|
|
162
165
|
isPost = method === 'POST';
|
|
163
166
|
|
|
164
167
|
const defaultHeaders = {};
|
|
165
|
-
this.defaultHeaders
|
|
166
|
-
Object.assign(defaultHeaders, isFunction(h) ? h(opts) : h);
|
|
167
|
-
}
|
|
168
|
+
for (const h of this.defaultHeaders) {
|
|
169
|
+
Object.assign(defaultHeaders, isFunction(h) ? await h(opts) : h);
|
|
170
|
+
}
|
|
168
171
|
|
|
169
172
|
return {
|
|
170
173
|
...opts,
|
package/svc/IdentityService.ts
CHANGED
|
@@ -59,7 +59,7 @@ export class IdentityService extends HoistService {
|
|
|
59
59
|
*/
|
|
60
60
|
async logoutAsync() {
|
|
61
61
|
await XH.fetchJson({url: 'xh/logout'});
|
|
62
|
-
await XH.appModel
|
|
62
|
+
await XH.appModel?.logoutAsync(); // can be called by LockoutPanel prior to appModel init
|
|
63
63
|
XH.reloadApp();
|
|
64
64
|
}
|
|
65
65
|
|