bruce-cesium 6.6.9 → 6.7.0

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.
@@ -16067,7 +16067,19 @@
16067
16067
  // Already exists, no need to re-initialize.
16068
16068
  return;
16069
16069
  }
16070
- const validToken = await exports.ViewerUtils.AssertIonToken(Cesium.Ion.defaultAccessToken);
16070
+ const ionCheckApi = this.getters.GetBruceApi({});
16071
+ await ionCheckApi.Loading;
16072
+ const { programKeys: ionCheckKeys } = await BModels.ProgramKey.GetList({ api: ionCheckApi });
16073
+ const ionKey = ionCheckKeys.find(k => k.ProgramId === BModels.ProgramKey.EProgramId.CesiumIon);
16074
+ // Use if marked as available.
16075
+ let validToken;
16076
+ if (ionCheckApi.IsVersionAtLeast(BModels.BruceApi.VERSION_WITH_PROXIES)) {
16077
+ validToken = (ionKey === null || ionKey === void 0 ? void 0 : ionKey.Available) === true;
16078
+ }
16079
+ // Legacy route, to be killed off.
16080
+ else {
16081
+ validToken = (ionKey === null || ionKey === void 0 ? void 0 : ionKey.Key) ? await exports.ViewerUtils.AssertIonToken(ionKey.Key) : false;
16082
+ }
16071
16083
  if (!validToken) {
16072
16084
  console.warn("'tileset-osm-render-manager.ts' could not locate a valid Cesium Ion token.");
16073
16085
  return;
@@ -22997,7 +23009,18 @@
22997
23009
  // If we need a cesium token, and we don't have one, then we can't render this.
22998
23010
  let shouldCreate = true;
22999
23011
  if (NEEDS_CESIUM_TOKEN.includes(defaultImg.id)) {
23000
- shouldCreate = await exports.ViewerUtils.AssertIonToken(Cesium.Ion.defaultAccessToken);
23012
+ const ionCheckApi = apiGetter.getApi(apiGetter.accountId);
23013
+ await ionCheckApi.Loading;
23014
+ const { programKeys: ionCheckKeys } = await BModels.ProgramKey.GetList({ api: ionCheckApi });
23015
+ const ionKey = ionCheckKeys.find(k => k.ProgramId === BModels.ProgramKey.EProgramId.CesiumIon);
23016
+ // Use if marked as available.
23017
+ if (ionCheckApi.IsVersionAtLeast(BModels.BruceApi.VERSION_WITH_PROXIES)) {
23018
+ shouldCreate = (ionKey === null || ionKey === void 0 ? void 0 : ionKey.Available) === true;
23019
+ }
23020
+ // Legacy route, to be killed off.
23021
+ else {
23022
+ shouldCreate = (ionKey === null || ionKey === void 0 ? void 0 : ionKey.Key) ? await exports.ViewerUtils.AssertIonToken(ionKey.Key) : false;
23023
+ }
23001
23024
  }
23002
23025
  if (shouldCreate) {
23003
23026
  try {
@@ -23440,7 +23463,18 @@
23440
23463
  // Cesium token is required for Cesium World Terrain.
23441
23464
  let shouldCreate = true;
23442
23465
  if (defaultTerr.id == BModels.ProjectViewTile.EDefaultTerrain.CesiumWorldTerrain) {
23443
- shouldCreate = await exports.ViewerUtils.AssertIonToken(Cesium.Ion.defaultAccessToken);
23466
+ const ionCheckApi = params.apiGetter.getApi(params.apiGetter.accountId);
23467
+ await ionCheckApi.Loading;
23468
+ const { programKeys: ionCheckKeys } = await BModels.ProgramKey.GetList({ api: ionCheckApi });
23469
+ const ionKey = ionCheckKeys.find(k => k.ProgramId === BModels.ProgramKey.EProgramId.CesiumIon);
23470
+ // Use if marked as available.
23471
+ if (ionCheckApi.IsVersionAtLeast(BModels.BruceApi.VERSION_WITH_PROXIES)) {
23472
+ shouldCreate = (ionKey === null || ionKey === void 0 ? void 0 : ionKey.Available) === true;
23473
+ }
23474
+ // Legacy route, to be killed off.
23475
+ else {
23476
+ shouldCreate = (ionKey === null || ionKey === void 0 ? void 0 : ionKey.Key) ? await exports.ViewerUtils.AssertIonToken(ionKey.Key) : false;
23477
+ }
23444
23478
  }
23445
23479
  if (shouldCreate) {
23446
23480
  provider = await renderDefaultTerrTile(defaultTerr.id);
@@ -23772,31 +23806,27 @@
23772
23806
  try {
23773
23807
  const bruceApi = getters.GetBruceApi();
23774
23808
  await bruceApi.Loading;
23775
- // Proxy path: token injected server-side.
23809
+ // Get token record to check availability.
23810
+ const { programKeys } = await BModels.ProgramKey.GetList({ api: bruceApi });
23811
+ const ionKey = programKeys.find(k => k.ProgramId === BModels.ProgramKey.EProgramId.CesiumIon);
23776
23812
  if (bruceApi.IsVersionAtLeast(BModels.BruceApi.VERSION_WITH_PROXIES)) {
23777
- Cesium.Ion.defaultServer = bruceApi.GetBaseUrl() + "proxy/cesium-ion/";
23778
- Cesium.Ion.defaultAccessToken = "proxy";
23779
- cTokenSet = true;
23813
+ // Marked as available.
23814
+ if (ionKey === null || ionKey === void 0 ? void 0 : ionKey.Available) {
23815
+ Cesium.Ion.defaultServer = bruceApi.GetBaseUrl() + "proxy/cesium-ion/";
23816
+ Cesium.Ion.defaultAccessToken = "proxy";
23817
+ cTokenSet = true;
23818
+ }
23780
23819
  }
23781
- // Legacy path: fetch real Ion token from DB.
23782
- // Kill off once API instances are migrated.
23783
23820
  else {
23784
- try {
23785
- const { programKey } = await BModels.ProgramKey.Get({
23786
- programId: BModels.ProgramKey.EProgramId.CesiumIon,
23787
- api: bruceApi
23788
- });
23789
- if (programKey === null || programKey === void 0 ? void 0 : programKey.Key) {
23790
- const valid = await exports.ViewerUtils.AssertIonToken(programKey.Key);
23791
- if (valid) {
23792
- Cesium.Ion.defaultAccessToken = programKey.Key;
23793
- cTokenSet = true;
23794
- }
23821
+ // Legacy path: fetch real Ion token from DB.
23822
+ // Kill off once API instances are migrated.
23823
+ if (ionKey === null || ionKey === void 0 ? void 0 : ionKey.Key) {
23824
+ const valid = await exports.ViewerUtils.AssertIonToken(ionKey.Key);
23825
+ if (valid) {
23826
+ Cesium.Ion.defaultAccessToken = ionKey.Key;
23827
+ cTokenSet = true;
23795
23828
  }
23796
23829
  }
23797
- catch (e) {
23798
- console.error(e);
23799
- }
23800
23830
  }
23801
23831
  }
23802
23832
  catch (e) {
@@ -29609,16 +29639,12 @@
29609
29639
  ViewerUtils.CreateWidgets = CreateWidgets;
29610
29640
  /**
29611
29641
  * Returns if the given token is valid or not.
29612
- * This will perform a test request to Cesium API.
29642
+ * Returns true if the supplied Cesium Ion access token is valid by probing the Ion endpoint.
29643
+ * @warning don't use when going through the proxy API route.
29613
29644
  * @param token
29614
29645
  * @returns
29615
29646
  */
29616
29647
  async function AssertIonToken(token) {
29617
- // If routed through a proxy then we don't need auth on client side for it.
29618
- const defaultServer = Cesium.Ion.defaultServer;
29619
- if (defaultServer && typeof defaultServer === "string" && !defaultServer.includes("cesium.com")) {
29620
- return true;
29621
- }
29622
29648
  if (!token) {
29623
29649
  return false;
29624
29650
  }
@@ -36203,7 +36229,7 @@
36203
36229
  }
36204
36230
  }
36205
36231
 
36206
- const VERSION = "6.6.9";
36232
+ const VERSION = "6.7.0";
36207
36233
  /**
36208
36234
  * Updates the environment instance used by bruce-cesium to one specified.
36209
36235
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.