dockview-core 6.1.1 → 6.2.1

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.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview-core
3
- * @version 6.1.1
3
+ * @version 6.2.1
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -11539,6 +11539,25 @@
11539
11539
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
11540
11540
  };
11541
11541
 
11542
+ /**
11543
+ * Reject popout URLs that aren't same-origin http(s). Blocks `javascript:`,
11544
+ * `data:`, `blob:`, `vbscript:`, and cross-origin URLs that would otherwise
11545
+ * execute in a context the browser still associates with the opener via
11546
+ * `window.opener`.
11547
+ */
11548
+ function assertSameOriginPopoutUrl(url) {
11549
+ let resolved;
11550
+ try {
11551
+ resolved = new URL(url, window.location.href);
11552
+ }
11553
+ catch (_a) {
11554
+ throw new Error(`dockview: invalid popout URL: ${url}`);
11555
+ }
11556
+ const protocolOk = resolved.protocol === 'http:' || resolved.protocol === 'https:';
11557
+ if (!protocolOk || resolved.origin !== window.location.origin) {
11558
+ throw new Error(`dockview: popout URL must be same-origin http(s); got: ${url}`);
11559
+ }
11560
+ }
11542
11561
  class PopoutWindow extends CompositeDisposable {
11543
11562
  get window() {
11544
11563
  var _a, _b;
@@ -11590,6 +11609,7 @@
11590
11609
  throw new Error('instance of popout window is already open');
11591
11610
  }
11592
11611
  const url = `${this.options.url}`;
11612
+ assertSameOriginPopoutUrl(url);
11593
11613
  const features = Object.entries({
11594
11614
  top: this.options.top,
11595
11615
  left: this.options.left,
@@ -11,6 +11,13 @@ export type PopoutWindowOptions = {
11
11
  window: Window;
12
12
  }) => void;
13
13
  } & Box;
14
+ /**
15
+ * Reject popout URLs that aren't same-origin http(s). Blocks `javascript:`,
16
+ * `data:`, `blob:`, `vbscript:`, and cross-origin URLs that would otherwise
17
+ * execute in a context the browser still associates with the opener via
18
+ * `window.opener`.
19
+ */
20
+ export declare function assertSameOriginPopoutUrl(url: string): void;
14
21
  export declare class PopoutWindow extends CompositeDisposable {
15
22
  private readonly target;
16
23
  private readonly className;
@@ -10,6 +10,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { addStyles } from './dom';
11
11
  import { Emitter, addDisposableListener } from './events';
12
12
  import { CompositeDisposable, Disposable } from './lifecycle';
13
+ /**
14
+ * Reject popout URLs that aren't same-origin http(s). Blocks `javascript:`,
15
+ * `data:`, `blob:`, `vbscript:`, and cross-origin URLs that would otherwise
16
+ * execute in a context the browser still associates with the opener via
17
+ * `window.opener`.
18
+ */
19
+ export function assertSameOriginPopoutUrl(url) {
20
+ let resolved;
21
+ try {
22
+ resolved = new URL(url, window.location.href);
23
+ }
24
+ catch (_a) {
25
+ throw new Error(`dockview: invalid popout URL: ${url}`);
26
+ }
27
+ const protocolOk = resolved.protocol === 'http:' || resolved.protocol === 'https:';
28
+ if (!protocolOk || resolved.origin !== window.location.origin) {
29
+ throw new Error(`dockview: popout URL must be same-origin http(s); got: ${url}`);
30
+ }
31
+ }
13
32
  export class PopoutWindow extends CompositeDisposable {
14
33
  get window() {
15
34
  var _a, _b;
@@ -61,6 +80,7 @@ export class PopoutWindow extends CompositeDisposable {
61
80
  throw new Error('instance of popout window is already open');
62
81
  }
63
82
  const url = `${this.options.url}`;
83
+ assertSameOriginPopoutUrl(url);
64
84
  const features = Object.entries({
65
85
  top: this.options.top,
66
86
  left: this.options.left,
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview-core
3
- * @version 6.1.1
3
+ * @version 6.2.1
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -11535,6 +11535,25 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
11535
11535
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
11536
11536
  };
11537
11537
 
11538
+ /**
11539
+ * Reject popout URLs that aren't same-origin http(s). Blocks `javascript:`,
11540
+ * `data:`, `blob:`, `vbscript:`, and cross-origin URLs that would otherwise
11541
+ * execute in a context the browser still associates with the opener via
11542
+ * `window.opener`.
11543
+ */
11544
+ function assertSameOriginPopoutUrl(url) {
11545
+ let resolved;
11546
+ try {
11547
+ resolved = new URL(url, window.location.href);
11548
+ }
11549
+ catch (_a) {
11550
+ throw new Error(`dockview: invalid popout URL: ${url}`);
11551
+ }
11552
+ const protocolOk = resolved.protocol === 'http:' || resolved.protocol === 'https:';
11553
+ if (!protocolOk || resolved.origin !== window.location.origin) {
11554
+ throw new Error(`dockview: popout URL must be same-origin http(s); got: ${url}`);
11555
+ }
11556
+ }
11538
11557
  class PopoutWindow extends CompositeDisposable {
11539
11558
  get window() {
11540
11559
  var _a, _b;
@@ -11586,6 +11605,7 @@ class PopoutWindow extends CompositeDisposable {
11586
11605
  throw new Error('instance of popout window is already open');
11587
11606
  }
11588
11607
  const url = `${this.options.url}`;
11608
+ assertSameOriginPopoutUrl(url);
11589
11609
  const features = Object.entries({
11590
11610
  top: this.options.top,
11591
11611
  left: this.options.left,