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.
@@ -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;
@@ -68,9 +68,29 @@ var __read = (this && this.__read) || function (o, n) {
68
68
  };
69
69
  Object.defineProperty(exports, "__esModule", { value: true });
70
70
  exports.PopoutWindow = void 0;
71
+ exports.assertSameOriginPopoutUrl = assertSameOriginPopoutUrl;
71
72
  var dom_1 = require("./dom");
72
73
  var events_1 = require("./events");
73
74
  var lifecycle_1 = require("./lifecycle");
75
+ /**
76
+ * Reject popout URLs that aren't same-origin http(s). Blocks `javascript:`,
77
+ * `data:`, `blob:`, `vbscript:`, and cross-origin URLs that would otherwise
78
+ * execute in a context the browser still associates with the opener via
79
+ * `window.opener`.
80
+ */
81
+ function assertSameOriginPopoutUrl(url) {
82
+ var resolved;
83
+ try {
84
+ resolved = new URL(url, window.location.href);
85
+ }
86
+ catch (_a) {
87
+ throw new Error("dockview: invalid popout URL: ".concat(url));
88
+ }
89
+ var protocolOk = resolved.protocol === 'http:' || resolved.protocol === 'https:';
90
+ if (!protocolOk || resolved.origin !== window.location.origin) {
91
+ throw new Error("dockview: popout URL must be same-origin http(s); got: ".concat(url));
92
+ }
93
+ }
74
94
  var PopoutWindow = /** @class */ (function (_super) {
75
95
  __extends(PopoutWindow, _super);
76
96
  function PopoutWindow(target, className, options) {
@@ -131,6 +151,7 @@ var PopoutWindow = /** @class */ (function (_super) {
131
151
  throw new Error('instance of popout window is already open');
132
152
  }
133
153
  url = "".concat(this.options.url);
154
+ assertSameOriginPopoutUrl(url);
134
155
  features = Object.entries({
135
156
  top: this.options.top,
136
157
  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
  */
@@ -11569,6 +11569,25 @@
11569
11569
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
11570
11570
  };
11571
11571
 
11572
+ /**
11573
+ * Reject popout URLs that aren't same-origin http(s). Blocks `javascript:`,
11574
+ * `data:`, `blob:`, `vbscript:`, and cross-origin URLs that would otherwise
11575
+ * execute in a context the browser still associates with the opener via
11576
+ * `window.opener`.
11577
+ */
11578
+ function assertSameOriginPopoutUrl(url) {
11579
+ let resolved;
11580
+ try {
11581
+ resolved = new URL(url, window.location.href);
11582
+ }
11583
+ catch (_a) {
11584
+ throw new Error(`dockview: invalid popout URL: ${url}`);
11585
+ }
11586
+ const protocolOk = resolved.protocol === 'http:' || resolved.protocol === 'https:';
11587
+ if (!protocolOk || resolved.origin !== window.location.origin) {
11588
+ throw new Error(`dockview: popout URL must be same-origin http(s); got: ${url}`);
11589
+ }
11590
+ }
11572
11591
  class PopoutWindow extends CompositeDisposable {
11573
11592
  get window() {
11574
11593
  var _a, _b;
@@ -11620,6 +11639,7 @@
11620
11639
  throw new Error('instance of popout window is already open');
11621
11640
  }
11622
11641
  const url = `${this.options.url}`;
11642
+ assertSameOriginPopoutUrl(url);
11623
11643
  const features = Object.entries({
11624
11644
  top: this.options.top,
11625
11645
  left: this.options.left,