@xh/hoist 67.0.0-SNAPSHOT.1723839594443 → 67.0.0-SNAPSHOT.1723841759825

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 CHANGED
@@ -15,7 +15,6 @@
15
15
  new `FetchOptions.track` API (see below).
16
16
  * If set on a fetch request, Correlation IDs are passed through to downstream error reporting
17
17
  and are available for review in the Admin Console.
18
- * New `XH.genUUID()` method to generate UUIDs for use as Correlation IDs or elsewhere.
19
18
  * New `FetchOptions.track` - specify `TrackOptions` or message `string` to track a request via
20
19
  Hoist activity tracking. The request's Correlation ID and LoadSpec will be included automatically.
21
20
  * New global interceptors on `FetchService`. See `FetchService.addInterceptor()`.
@@ -398,12 +398,7 @@ export declare class XHApi {
398
398
  * Deliberately *not* intended to be globally unique, suitable for reuse, or to appear as such.
399
399
  */
400
400
  genId(): string;
401
- /**
402
- * Generate a universally unique identifier (UUID). Useful for generating Correlation IDs.
403
- */
404
- genUUID(): string;
405
401
  private get acm();
406
- private shortUniqueId;
407
402
  }
408
403
  /** The app-wide singleton instance. */
409
404
  export declare const XH: XHApi;
@@ -24,14 +24,16 @@ import { IStringifyOptions } from 'qs';
24
24
  export declare class FetchService extends HoistService {
25
25
  static instance: FetchService;
26
26
  NO_JSON_RESPONSES: StatusCodes[];
27
+ private idGenerator;
27
28
  private autoAborters;
28
29
  private _defaultHeaders;
29
30
  private _interceptors;
30
31
  /** True to auto-generate a Correlation ID for each request unless otherwise specified. */
31
32
  autoGenCorrelationIds: boolean;
32
33
  /**
33
- * Method for generating Correlation ID's. Defaults to `XH.genUUID()` but can be modified
34
- * by applications looking to customize the format of their Correlation ID's.
34
+ * Method for generating Correlation ID's. Defaults to a 16 character random string with
35
+ * an extremely low probability of collisions. Applications may customize
36
+ * to improve readability or provide a stronger uniqueness guarantee.
35
37
  */
36
38
  genCorrelationId: () => string;
37
39
  /** Request header name to be used for Correlation ID tracking. */
package/core/XH.ts CHANGED
@@ -63,7 +63,6 @@ import {
63
63
  import {installServicesAsync} from './impl/InstallServices';
64
64
  import {instanceManager} from './impl/InstanceManager';
65
65
  import {HoistModel, ModelSelector, RefreshContextModel} from './model';
66
- import ShortUniqueId from 'short-unique-id';
67
66
 
68
67
  export const MIN_HOIST_CORE_VERSION = '18.0';
69
68
 
@@ -780,21 +779,12 @@ export class XHApi {
780
779
  return uniqueId('xh-id-');
781
780
  }
782
781
 
783
- /**
784
- * Generate a universally unique identifier (UUID). Useful for generating Correlation IDs.
785
- */
786
- genUUID(): string {
787
- return this.shortUniqueId.rnd();
788
- }
789
-
790
782
  //----------------
791
783
  // Implementation
792
784
  //----------------
793
785
  private get acm(): AppContainerModel {
794
786
  return this.appContainerModel;
795
787
  }
796
-
797
- private shortUniqueId = new ShortUniqueId({length: 16});
798
788
  }
799
789
 
800
790
  /** The app-wide singleton instance. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "67.0.0-SNAPSHOT.1723839594443",
3
+ "version": "67.0.0-SNAPSHOT.1723841759825",
4
4
  "description": "Hoist add-on for building and deploying React Applications.",
5
5
  "repository": "github:xh/hoist-react",
6
6
  "homepage": "https://xh.io",
@@ -11,6 +11,7 @@ import {Timer} from '@xh/hoist/utils/async';
11
11
  import {MINUTES, olderThan, ONE_MINUTE, SECONDS} from '@xh/hoist/utils/datetime';
12
12
  import {isJSON, throwIf} from '@xh/hoist/utils/js';
13
13
  import {find, forEach, isEmpty, isObject, keys, pickBy, union} from 'lodash';
14
+ import ShortUniqueId from 'short-unique-id';
14
15
 
15
16
  export type LoginMethod = 'REDIRECT' | 'POPUP';
16
17
 
@@ -253,11 +254,12 @@ export abstract class BaseOAuthClient<C extends BaseOAuthClientConfig<S>, S> ext
253
254
  */
254
255
  protected captureRedirectState(): string {
255
256
  const {pathname, search} = window.location,
257
+ key = new ShortUniqueId({length: 8}).rnd(),
256
258
  state = {
257
- key: XH.genUUID(),
258
- timestamp: Date.now(),
259
+ key,
259
260
  pathname,
260
- search
261
+ search,
262
+ timestamp: Date.now()
261
263
  };
262
264
 
263
265
  const recs = this.getLocalStorage('xhOAuthState', []).filter(
@@ -19,6 +19,7 @@ import {apiDeprecated, warnIf} from '@xh/hoist/utils/js';
19
19
  import {StatusCodes} from 'http-status-codes';
20
20
  import {isDate, isFunction, isNil, isObject, isString, omit, omitBy} from 'lodash';
21
21
  import {IStringifyOptions, stringify} from 'qs';
22
+ import ShortUniqueId from 'short-unique-id';
22
23
 
23
24
  /**
24
25
  * Service for making managed HTTP requests, both to the app's own Hoist server and to remote APIs.
@@ -44,6 +45,7 @@ export class FetchService extends HoistService {
44
45
 
45
46
  NO_JSON_RESPONSES = [StatusCodes.NO_CONTENT, StatusCodes.RESET_CONTENT];
46
47
 
48
+ private idGenerator = new ShortUniqueId({length: 16});
47
49
  private autoAborters = {};
48
50
  private _defaultHeaders: DefaultHeaders[] = [];
49
51
  private _interceptors: FetchInterceptor[] = [];
@@ -54,10 +56,11 @@ export class FetchService extends HoistService {
54
56
  autoGenCorrelationIds = false;
55
57
 
56
58
  /**
57
- * Method for generating Correlation ID's. Defaults to `XH.genUUID()` but can be modified
58
- * by applications looking to customize the format of their Correlation ID's.
59
+ * Method for generating Correlation ID's. Defaults to a 16 character random string with
60
+ * an extremely low probability of collisions. Applications may customize
61
+ * to improve readability or provide a stronger uniqueness guarantee.
59
62
  */
60
- genCorrelationId: () => string = () => XH.genUUID();
63
+ genCorrelationId: () => string = () => this.idGenerator.rnd();
61
64
 
62
65
  /** Request header name to be used for Correlation ID tracking. */
63
66
  correlationIdHeaderKey: string = 'X-Correlation-ID';