bruce-models 7.1.49 → 7.1.51

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.
@@ -1138,6 +1138,23 @@ class AbstractApi {
1138
1138
  SetSessionId(value) {
1139
1139
  this.ssid = prepSessionId(value);
1140
1140
  }
1141
+ /**
1142
+ * Injects auth header into the headers object.
1143
+ */
1144
+ applyAuthHeader(headers) {
1145
+ if (!this.ssidHeader) {
1146
+ return;
1147
+ }
1148
+ const token = this.GetSessionId();
1149
+ if (this.ssidHeader.toLowerCase() === "authorization") {
1150
+ if (token && token !== "anonymous") {
1151
+ headers["Authorization"] = `Bearer ${token}`;
1152
+ }
1153
+ }
1154
+ else if (token) {
1155
+ headers[this.ssidHeader] = token;
1156
+ }
1157
+ }
1141
1158
  /**
1142
1159
  * Returns the session header.
1143
1160
  * @returns
@@ -1166,9 +1183,7 @@ class AbstractApi {
1166
1183
  }
1167
1184
  params.headers = params.headers || {};
1168
1185
  params.headers = Object.assign({ "Content-Type": "application/json;" }, params.headers);
1169
- if (this.ssidHeader) {
1170
- params.headers[this.ssidHeader] = this.GetSessionId();
1171
- }
1186
+ this.applyAuthHeader(params.headers);
1172
1187
  const res = yield fetch(url, {
1173
1188
  headers: params.headers,
1174
1189
  signal: params.abortSignal
@@ -1190,9 +1205,7 @@ class AbstractApi {
1190
1205
  }
1191
1206
  params.headers = params.headers || {};
1192
1207
  params.headers = Object.assign({ "Content-Type": "application/json;" }, params.headers);
1193
- if (this.ssidHeader) {
1194
- params.headers[this.ssidHeader] = this.GetSessionId();
1195
- }
1208
+ this.applyAuthHeader(params.headers);
1196
1209
  const res = yield fetch(url, {
1197
1210
  headers: params.headers,
1198
1211
  method: "DELETE",
@@ -1216,9 +1229,7 @@ class AbstractApi {
1216
1229
  }
1217
1230
  params.headers = params.headers || {};
1218
1231
  params.headers = Object.assign({ "Content-Type": "application/json;" }, params.headers);
1219
- if (this.ssidHeader) {
1220
- params.headers[this.ssidHeader] = this.GetSessionId();
1221
- }
1232
+ this.applyAuthHeader(params.headers);
1222
1233
  if (!data) {
1223
1234
  data = {};
1224
1235
  }
@@ -1249,9 +1260,7 @@ class AbstractApi {
1249
1260
  }
1250
1261
  params.headers = params.headers || {};
1251
1262
  params.headers = Object.assign({ "Content-Type": "application/json;" }, params.headers);
1252
- if (this.ssidHeader) {
1253
- params.headers[this.ssidHeader] = this.GetSessionId();
1254
- }
1263
+ this.applyAuthHeader(params.headers);
1255
1264
  if (!data) {
1256
1265
  data = {};
1257
1266
  }
@@ -1281,9 +1290,7 @@ class AbstractApi {
1281
1290
  params = {};
1282
1291
  }
1283
1292
  params.headers = Object.assign({}, params.headers);
1284
- if (this.ssidHeader) {
1285
- params.headers[this.ssidHeader] = this.GetSessionId();
1286
- }
1293
+ this.applyAuthHeader(params.headers);
1287
1294
  const formData = params.formData instanceof FormData ? params.formData : new FormData();
1288
1295
  if (formData.has("file")) {
1289
1296
  formData.delete("file");
@@ -1367,7 +1374,7 @@ var GuardianApi;
1367
1374
  class Api$$1 extends AbstractApi {
1368
1375
  constructor(params) {
1369
1376
  super({
1370
- ssidHeader: "x-sessionid",
1377
+ ssidHeader: "Authorization",
1371
1378
  cacheId: `GUARDIAN_API_${params === null || params === void 0 ? void 0 : params.env}_`
1372
1379
  });
1373
1380
  this.env = (params === null || params === void 0 ? void 0 : params.env) ? params.env : Api.EEnv.PROD;
@@ -1511,7 +1518,7 @@ var BruceApi;
1511
1518
  }
1512
1519
  constructor(params) {
1513
1520
  super({
1514
- ssidHeader: "x-sessionid",
1521
+ ssidHeader: "Authorization",
1515
1522
  cacheId: `BRUCE_API_${params === null || params === void 0 ? void 0 : params.env}_${params === null || params === void 0 ? void 0 : params.accountId}_`
1516
1523
  });
1517
1524
  // Load cancelled indicates the user set a custom base url.
@@ -18989,7 +18996,7 @@ var UrlUtils;
18989
18996
  })(UrlUtils || (UrlUtils = {}));
18990
18997
 
18991
18998
  // This is updated with the package.json version on build.
18992
- const VERSION = "7.1.49";
18999
+ const VERSION = "7.1.51";
18993
19000
 
18994
19001
  export { VERSION, Account, AccountConcept, AccountFeatures, AccountInvite, AccountLimits, AccountTemplate, AccountType, AnnDocument, AbstractApi, Api, ApiGetters, BruceApi, GlobalApi, GuardianApi, Assembly, Calculator, ChangeSet, ClientFile, Bounds, BruceEvent, BruceVariable, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, GeoJson, Geometry, LRUCache, UTC, CustomForm, DashboardView, DataFeed, DataLab, DataLabGroup, DataSource, DataTransform, Comment, Entity, EntityAttachment, EntityAttachmentType, EntityAttribute, EntityComment, EntityCoords, EntityHistoricData, EntityLink, EntityLod, EntityLodCategory, EntityRelation, EntityRelationType, EntitySource, EntityTableView, EntityTag, EntityType, EntityTypeTrigger, ENVIRONMENT, ExportBrz, ExportUsd, ImportAssembly, ImportCad, ImportCsv, ImportGeoJson, ImportJson, ImportKml, ImportLcc, ImportedFile, Uploader, Markup, NAVIGATOR_CHAT_EVENT_ENTITY_HIGHLIGHT_APPLIED, NAVIGATOR_CHAT_EVENT_SCENE_CONTEXT_PREFETCHED, NavigatorChatClient, NavigatorMcpWebSocketClient, Plugin, ProgramKey, MenuItem, ProjectView, ProjectViewBookmark, ProjectViewBookmarkGroup, ProjectViewLegacy, ProjectViewLegacyBookmark, ProjectViewLegacyTile, ProjectViewTile, ZoomControl, Scenario, HostingLocation, MessageBroker, PendingAction, RecordChangeFeed, Style, Tileset, Tracking, Permission, Session, User, UserGroup, UserMfaMethod, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils };
18995
19002
  //# sourceMappingURL=bruce-models.es5.js.map