@itwin/core-frontend 5.13.0-dev.8 → 5.13.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.
- package/CHANGELOG.md +50 -1
- package/lib/cjs/BriefcaseTxns.d.ts +9 -0
- package/lib/cjs/BriefcaseTxns.d.ts.map +1 -1
- package/lib/cjs/BriefcaseTxns.js +9 -0
- package/lib/cjs/BriefcaseTxns.js.map +1 -1
- package/lib/cjs/EmphasizeElements.d.ts +4 -1
- package/lib/cjs/EmphasizeElements.d.ts.map +1 -1
- package/lib/cjs/EmphasizeElements.js +16 -9
- package/lib/cjs/EmphasizeElements.js.map +1 -1
- package/lib/cjs/IModelApp.d.ts +11 -1
- package/lib/cjs/IModelApp.d.ts.map +1 -1
- package/lib/cjs/IModelApp.js +14 -1
- package/lib/cjs/IModelApp.js.map +1 -1
- package/lib/cjs/IModeljs-css.d.ts.map +1 -1
- package/lib/cjs/IModeljs-css.js +4 -2
- package/lib/cjs/IModeljs-css.js.map +1 -1
- package/lib/cjs/RealityDataSource.d.ts.map +1 -1
- package/lib/cjs/RealityDataSource.js +7 -4
- package/lib/cjs/RealityDataSource.js.map +1 -1
- package/lib/cjs/TxnEntityChanges.d.ts +4 -18
- package/lib/cjs/TxnEntityChanges.d.ts.map +1 -1
- package/lib/cjs/TxnEntityChanges.js.map +1 -1
- package/lib/cjs/ViewManager.d.ts +3 -0
- package/lib/cjs/ViewManager.d.ts.map +1 -1
- package/lib/cjs/ViewManager.js +9 -1
- package/lib/cjs/ViewManager.js.map +1 -1
- package/lib/cjs/Viewport.d.ts +7 -1
- package/lib/cjs/Viewport.d.ts.map +1 -1
- package/lib/cjs/Viewport.js +13 -1
- package/lib/cjs/Viewport.js.map +1 -1
- package/lib/cjs/core-frontend.d.ts +7 -1
- package/lib/cjs/core-frontend.d.ts.map +1 -1
- package/lib/cjs/core-frontend.js.map +1 -1
- package/lib/cjs/internal/GoogleMapsDecorator.js +1 -1
- package/lib/cjs/internal/GoogleMapsDecorator.js.map +1 -1
- package/lib/cjs/internal/tile/OrbitGtTileTree.d.ts +11 -1
- package/lib/cjs/internal/tile/OrbitGtTileTree.d.ts.map +1 -1
- package/lib/cjs/internal/tile/OrbitGtTileTree.js +49 -3
- package/lib/cjs/internal/tile/OrbitGtTileTree.js.map +1 -1
- package/lib/cjs/internal/tile/RealityModelTileTree.d.ts.map +1 -1
- package/lib/cjs/internal/tile/RealityModelTileTree.js +5 -1
- package/lib/cjs/internal/tile/RealityModelTileTree.js.map +1 -1
- package/lib/cjs/internal/tile/map/ArcGisUtilities.d.ts +3 -0
- package/lib/cjs/internal/tile/map/ArcGisUtilities.d.ts.map +1 -1
- package/lib/cjs/internal/tile/map/ArcGisUtilities.js +32 -4
- package/lib/cjs/internal/tile/map/ArcGisUtilities.js.map +1 -1
- package/lib/cjs/internal/tile/map/ImageryProviders/ArcGISImageryProvider.d.ts.map +1 -1
- package/lib/cjs/internal/tile/map/ImageryProviders/ArcGISImageryProvider.js +28 -6
- package/lib/cjs/internal/tile/map/ImageryProviders/ArcGISImageryProvider.js.map +1 -1
- package/lib/cjs/internal/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.d.ts.map +1 -1
- package/lib/cjs/internal/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js +7 -3
- package/lib/cjs/internal/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js.map +1 -1
- package/lib/cjs/internal/tile/map/ImageryProviders/BingImageryProvider.d.ts.map +1 -1
- package/lib/cjs/internal/tile/map/ImageryProviders/BingImageryProvider.js +1 -7
- package/lib/cjs/internal/tile/map/ImageryProviders/BingImageryProvider.js.map +1 -1
- package/lib/cjs/internal/tile/map/ImageryProviders/WmsMapLayerImageryProvider.d.ts.map +1 -1
- package/lib/cjs/internal/tile/map/ImageryProviders/WmsMapLayerImageryProvider.js +4 -1
- package/lib/cjs/internal/tile/map/ImageryProviders/WmsMapLayerImageryProvider.js.map +1 -1
- package/lib/cjs/internal/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.d.ts.map +1 -1
- package/lib/cjs/internal/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.js +6 -2
- package/lib/cjs/internal/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.js.map +1 -1
- package/lib/cjs/internal/tile/map/WmsCapabilities.d.ts +2 -0
- package/lib/cjs/internal/tile/map/WmsCapabilities.d.ts.map +1 -1
- package/lib/cjs/internal/tile/map/WmsCapabilities.js +28 -6
- package/lib/cjs/internal/tile/map/WmsCapabilities.js.map +1 -1
- package/lib/cjs/internal/tile/map/WmsUtilities.d.ts.map +1 -1
- package/lib/cjs/internal/tile/map/WmsUtilities.js +25 -4
- package/lib/cjs/internal/tile/map/WmsUtilities.js.map +1 -1
- package/lib/cjs/quantity-formatting/QuantityFormatter.d.ts.map +1 -1
- package/lib/cjs/quantity-formatting/QuantityFormatter.js +14 -6
- package/lib/cjs/quantity-formatting/QuantityFormatter.js.map +1 -1
- package/lib/cjs/tile/map/MapLayerFormatRegistry.d.ts +74 -0
- package/lib/cjs/tile/map/MapLayerFormatRegistry.d.ts.map +1 -1
- package/lib/cjs/tile/map/MapLayerFormatRegistry.js +114 -2
- package/lib/cjs/tile/map/MapLayerFormatRegistry.js.map +1 -1
- package/lib/cjs/tile/map/MapLayerImageryFormats.d.ts.map +1 -1
- package/lib/cjs/tile/map/MapLayerImageryFormats.js +16 -0
- package/lib/cjs/tile/map/MapLayerImageryFormats.js.map +1 -1
- package/lib/cjs/tile/map/MapLayerImageryProvider.d.ts +118 -2
- package/lib/cjs/tile/map/MapLayerImageryProvider.d.ts.map +1 -1
- package/lib/cjs/tile/map/MapLayerImageryProvider.js +230 -20
- package/lib/cjs/tile/map/MapLayerImageryProvider.js.map +1 -1
- package/lib/cjs/tile/map/MapLayerSources.d.ts +7 -1
- package/lib/cjs/tile/map/MapLayerSources.d.ts.map +1 -1
- package/lib/cjs/tile/map/MapLayerSources.js +6 -0
- package/lib/cjs/tile/map/MapLayerSources.js.map +1 -1
- package/lib/cjs/tile/map/MapLayerTileTreeReference.d.ts.map +1 -1
- package/lib/cjs/tile/map/MapLayerTileTreeReference.js +1 -3
- package/lib/cjs/tile/map/MapLayerTileTreeReference.js.map +1 -1
- package/lib/cjs/tile/map/MapTileTree.d.ts.map +1 -1
- package/lib/cjs/tile/map/MapTileTree.js +3 -1
- package/lib/cjs/tile/map/MapTileTree.js.map +1 -1
- package/lib/cjs/tools/Tool.d.ts +5 -1
- package/lib/cjs/tools/Tool.d.ts.map +1 -1
- package/lib/cjs/tools/Tool.js +5 -1
- package/lib/cjs/tools/Tool.js.map +1 -1
- package/lib/cjs/tools/ToolAdmin.d.ts +2 -1
- package/lib/cjs/tools/ToolAdmin.d.ts.map +1 -1
- package/lib/cjs/tools/ToolAdmin.js +81 -19
- package/lib/cjs/tools/ToolAdmin.js.map +1 -1
- package/lib/esm/BriefcaseTxns.d.ts +9 -0
- package/lib/esm/BriefcaseTxns.d.ts.map +1 -1
- package/lib/esm/BriefcaseTxns.js +9 -0
- package/lib/esm/BriefcaseTxns.js.map +1 -1
- package/lib/esm/EmphasizeElements.d.ts +4 -1
- package/lib/esm/EmphasizeElements.d.ts.map +1 -1
- package/lib/esm/EmphasizeElements.js +16 -9
- package/lib/esm/EmphasizeElements.js.map +1 -1
- package/lib/esm/IModelApp.d.ts +11 -1
- package/lib/esm/IModelApp.d.ts.map +1 -1
- package/lib/esm/IModelApp.js +14 -1
- package/lib/esm/IModelApp.js.map +1 -1
- package/lib/esm/IModeljs-css.d.ts.map +1 -1
- package/lib/esm/IModeljs-css.js +4 -2
- package/lib/esm/IModeljs-css.js.map +1 -1
- package/lib/esm/RealityDataSource.d.ts.map +1 -1
- package/lib/esm/RealityDataSource.js +7 -4
- package/lib/esm/RealityDataSource.js.map +1 -1
- package/lib/esm/TxnEntityChanges.d.ts +4 -18
- package/lib/esm/TxnEntityChanges.d.ts.map +1 -1
- package/lib/esm/TxnEntityChanges.js.map +1 -1
- package/lib/esm/ViewManager.d.ts +3 -0
- package/lib/esm/ViewManager.d.ts.map +1 -1
- package/lib/esm/ViewManager.js +9 -1
- package/lib/esm/ViewManager.js.map +1 -1
- package/lib/esm/Viewport.d.ts +7 -1
- package/lib/esm/Viewport.d.ts.map +1 -1
- package/lib/esm/Viewport.js +13 -1
- package/lib/esm/Viewport.js.map +1 -1
- package/lib/esm/core-frontend.d.ts +7 -1
- package/lib/esm/core-frontend.d.ts.map +1 -1
- package/lib/esm/core-frontend.js.map +1 -1
- package/lib/esm/internal/GoogleMapsDecorator.js +1 -1
- package/lib/esm/internal/GoogleMapsDecorator.js.map +1 -1
- package/lib/esm/internal/tile/OrbitGtTileTree.d.ts +11 -1
- package/lib/esm/internal/tile/OrbitGtTileTree.d.ts.map +1 -1
- package/lib/esm/internal/tile/OrbitGtTileTree.js +49 -4
- package/lib/esm/internal/tile/OrbitGtTileTree.js.map +1 -1
- package/lib/esm/internal/tile/RealityModelTileTree.d.ts.map +1 -1
- package/lib/esm/internal/tile/RealityModelTileTree.js +5 -1
- package/lib/esm/internal/tile/RealityModelTileTree.js.map +1 -1
- package/lib/esm/internal/tile/map/ArcGisUtilities.d.ts +3 -0
- package/lib/esm/internal/tile/map/ArcGisUtilities.d.ts.map +1 -1
- package/lib/esm/internal/tile/map/ArcGisUtilities.js +33 -5
- package/lib/esm/internal/tile/map/ArcGisUtilities.js.map +1 -1
- package/lib/esm/internal/tile/map/ImageryProviders/ArcGISImageryProvider.d.ts.map +1 -1
- package/lib/esm/internal/tile/map/ImageryProviders/ArcGISImageryProvider.js +29 -7
- package/lib/esm/internal/tile/map/ImageryProviders/ArcGISImageryProvider.js.map +1 -1
- package/lib/esm/internal/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.d.ts.map +1 -1
- package/lib/esm/internal/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js +8 -4
- package/lib/esm/internal/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js.map +1 -1
- package/lib/esm/internal/tile/map/ImageryProviders/BingImageryProvider.d.ts.map +1 -1
- package/lib/esm/internal/tile/map/ImageryProviders/BingImageryProvider.js +1 -7
- package/lib/esm/internal/tile/map/ImageryProviders/BingImageryProvider.js.map +1 -1
- package/lib/esm/internal/tile/map/ImageryProviders/WmsMapLayerImageryProvider.d.ts.map +1 -1
- package/lib/esm/internal/tile/map/ImageryProviders/WmsMapLayerImageryProvider.js +5 -2
- package/lib/esm/internal/tile/map/ImageryProviders/WmsMapLayerImageryProvider.js.map +1 -1
- package/lib/esm/internal/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.d.ts.map +1 -1
- package/lib/esm/internal/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.js +7 -3
- package/lib/esm/internal/tile/map/ImageryProviders/WmtsMapLayerImageryProvider.js.map +1 -1
- package/lib/esm/internal/tile/map/WmsCapabilities.d.ts +2 -0
- package/lib/esm/internal/tile/map/WmsCapabilities.d.ts.map +1 -1
- package/lib/esm/internal/tile/map/WmsCapabilities.js +28 -6
- package/lib/esm/internal/tile/map/WmsCapabilities.js.map +1 -1
- package/lib/esm/internal/tile/map/WmsUtilities.d.ts.map +1 -1
- package/lib/esm/internal/tile/map/WmsUtilities.js +25 -4
- package/lib/esm/internal/tile/map/WmsUtilities.js.map +1 -1
- package/lib/esm/quantity-formatting/QuantityFormatter.d.ts.map +1 -1
- package/lib/esm/quantity-formatting/QuantityFormatter.js +14 -6
- package/lib/esm/quantity-formatting/QuantityFormatter.js.map +1 -1
- package/lib/esm/tile/map/MapLayerFormatRegistry.d.ts +74 -0
- package/lib/esm/tile/map/MapLayerFormatRegistry.d.ts.map +1 -1
- package/lib/esm/tile/map/MapLayerFormatRegistry.js +113 -2
- package/lib/esm/tile/map/MapLayerFormatRegistry.js.map +1 -1
- package/lib/esm/tile/map/MapLayerImageryFormats.d.ts.map +1 -1
- package/lib/esm/tile/map/MapLayerImageryFormats.js +17 -1
- package/lib/esm/tile/map/MapLayerImageryFormats.js.map +1 -1
- package/lib/esm/tile/map/MapLayerImageryProvider.d.ts +118 -2
- package/lib/esm/tile/map/MapLayerImageryProvider.d.ts.map +1 -1
- package/lib/esm/tile/map/MapLayerImageryProvider.js +228 -20
- package/lib/esm/tile/map/MapLayerImageryProvider.js.map +1 -1
- package/lib/esm/tile/map/MapLayerSources.d.ts +7 -1
- package/lib/esm/tile/map/MapLayerSources.d.ts.map +1 -1
- package/lib/esm/tile/map/MapLayerSources.js +6 -0
- package/lib/esm/tile/map/MapLayerSources.js.map +1 -1
- package/lib/esm/tile/map/MapLayerTileTreeReference.d.ts.map +1 -1
- package/lib/esm/tile/map/MapLayerTileTreeReference.js +1 -3
- package/lib/esm/tile/map/MapLayerTileTreeReference.js.map +1 -1
- package/lib/esm/tile/map/MapTileTree.d.ts.map +1 -1
- package/lib/esm/tile/map/MapTileTree.js +4 -2
- package/lib/esm/tile/map/MapTileTree.js.map +1 -1
- package/lib/esm/tools/Tool.d.ts +5 -1
- package/lib/esm/tools/Tool.d.ts.map +1 -1
- package/lib/esm/tools/Tool.js +5 -1
- package/lib/esm/tools/Tool.js.map +1 -1
- package/lib/esm/tools/ToolAdmin.d.ts +2 -1
- package/lib/esm/tools/ToolAdmin.d.ts.map +1 -1
- package/lib/esm/tools/ToolAdmin.js +82 -20
- package/lib/esm/tools/ToolAdmin.js.map +1 -1
- package/lib/public/scripts/parse-imdl-worker.js +2 -2
- package/package.json +21 -24
|
@@ -7,12 +7,35 @@ import { ScreenViewport } from "../../Viewport";
|
|
|
7
7
|
import { ImageryMapTile, ImageryMapTileTree, MapCartoRectangle, MapFeatureInfoOptions, MapLayerFeatureInfo, MapTilingScheme, QuadId } from "../internal";
|
|
8
8
|
import { HitDetail } from "../../HitDetail";
|
|
9
9
|
import { DecorateContext } from "../../ViewContext";
|
|
10
|
+
/** Escapes HTML metacharacters so the text renders literally when assigned to `innerHTML`.
|
|
11
|
+
* Use for any server- or user-supplied string that ends up in the map tooltip, which is rendered
|
|
12
|
+
* as HTML by [[MapLayerTileTreeReference.getToolTip]].
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export declare function escapeHtml(text: string): string;
|
|
16
|
+
/** Returns the origin (scheme + host + port) of the given URL, or undefined if it cannot be parsed or does
|
|
17
|
+
* not denote a distinct network origin.
|
|
18
|
+
*
|
|
19
|
+
* Only `http:` and `https:` URLs yield an origin. Every other scheme is rejected because opaque URLs
|
|
20
|
+
* — `file:`, `data:`, `about:`, `blob:null`, and the custom protocols Electron hosts commonly register —
|
|
21
|
+
* all serialize to the literal string `"null"`. Comparing those would make unrelated URLs look same-origin,
|
|
22
|
+
* so a single trusted entry could unlock all of them. Callers use this for credential-trust decisions, and
|
|
23
|
+
* returning `undefined` keeps those decisions fail-closed.
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export declare function tryGetOrigin(url: string): string | undefined;
|
|
10
27
|
/** The status of the map layer imagery provider that lets you know if authentication is needed to request tiles.
|
|
11
28
|
* @public
|
|
12
29
|
*/
|
|
13
30
|
export declare enum MapLayerImageryProviderStatus {
|
|
14
31
|
Valid = 0,
|
|
15
|
-
RequireAuth = 1
|
|
32
|
+
RequireAuth = 1,
|
|
33
|
+
/** A request received an authentication challenge, but credentials were withheld because the request origin
|
|
34
|
+
* is not trusted (see [[MapLayerFormatRegistry.restrictCredentialsToTrustedOrigins]]).
|
|
35
|
+
* The blocked origins are available via [[MapLayerImageryProvider.blockedOrigins]].
|
|
36
|
+
* @beta
|
|
37
|
+
*/
|
|
38
|
+
UntrustedOrigin = 2
|
|
16
39
|
}
|
|
17
40
|
/** @internal */
|
|
18
41
|
export interface WGS84Extent {
|
|
@@ -37,7 +60,34 @@ export declare abstract class MapLayerImageryProvider {
|
|
|
37
60
|
/** @internal */
|
|
38
61
|
private _status;
|
|
39
62
|
/** @internal */
|
|
40
|
-
|
|
63
|
+
private readonly _blockedOrigins;
|
|
64
|
+
/** Origins of requests for which credentials were withheld because they are not trusted
|
|
65
|
+
* (see [[MapLayerFormatRegistry.restrictCredentialsToTrustedOrigins]]).
|
|
66
|
+
* Populated when [[status]] transitions to [[MapLayerImageryProviderStatus.UntrustedOrigin]];
|
|
67
|
+
* [[onStatusChanged]] is raised again each time a new origin is added. Cleared by [[resetStatus]].
|
|
68
|
+
* @beta
|
|
69
|
+
*/
|
|
70
|
+
get blockedOrigins(): ReadonlyArray<string>;
|
|
71
|
+
/** Origins for which a previous SSO handshake (i.e. Windows Authentication) succeeded.
|
|
72
|
+
* Browser credentials are only included for subsequent requests targeting these origins,
|
|
73
|
+
* so that a successful handshake with one host does not leak credentials to other hosts
|
|
74
|
+
* this provider may contact.
|
|
75
|
+
* @internal
|
|
76
|
+
*/
|
|
77
|
+
private readonly _ssoSucceededOrigins;
|
|
78
|
+
/** Returns true if browser credentials should be included for the given URL because a previous
|
|
79
|
+
* SSO handshake succeeded for its origin AND the origin is still allowed by the current policy
|
|
80
|
+
* (see [[MapLayerFormatRegistry.isSsoAllowed]]). Re-checking the policy ensures a handshake recorded
|
|
81
|
+
* while enforcement was disabled — or before an origin was removed from
|
|
82
|
+
* [[MapLayerFormatRegistry.trustedCredentialsOrigins]] — does not keep latching credentials on.
|
|
83
|
+
* @internal
|
|
84
|
+
*/
|
|
85
|
+
protected includeUserCredentials(url: string): boolean;
|
|
86
|
+
/** Records that an SSO handshake succeeded for the given URL's origin, so subsequent requests
|
|
87
|
+
* to that origin include browser credentials without going through another 401 challenge.
|
|
88
|
+
* @internal
|
|
89
|
+
*/
|
|
90
|
+
protected recordSsoSucceeded(url: string): void;
|
|
41
91
|
/** @internal */
|
|
42
92
|
protected readonly onFirstRequestCompleted: BeEvent<() => void>;
|
|
43
93
|
/** @internal */
|
|
@@ -53,6 +103,13 @@ export declare abstract class MapLayerImageryProvider {
|
|
|
53
103
|
* @public
|
|
54
104
|
*/
|
|
55
105
|
get supportsMapFeatureInfo(): boolean;
|
|
106
|
+
/** Reset the provider's status to [[MapLayerImageryProviderStatus.Valid]] and clear the list of
|
|
107
|
+
* [[blockedOrigins]] accumulated while in the [[MapLayerImageryProviderStatus.UntrustedOrigin]] state.
|
|
108
|
+
* Raises [[onStatusChanged]] if the status actually changes.
|
|
109
|
+
* Typically called after the user has provided credentials or the application has updated
|
|
110
|
+
* [[MapLayerFormatRegistry.trustedCredentialsOrigins]], so that subsequent requests are re-attempted.
|
|
111
|
+
* @beta
|
|
112
|
+
*/
|
|
56
113
|
resetStatus(): void;
|
|
57
114
|
/** @internal */
|
|
58
115
|
get tileSize(): number;
|
|
@@ -152,8 +209,67 @@ export declare abstract class MapLayerImageryProvider {
|
|
|
152
209
|
protected onStatusUpdated(_newStatus: MapLayerImageryProviderStatus): void;
|
|
153
210
|
/** @internal */
|
|
154
211
|
protected setRequestAuthorization(headers: Headers): void;
|
|
212
|
+
/** Returns true if the given URL has the same origin as this layer's settings URL.
|
|
213
|
+
* Used to avoid leaking credentials to third-party hosts.
|
|
214
|
+
* @internal
|
|
215
|
+
*/
|
|
216
|
+
protected matchesSettingsUrlOrigin(url: string): boolean;
|
|
217
|
+
/** Returns true if the basic-auth credentials from the layer settings may be attached to a request to the given URL.
|
|
218
|
+
* Always true unless [[MapLayerFormatRegistry.restrictCredentialsToTrustedOrigins]] is enabled (opt-in).
|
|
219
|
+
* When enabled, the origin of this layer's settings URL is implicitly trusted (the credentials belong to that
|
|
220
|
+
* server); other origins must be listed in [[MapLayerFormatRegistry.trustedCredentialsOrigins]].
|
|
221
|
+
* See [[MapLayerFormatRegistry.isCredentialsSharingAllowed]].
|
|
222
|
+
* @internal
|
|
223
|
+
*/
|
|
224
|
+
protected isCredentialsSharingAllowed(url: string): boolean;
|
|
225
|
+
/** Returns true if a request to the given URL may be retried with browser credentials included
|
|
226
|
+
* (i.e. SSO / Windows Authentication) after an NTLM or Negotiate http 401 challenge.
|
|
227
|
+
* See [[MapLayerFormatRegistry.isSsoAllowed]].
|
|
228
|
+
* @internal
|
|
229
|
+
*/
|
|
230
|
+
protected isSsoAllowed(url: string): boolean;
|
|
155
231
|
/** @internal */
|
|
156
232
|
makeTileRequest(url: string, timeoutMs?: number, authorization?: string): Promise<Response>;
|
|
233
|
+
/** Records the given URL's origin and transitions the status to [[MapLayerImageryProviderStatus.UntrustedOrigin]].
|
|
234
|
+
* Called when a request received an authentication challenge that could not be answered because the origin
|
|
235
|
+
* is not trusted (see [[MapLayerFormatRegistry.restrictCredentialsToTrustedOrigins]]).
|
|
236
|
+
* Raises [[onStatusChanged]] on the status transition, and again whenever a new origin is added.
|
|
237
|
+
* @internal
|
|
238
|
+
*/
|
|
239
|
+
protected reportBlockedOrigin(url: string): void;
|
|
240
|
+
/** Logs a warning (once per origin, app-wide) when credentials are sent to an origin that would be blocked
|
|
241
|
+
* if [[MapLayerFormatRegistry.restrictCredentialsToTrustedOrigins]] were enabled.
|
|
242
|
+
* Helps applications discover the origins they need to whitelist before opting in to the restriction.
|
|
243
|
+
* See [[MapLayerFormatRegistry.logUntrustedOriginUse]].
|
|
244
|
+
* @internal
|
|
245
|
+
*/
|
|
246
|
+
protected logUntrustedOriginUse(url: string): void;
|
|
247
|
+
/** The redirect policy to apply to a request that carries browser credentials (see [[includeUserCredentials]]).
|
|
248
|
+
*
|
|
249
|
+
* When [[MapLayerFormatRegistry.restrictCredentialsToTrustedOrigins]] is enabled, redirects are refused
|
|
250
|
+
* outright (`"error"`). `fetch` cannot be asked to follow only same-origin redirects, and by the time a
|
|
251
|
+
* followed redirect can be inspected the credentials have already been delivered to the destination — so
|
|
252
|
+
* refusing is the only way to honour the guarantee that credentials reach none but the origins listed in
|
|
253
|
+
* [[MapLayerFormatRegistry.trustedCredentialsOrigins]]. Legitimate same-origin redirects fail as a result;
|
|
254
|
+
* that is the cost of the opt-in restriction.
|
|
255
|
+
*
|
|
256
|
+
* When the restriction is disabled (the default), redirects are followed as before and
|
|
257
|
+
* [[checkCredentialedRedirect]] reports the destination after the fact.
|
|
258
|
+
* @internal
|
|
259
|
+
*/
|
|
260
|
+
protected get credentialedRedirect(): RequestRedirect | undefined;
|
|
261
|
+
/** Detects that a request carrying browser credentials (see [[includeUserCredentials]]) was transparently
|
|
262
|
+
* redirected to a different origin, and reports or logs that origin.
|
|
263
|
+
*
|
|
264
|
+
* This is a **best-effort, after-the-fact** signal used only while
|
|
265
|
+
* [[MapLayerFormatRegistry.restrictCredentialsToTrustedOrigins]] is disabled, where credentialed requests
|
|
266
|
+
* still follow redirects (see [[credentialedRedirect]]). It cannot prevent the exposure — the credentials
|
|
267
|
+
* have already been sent — and it does not fire at all when the destination denies CORS, because `fetch`
|
|
268
|
+
* then rejects instead of returning a `Response`. The destination origin is never latched as SSO-succeeded,
|
|
269
|
+
* so credentials do not keep flowing to it.
|
|
270
|
+
* @internal
|
|
271
|
+
*/
|
|
272
|
+
protected checkCredentialedRedirect(requestedUrl: string, response: Response): void;
|
|
157
273
|
/** @internal */
|
|
158
274
|
makeRequest(url: string, timeoutMs?: number, authorization?: string): Promise<Response>;
|
|
159
275
|
/** Returns a map layer tile at the specified settings. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapLayerImageryProvider.d.ts","sourceRoot":"","sources":["../../../../src/tile/map/MapLayerImageryProvider.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAU,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,WAAW,EAAqB,MAAM,oBAAoB,CAAC;AAIzG,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAA6C,cAAc,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,EAA2B,MAAM,aAAa,CAAC;AAC7N,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAOpD;;GAEG;AACH,oBAAY,6BAA6B;IACvC,KAAK,IAAA;IACL,WAAW,IAAA;
|
|
1
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AC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAWtI,gBAAgB;IACT,uBAAuB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;IAK7E,gBAAgB;IACT,2BAA2B,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,mBAAmB,EAAE,OAAO;IAM/G,gBAAgB;IACT,uBAAuB,CAAC,UAAU,EAAE,WAAW,EAAE,mBAAmB,EAAE,OAAO;IASpF;;OAEG;IACH,SAAS,CAAC,kBAAkB,CAAC,GAAG,EAAE,MAAM;CAQzC"}
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.MapLayerImageryProvider = exports.MapLayerImageryProviderStatus = void 0;
|
|
11
|
+
exports.escapeHtml = escapeHtml;
|
|
12
|
+
exports.tryGetOrigin = tryGetOrigin;
|
|
11
13
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
12
14
|
const core_common_1 = require("@itwin/core-common");
|
|
13
15
|
const core_geometry_1 = require("@itwin/core-geometry");
|
|
@@ -19,6 +21,34 @@ const utils_1 = require("../../request/utils");
|
|
|
19
21
|
const tileImageSize = 256, untiledImageSize = 256;
|
|
20
22
|
const earthRadius = 6378137;
|
|
21
23
|
const doDebugToolTips = false;
|
|
24
|
+
/** Escapes HTML metacharacters so the text renders literally when assigned to `innerHTML`.
|
|
25
|
+
* Use for any server- or user-supplied string that ends up in the map tooltip, which is rendered
|
|
26
|
+
* as HTML by [[MapLayerTileTreeReference.getToolTip]].
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
function escapeHtml(text) {
|
|
30
|
+
return text.replace(/[&<>"']/g, (c) => `&#${c.charCodeAt(0)};`);
|
|
31
|
+
}
|
|
32
|
+
/** Returns the origin (scheme + host + port) of the given URL, or undefined if it cannot be parsed or does
|
|
33
|
+
* not denote a distinct network origin.
|
|
34
|
+
*
|
|
35
|
+
* Only `http:` and `https:` URLs yield an origin. Every other scheme is rejected because opaque URLs
|
|
36
|
+
* — `file:`, `data:`, `about:`, `blob:null`, and the custom protocols Electron hosts commonly register —
|
|
37
|
+
* all serialize to the literal string `"null"`. Comparing those would make unrelated URLs look same-origin,
|
|
38
|
+
* so a single trusted entry could unlock all of them. Callers use this for credential-trust decisions, and
|
|
39
|
+
* returning `undefined` keeps those decisions fail-closed.
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
function tryGetOrigin(url) {
|
|
43
|
+
let parsed;
|
|
44
|
+
try {
|
|
45
|
+
parsed = new URL(url);
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
return (parsed.protocol === "http:" || parsed.protocol === "https:") ? parsed.origin : undefined;
|
|
51
|
+
}
|
|
22
52
|
/** The status of the map layer imagery provider that lets you know if authentication is needed to request tiles.
|
|
23
53
|
* @public
|
|
24
54
|
*/
|
|
@@ -26,6 +56,12 @@ var MapLayerImageryProviderStatus;
|
|
|
26
56
|
(function (MapLayerImageryProviderStatus) {
|
|
27
57
|
MapLayerImageryProviderStatus[MapLayerImageryProviderStatus["Valid"] = 0] = "Valid";
|
|
28
58
|
MapLayerImageryProviderStatus[MapLayerImageryProviderStatus["RequireAuth"] = 1] = "RequireAuth";
|
|
59
|
+
/** A request received an authentication challenge, but credentials were withheld because the request origin
|
|
60
|
+
* is not trusted (see [[MapLayerFormatRegistry.restrictCredentialsToTrustedOrigins]]).
|
|
61
|
+
* The blocked origins are available via [[MapLayerImageryProvider.blockedOrigins]].
|
|
62
|
+
* @beta
|
|
63
|
+
*/
|
|
64
|
+
MapLayerImageryProviderStatus[MapLayerImageryProviderStatus["UntrustedOrigin"] = 2] = "UntrustedOrigin";
|
|
29
65
|
})(MapLayerImageryProviderStatus || (exports.MapLayerImageryProviderStatus = MapLayerImageryProviderStatus = {}));
|
|
30
66
|
/** Abstract class for map layer imagery providers.
|
|
31
67
|
* Map layer imagery providers request and provide tile images and other data. Each map layer from a separate source needs its own imagery provider object.
|
|
@@ -43,7 +79,41 @@ class MapLayerImageryProvider {
|
|
|
43
79
|
/** @internal */
|
|
44
80
|
_status = MapLayerImageryProviderStatus.Valid;
|
|
45
81
|
/** @internal */
|
|
46
|
-
|
|
82
|
+
_blockedOrigins = new Set();
|
|
83
|
+
/** Origins of requests for which credentials were withheld because they are not trusted
|
|
84
|
+
* (see [[MapLayerFormatRegistry.restrictCredentialsToTrustedOrigins]]).
|
|
85
|
+
* Populated when [[status]] transitions to [[MapLayerImageryProviderStatus.UntrustedOrigin]];
|
|
86
|
+
* [[onStatusChanged]] is raised again each time a new origin is added. Cleared by [[resetStatus]].
|
|
87
|
+
* @beta
|
|
88
|
+
*/
|
|
89
|
+
get blockedOrigins() { return [...this._blockedOrigins]; }
|
|
90
|
+
/** Origins for which a previous SSO handshake (i.e. Windows Authentication) succeeded.
|
|
91
|
+
* Browser credentials are only included for subsequent requests targeting these origins,
|
|
92
|
+
* so that a successful handshake with one host does not leak credentials to other hosts
|
|
93
|
+
* this provider may contact.
|
|
94
|
+
* @internal
|
|
95
|
+
*/
|
|
96
|
+
_ssoSucceededOrigins = new Set();
|
|
97
|
+
/** Returns true if browser credentials should be included for the given URL because a previous
|
|
98
|
+
* SSO handshake succeeded for its origin AND the origin is still allowed by the current policy
|
|
99
|
+
* (see [[MapLayerFormatRegistry.isSsoAllowed]]). Re-checking the policy ensures a handshake recorded
|
|
100
|
+
* while enforcement was disabled — or before an origin was removed from
|
|
101
|
+
* [[MapLayerFormatRegistry.trustedCredentialsOrigins]] — does not keep latching credentials on.
|
|
102
|
+
* @internal
|
|
103
|
+
*/
|
|
104
|
+
includeUserCredentials(url) {
|
|
105
|
+
const origin = tryGetOrigin(url);
|
|
106
|
+
return origin !== undefined && this._ssoSucceededOrigins.has(origin) && this.isSsoAllowed(url);
|
|
107
|
+
}
|
|
108
|
+
/** Records that an SSO handshake succeeded for the given URL's origin, so subsequent requests
|
|
109
|
+
* to that origin include browser credentials without going through another 401 challenge.
|
|
110
|
+
* @internal
|
|
111
|
+
*/
|
|
112
|
+
recordSsoSucceeded(url) {
|
|
113
|
+
const origin = tryGetOrigin(url);
|
|
114
|
+
if (origin !== undefined)
|
|
115
|
+
this._ssoSucceededOrigins.add(origin);
|
|
116
|
+
}
|
|
47
117
|
/** @internal */
|
|
48
118
|
onFirstRequestCompleted = new core_bentley_1.BeEvent();
|
|
49
119
|
/** @internal */
|
|
@@ -59,7 +129,17 @@ class MapLayerImageryProvider {
|
|
|
59
129
|
* @public
|
|
60
130
|
*/
|
|
61
131
|
get supportsMapFeatureInfo() { return false; }
|
|
62
|
-
|
|
132
|
+
/** Reset the provider's status to [[MapLayerImageryProviderStatus.Valid]] and clear the list of
|
|
133
|
+
* [[blockedOrigins]] accumulated while in the [[MapLayerImageryProviderStatus.UntrustedOrigin]] state.
|
|
134
|
+
* Raises [[onStatusChanged]] if the status actually changes.
|
|
135
|
+
* Typically called after the user has provided credentials or the application has updated
|
|
136
|
+
* [[MapLayerFormatRegistry.trustedCredentialsOrigins]], so that subsequent requests are re-attempted.
|
|
137
|
+
* @beta
|
|
138
|
+
*/
|
|
139
|
+
resetStatus() {
|
|
140
|
+
this._blockedOrigins.clear();
|
|
141
|
+
this.setStatus(MapLayerImageryProviderStatus.Valid);
|
|
142
|
+
}
|
|
63
143
|
/** @internal */
|
|
64
144
|
get tileSize() { return this._usesCachedTiles ? tileImageSize : untiledImageSize; }
|
|
65
145
|
/** @internal */
|
|
@@ -233,6 +313,32 @@ class MapLayerImageryProvider {
|
|
|
233
313
|
(0, utils_1.setBasicAuthorization)(headers, this._settings.userName, this._settings.password);
|
|
234
314
|
}
|
|
235
315
|
}
|
|
316
|
+
/** Returns true if the given URL has the same origin as this layer's settings URL.
|
|
317
|
+
* Used to avoid leaking credentials to third-party hosts.
|
|
318
|
+
* @internal
|
|
319
|
+
*/
|
|
320
|
+
matchesSettingsUrlOrigin(url) {
|
|
321
|
+
const origin = tryGetOrigin(url);
|
|
322
|
+
return origin !== undefined && origin === tryGetOrigin(this._settings.url);
|
|
323
|
+
}
|
|
324
|
+
/** Returns true if the basic-auth credentials from the layer settings may be attached to a request to the given URL.
|
|
325
|
+
* Always true unless [[MapLayerFormatRegistry.restrictCredentialsToTrustedOrigins]] is enabled (opt-in).
|
|
326
|
+
* When enabled, the origin of this layer's settings URL is implicitly trusted (the credentials belong to that
|
|
327
|
+
* server); other origins must be listed in [[MapLayerFormatRegistry.trustedCredentialsOrigins]].
|
|
328
|
+
* See [[MapLayerFormatRegistry.isCredentialsSharingAllowed]].
|
|
329
|
+
* @internal
|
|
330
|
+
*/
|
|
331
|
+
isCredentialsSharingAllowed(url) {
|
|
332
|
+
return IModelApp_1.IModelApp.mapLayerFormatRegistry.isCredentialsSharingAllowed(url, this._settings.url);
|
|
333
|
+
}
|
|
334
|
+
/** Returns true if a request to the given URL may be retried with browser credentials included
|
|
335
|
+
* (i.e. SSO / Windows Authentication) after an NTLM or Negotiate http 401 challenge.
|
|
336
|
+
* See [[MapLayerFormatRegistry.isSsoAllowed]].
|
|
337
|
+
* @internal
|
|
338
|
+
*/
|
|
339
|
+
isSsoAllowed(url) {
|
|
340
|
+
return IModelApp_1.IModelApp.mapLayerFormatRegistry.isSsoAllowed(url);
|
|
341
|
+
}
|
|
236
342
|
/** @internal */
|
|
237
343
|
async makeTileRequest(url, timeoutMs, authorization) {
|
|
238
344
|
// We want to complete the first request before letting other requests go;
|
|
@@ -252,40 +358,132 @@ class MapLayerImageryProvider {
|
|
|
252
358
|
throw new Error("fetch call failed");
|
|
253
359
|
return response;
|
|
254
360
|
}
|
|
361
|
+
/** Records the given URL's origin and transitions the status to [[MapLayerImageryProviderStatus.UntrustedOrigin]].
|
|
362
|
+
* Called when a request received an authentication challenge that could not be answered because the origin
|
|
363
|
+
* is not trusted (see [[MapLayerFormatRegistry.restrictCredentialsToTrustedOrigins]]).
|
|
364
|
+
* Raises [[onStatusChanged]] on the status transition, and again whenever a new origin is added.
|
|
365
|
+
* @internal
|
|
366
|
+
*/
|
|
367
|
+
reportBlockedOrigin(url) {
|
|
368
|
+
const origin = tryGetOrigin(url) ?? url;
|
|
369
|
+
const isNewOrigin = !this._blockedOrigins.has(origin);
|
|
370
|
+
this._blockedOrigins.add(origin);
|
|
371
|
+
if (this._status !== MapLayerImageryProviderStatus.UntrustedOrigin)
|
|
372
|
+
this.setStatus(MapLayerImageryProviderStatus.UntrustedOrigin);
|
|
373
|
+
else if (isNewOrigin)
|
|
374
|
+
this.onStatusChanged.raiseEvent(this); // status unchanged, but a new origin was blocked
|
|
375
|
+
}
|
|
376
|
+
/** Logs a warning (once per origin, app-wide) when credentials are sent to an origin that would be blocked
|
|
377
|
+
* if [[MapLayerFormatRegistry.restrictCredentialsToTrustedOrigins]] were enabled.
|
|
378
|
+
* Helps applications discover the origins they need to whitelist before opting in to the restriction.
|
|
379
|
+
* See [[MapLayerFormatRegistry.logUntrustedOriginUse]].
|
|
380
|
+
* @internal
|
|
381
|
+
*/
|
|
382
|
+
logUntrustedOriginUse(url) {
|
|
383
|
+
IModelApp_1.IModelApp.mapLayerFormatRegistry.logUntrustedOriginUse(url);
|
|
384
|
+
}
|
|
385
|
+
/** The redirect policy to apply to a request that carries browser credentials (see [[includeUserCredentials]]).
|
|
386
|
+
*
|
|
387
|
+
* When [[MapLayerFormatRegistry.restrictCredentialsToTrustedOrigins]] is enabled, redirects are refused
|
|
388
|
+
* outright (`"error"`). `fetch` cannot be asked to follow only same-origin redirects, and by the time a
|
|
389
|
+
* followed redirect can be inspected the credentials have already been delivered to the destination — so
|
|
390
|
+
* refusing is the only way to honour the guarantee that credentials reach none but the origins listed in
|
|
391
|
+
* [[MapLayerFormatRegistry.trustedCredentialsOrigins]]. Legitimate same-origin redirects fail as a result;
|
|
392
|
+
* that is the cost of the opt-in restriction.
|
|
393
|
+
*
|
|
394
|
+
* When the restriction is disabled (the default), redirects are followed as before and
|
|
395
|
+
* [[checkCredentialedRedirect]] reports the destination after the fact.
|
|
396
|
+
* @internal
|
|
397
|
+
*/
|
|
398
|
+
get credentialedRedirect() {
|
|
399
|
+
return IModelApp_1.IModelApp.mapLayerFormatRegistry.restrictCredentialsToTrustedOrigins ? "error" : undefined;
|
|
400
|
+
}
|
|
401
|
+
/** Detects that a request carrying browser credentials (see [[includeUserCredentials]]) was transparently
|
|
402
|
+
* redirected to a different origin, and reports or logs that origin.
|
|
403
|
+
*
|
|
404
|
+
* This is a **best-effort, after-the-fact** signal used only while
|
|
405
|
+
* [[MapLayerFormatRegistry.restrictCredentialsToTrustedOrigins]] is disabled, where credentialed requests
|
|
406
|
+
* still follow redirects (see [[credentialedRedirect]]). It cannot prevent the exposure — the credentials
|
|
407
|
+
* have already been sent — and it does not fire at all when the destination denies CORS, because `fetch`
|
|
408
|
+
* then rejects instead of returning a `Response`. The destination origin is never latched as SSO-succeeded,
|
|
409
|
+
* so credentials do not keep flowing to it.
|
|
410
|
+
* @internal
|
|
411
|
+
*/
|
|
412
|
+
checkCredentialedRedirect(requestedUrl, response) {
|
|
413
|
+
const finalOrigin = tryGetOrigin(response.url);
|
|
414
|
+
if (!response.url || finalOrigin === undefined || finalOrigin === tryGetOrigin(requestedUrl))
|
|
415
|
+
return;
|
|
416
|
+
if (!this.isSsoAllowed(response.url))
|
|
417
|
+
this.reportBlockedOrigin(response.url);
|
|
418
|
+
else
|
|
419
|
+
this.logUntrustedOriginUse(response.url); // no-op when the restriction is enabled
|
|
420
|
+
}
|
|
255
421
|
/** @internal */
|
|
256
422
|
async makeRequest(url, timeoutMs, authorization) {
|
|
257
423
|
let response;
|
|
258
424
|
let headers;
|
|
259
425
|
let hasCreds = false;
|
|
426
|
+
// Whether this request had basic-auth credentials of its own to offer. Requests carrying a caller-supplied
|
|
427
|
+
// `authorization` are excluded: those bypass the origin policy entirely.
|
|
428
|
+
const hasSettingsCreds = !authorization && !!this._settings.userName && !!this._settings.password;
|
|
260
429
|
if (authorization) {
|
|
261
430
|
headers = new Headers();
|
|
262
431
|
headers.set("Authorization", authorization);
|
|
263
432
|
}
|
|
264
|
-
else if (
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
433
|
+
else if (hasSettingsCreds) {
|
|
434
|
+
if (this.isCredentialsSharingAllowed(url)) {
|
|
435
|
+
hasCreds = true;
|
|
436
|
+
headers = new Headers();
|
|
437
|
+
this.setRequestAuthorization(headers);
|
|
438
|
+
if (!this.matchesSettingsUrlOrigin(url))
|
|
439
|
+
this.logUntrustedOriginUse(url);
|
|
440
|
+
}
|
|
268
441
|
}
|
|
442
|
+
const includeCredentials = this.includeUserCredentials(url);
|
|
269
443
|
const opts = {
|
|
270
444
|
method: "GET",
|
|
271
445
|
headers,
|
|
272
|
-
credentials:
|
|
446
|
+
credentials: includeCredentials ? "include" : undefined,
|
|
447
|
+
redirect: includeCredentials ? this.credentialedRedirect : undefined,
|
|
273
448
|
};
|
|
274
449
|
if (timeoutMs !== undefined)
|
|
275
450
|
(0, utils_1.setRequestTimeout)(opts, timeoutMs);
|
|
276
451
|
response = await fetch(url, opts);
|
|
452
|
+
if (includeCredentials)
|
|
453
|
+
this.checkCredentialedRedirect(url, response);
|
|
454
|
+
// fetch follows redirects transparently, so all trust decisions below target the final
|
|
455
|
+
// (post-redirect) URL reported by the response, not the URL we asked for.
|
|
456
|
+
const challengedUrl = response.url || url;
|
|
277
457
|
if (response.status === 401
|
|
278
458
|
&& (0, utils_1.headersIncludeAuthMethod)(response.headers, ["ntlm", "negotiate"])
|
|
279
|
-
&& !
|
|
459
|
+
&& !includeCredentials
|
|
280
460
|
&& !hasCreds) {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
461
|
+
if (this.isSsoAllowed(challengedUrl)) {
|
|
462
|
+
// Removed the previous headers and make sure "include" credentials is set
|
|
463
|
+
opts.headers = undefined;
|
|
464
|
+
opts.credentials = "include";
|
|
465
|
+
// A Negotiate/NTLM handshake is normally a same-URL 401 round-trip, but in legacy mode we preserve
|
|
466
|
+
// the previous behavior and allow the browser to follow redirects after the authenticated retry.
|
|
467
|
+
opts.redirect = IModelApp_1.IModelApp.mapLayerFormatRegistry.restrictCredentialsToTrustedOrigins ? "error" : undefined;
|
|
468
|
+
this.logUntrustedOriginUse(challengedUrl);
|
|
469
|
+
// We got a http 401 challenge, lets try again with SSO enabled (i.e. Windows Authentication)
|
|
470
|
+
response = await fetch(challengedUrl, opts);
|
|
471
|
+
if (response.status === 200) {
|
|
472
|
+
this.recordSsoSucceeded(challengedUrl); // avoid going through 401 challenges over and over for this origin
|
|
473
|
+
}
|
|
288
474
|
}
|
|
475
|
+
else {
|
|
476
|
+
this.reportBlockedOrigin(challengedUrl);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
else if ((response.status === 401 || response.status === 403) && hasSettingsCreds && !this.isCredentialsSharingAllowed(challengedUrl)) {
|
|
480
|
+
// Some servers answer an unauthenticated request with 403 (Forbidden) rather than a 401 challenge;
|
|
481
|
+
// since this request could not present its credentials to the challenging origin, either status most
|
|
482
|
+
// likely results from that. The permission is recomputed for the challenged URL rather than reusing the
|
|
483
|
+
// decision made for the requested one: `fetch` strips the Authorization header when it follows a
|
|
484
|
+
// cross-origin redirect, so a trusted request can still arrive unauthenticated at an untrusted origin,
|
|
485
|
+
// and conversely a request that started out untrusted may end up at an origin that is trusted.
|
|
486
|
+
this.reportBlockedOrigin(challengedUrl);
|
|
289
487
|
}
|
|
290
488
|
return response;
|
|
291
489
|
}
|
|
@@ -317,16 +515,28 @@ class MapLayerImageryProvider {
|
|
|
317
515
|
}
|
|
318
516
|
/** @internal */
|
|
319
517
|
async toolTipFromUrl(strings, url) {
|
|
320
|
-
|
|
321
|
-
this.
|
|
518
|
+
let headers;
|
|
519
|
+
if (this.isCredentialsSharingAllowed(url)) {
|
|
520
|
+
headers = new Headers();
|
|
521
|
+
this.setRequestAuthorization(headers);
|
|
522
|
+
}
|
|
322
523
|
try {
|
|
524
|
+
const includeCredentials = this.includeUserCredentials(url);
|
|
323
525
|
const response = await fetch(url, {
|
|
324
526
|
method: "GET",
|
|
325
527
|
headers,
|
|
326
|
-
credentials:
|
|
528
|
+
credentials: includeCredentials ? "include" : undefined,
|
|
529
|
+
redirect: includeCredentials ? this.credentialedRedirect : undefined,
|
|
327
530
|
});
|
|
328
|
-
|
|
329
|
-
|
|
531
|
+
if (includeCredentials)
|
|
532
|
+
this.checkCredentialedRedirect(url, response);
|
|
533
|
+
let text = await response.text();
|
|
534
|
+
if (text) {
|
|
535
|
+
// Tooltip content (e.g. WMS GetFeatureInfo responses) is rendered as HTML downstream and may
|
|
536
|
+
// deliberately contain markup; text from origins not trusted for credentials is escaped.
|
|
537
|
+
// fetch follows redirects transparently, so the text may come from a different origin than requested.
|
|
538
|
+
if (!this.isCredentialsSharingAllowed(response.url || url))
|
|
539
|
+
text = escapeHtml(text);
|
|
330
540
|
strings.push(text);
|
|
331
541
|
}
|
|
332
542
|
}
|