@paciolan/remote-module-loader 3.0.6 → 3.1.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.
- package/.husky/commit-msg +1 -0
- package/.husky/pre-commit +1 -0
- package/.husky/pre-push +1 -0
- package/README.md +39 -10
- package/dist/index.js +4 -15
- package/dist/index.js.map +1 -1
- package/dist/lib/createRequires.js +5 -5
- package/dist/lib/createRequires.js.map +1 -1
- package/dist/lib/loadRemoteModule.js +40 -21
- package/dist/lib/loadRemoteModule.js.map +1 -1
- package/dist/lib/memoize.d.ts +1 -1
- package/dist/lib/memoize.js +5 -5
- package/dist/lib/memoize.js.map +1 -1
- package/dist/lib/nodeFetcher.js +64 -45
- package/dist/lib/nodeFetcher.js.map +1 -1
- package/dist/lib/status.js +1 -1
- package/dist/lib/xmlHttpRequestFetcher/index.js +16 -18
- package/dist/lib/xmlHttpRequestFetcher/index.js.map +1 -1
- package/dist/lib/xmlHttpRequestFetcher/readyState.js +1 -1
- package/dist/models/index.js +1 -1
- package/eslint.config.mjs +39 -0
- package/gl-sast-report.json +4 -4
- package/gl-sbom-npm-npm.cdx.json +781 -1236
- package/gl-secret-detection-report.json +6 -6
- package/package.json +24 -30
- package/tsconfig.json +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npx --no -- commitlint --edit "$1"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npm run lint && npm run build && npm run test:changed
|
package/.husky/pre-push
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npm run test:coverage
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Remote Module Loader 
|
|
2
2
|
|
|
3
|
-
Loads a CommonJS module from a remote URL for the Browser or Node.js.
|
|
3
|
+
Loads a CommonJS, AMD, or UMD module from a remote URL for the Browser or Node.js.
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|
|
|
@@ -61,7 +61,7 @@ export default createLoadRemoteModule({ requires });
|
|
|
61
61
|
|
|
62
62
|
The default loader can be overridden if you want to use an alternate method.
|
|
63
63
|
|
|
64
|
-
This example uses `
|
|
64
|
+
This example uses `fetch` for the fetcher.
|
|
65
65
|
|
|
66
66
|
```javascript
|
|
67
67
|
/**
|
|
@@ -69,9 +69,8 @@ This example uses `axios` for the fetcher.
|
|
|
69
69
|
*/
|
|
70
70
|
|
|
71
71
|
import createLoadRemoteModule from "@paciolan/remote-module-loader";
|
|
72
|
-
import axios from "axios";
|
|
73
72
|
|
|
74
|
-
const fetcher = url =>
|
|
73
|
+
const fetcher = url => fetch(url).then(response => response.text());
|
|
75
74
|
|
|
76
75
|
export default createLoadRemoteModule({ fetcher });
|
|
77
76
|
```
|
|
@@ -139,9 +138,9 @@ main();
|
|
|
139
138
|
|
|
140
139
|
## Creating a Remote Module
|
|
141
140
|
|
|
142
|
-
Remote
|
|
141
|
+
Remote modules can be in CommonJS, AMD, or UMD format. The loader provides both `require`/`module`/`exports` (CommonJS) and `define` (AMD) to every module, so the module itself determines which format to use.
|
|
143
142
|
|
|
144
|
-
|
|
143
|
+
### CommonJS
|
|
145
144
|
|
|
146
145
|
```javascript
|
|
147
146
|
function helloWorld() {
|
|
@@ -163,11 +162,33 @@ exports = {
|
|
|
163
162
|
exports.default = "SUCCESS!";
|
|
164
163
|
```
|
|
165
164
|
|
|
165
|
+
### AMD
|
|
166
|
+
|
|
167
|
+
```javascript
|
|
168
|
+
define(["exports"], function (exports) {
|
|
169
|
+
exports.default = function helloWorld() {
|
|
170
|
+
console.log("Hello World!");
|
|
171
|
+
};
|
|
172
|
+
});
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
AMD modules can also return a value directly from the factory:
|
|
176
|
+
|
|
177
|
+
```javascript
|
|
178
|
+
define(function () {
|
|
179
|
+
return {
|
|
180
|
+
default: function helloWorld() {
|
|
181
|
+
console.log("Hello World!");
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
});
|
|
185
|
+
```
|
|
186
|
+
|
|
166
187
|
### Webpack
|
|
167
188
|
|
|
168
|
-
Webpack can be setup to export as CommonJS.
|
|
189
|
+
Webpack can be setup to export as CommonJS or AMD.
|
|
169
190
|
|
|
170
|
-
Inside `webpack.config.js`, set the `libraryTarget` to `"commonjs"`.
|
|
191
|
+
Inside `webpack.config.js`, set the `libraryTarget` to `"commonjs"` or `"amd"`.
|
|
171
192
|
|
|
172
193
|
```javascript
|
|
173
194
|
module.exports = {
|
|
@@ -177,6 +198,14 @@ module.exports = {
|
|
|
177
198
|
};
|
|
178
199
|
```
|
|
179
200
|
|
|
201
|
+
```javascript
|
|
202
|
+
module.exports = {
|
|
203
|
+
output: {
|
|
204
|
+
libraryTarget: "amd"
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
```
|
|
208
|
+
|
|
180
209
|
Dependencies should be excluded from the bundle because they will be provided by the Web Application can be added to webpack's `externals` section.
|
|
181
210
|
|
|
182
211
|
This will prevent webpack from bundling duplicate 3rd party libraries, decreasing the bundle size.
|
|
@@ -196,7 +225,7 @@ module.exports = {
|
|
|
196
225
|
|
|
197
226
|
Sites with a `content_security_policy` header set are likely to not work. CSP puts a restriction on using `new Function`, which `remote-module-loader` relies upon.
|
|
198
227
|
|
|
199
|
-
[Read more on CSP](https://developer.
|
|
228
|
+
[Read more on CSP](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP)
|
|
200
229
|
|
|
201
230
|
## Alternatives
|
|
202
231
|
|
|
@@ -204,6 +233,6 @@ Sites with a `content_security_policy` header set are likely to not work. CSP pu
|
|
|
204
233
|
|
|
205
234
|
## Contributors
|
|
206
235
|
|
|
207
|
-
Joel Thoms (https://
|
|
236
|
+
Joel Thoms (https://x.com/joelnet)
|
|
208
237
|
|
|
209
238
|
Icon made by [Freepik](https://www.flaticon.com/authors/freepik) from [www.flaticon.com](www.flaticon.com)
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
exports.__esModule = true;
|
|
14
|
-
exports.createRequires = exports["default"] = void 0;
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createRequires = exports.default = void 0;
|
|
15
4
|
var loadRemoteModule_1 = require("./lib/loadRemoteModule");
|
|
16
|
-
|
|
5
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return loadRemoteModule_1.createLoadRemoteModule; } });
|
|
17
6
|
var createRequires_1 = require("./lib/createRequires");
|
|
18
|
-
|
|
7
|
+
Object.defineProperty(exports, "createRequires", { enumerable: true, get: function () { return createRequires_1.createRequires; } });
|
|
19
8
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,2DAA2E;AAAlE,2GAAA,sBAAsB,OAAW;AAC1C,uDAAsD;AAA7C,gHAAA,cAAc,OAAA"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createRequires = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const createRequires = dependencies => name => {
|
|
5
|
+
const _dependencies = dependencies || {};
|
|
6
6
|
if (!(name in _dependencies)) {
|
|
7
|
-
throw new Error(
|
|
7
|
+
throw new Error(`Could not require '${name}'. '${name}' does not exist in dependencies.`);
|
|
8
8
|
}
|
|
9
9
|
return _dependencies[name];
|
|
10
|
-
};
|
|
10
|
+
};
|
|
11
11
|
exports.createRequires = createRequires;
|
|
12
12
|
//# sourceMappingURL=createRequires.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRequires.js","sourceRoot":"","sources":["../../src/lib/createRequires.ts"],"names":[],"mappings":";;;AAQO,
|
|
1
|
+
{"version":3,"file":"createRequires.js","sourceRoot":"","sources":["../../src/lib/createRequires.ts"],"names":[],"mappings":";;;AAQO,MAAM,cAAc,GAAmB,YAAY,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE;IACnE,MAAM,aAAa,GAAG,YAAY,IAAI,EAAE,CAAC;IAEzC,IAAI,CAAC,CAAC,IAAI,IAAI,aAAa,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CACb,sBAAsB,IAAI,OAAO,IAAI,mCAAmC,CACzE,CAAC;IACJ,CAAC;IAED,OAAQ,aAAqC,CAAC,IAAI,CAAC,CAAC;AACtD,CAAC,CAAC;AAVW,QAAA,cAAc,kBAUzB"}
|
|
@@ -1,29 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.createLoadRemoteModule = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
const memoize_1 = __importDefault(require("./memoize"));
|
|
8
|
+
const nodeFetcher_1 = __importDefault(require("./nodeFetcher"));
|
|
9
|
+
const index_1 = __importDefault(require("./xmlHttpRequestFetcher/index"));
|
|
7
10
|
/* istanbul ignore next - environment detection */
|
|
8
|
-
|
|
11
|
+
const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
9
12
|
/* istanbul ignore next - difficult to test */
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
throw new Error(
|
|
13
|
+
const defaultFetcher = isBrowser ? index_1.default : nodeFetcher_1.default;
|
|
14
|
+
const defaultRequires = (name) => {
|
|
15
|
+
throw new Error(`Could not require '${name}'. The 'requires' function was not provided.`);
|
|
13
16
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
const createLoadRemoteModule = ({ requires, fetcher } = {}) => {
|
|
18
|
+
const _requires = requires || defaultRequires;
|
|
19
|
+
const _fetcher = fetcher || defaultFetcher;
|
|
20
|
+
return (0, memoize_1.default)((url) => _fetcher(url).then(data => {
|
|
21
|
+
const exports = {};
|
|
22
|
+
const module = { exports };
|
|
23
|
+
const define = (...args) => {
|
|
24
|
+
let factory;
|
|
25
|
+
let deps;
|
|
26
|
+
if (typeof args[args.length - 1] === "function") {
|
|
27
|
+
factory = args.pop();
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
module.exports = args[args.length - 1];
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
deps = Array.isArray(args[args.length - 1]) ? args.pop() : ["require", "exports", "module"];
|
|
34
|
+
const builtins = { exports, require: _requires, module };
|
|
35
|
+
const resolved = deps.map(dep => builtins[dep] || _requires(dep));
|
|
36
|
+
const result = factory(...resolved);
|
|
37
|
+
if (result !== undefined) {
|
|
38
|
+
module.exports = result;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
define.amd = {};
|
|
42
|
+
const func = new Function("require", "module", "exports", "define", data);
|
|
43
|
+
func(_requires, module, exports, define);
|
|
44
|
+
return module.exports;
|
|
45
|
+
}));
|
|
27
46
|
};
|
|
28
47
|
exports.createLoadRemoteModule = createLoadRemoteModule;
|
|
29
48
|
//# sourceMappingURL=loadRemoteModule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadRemoteModule.js","sourceRoot":"","sources":["../../src/lib/loadRemoteModule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"loadRemoteModule.js","sourceRoot":"","sources":["../../src/lib/loadRemoteModule.ts"],"names":[],"mappings":";;;;;;AACA,wDAAgC;AAChC,gEAAwC;AACxC,0EAAkE;AAElE,kDAAkD;AAClD,MAAM,SAAS,GACb,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW,CAAC;AAE1E,8CAA8C;AAC9C,MAAM,cAAc,GAAG,SAAS,CAAC,CAAC,CAAC,eAAqB,CAAC,CAAC,CAAC,qBAAW,CAAC;AAEvE,MAAM,eAAe,GAAG,CAAC,IAAY,EAAE,EAAE;IACvC,MAAM,IAAI,KAAK,CACb,sBAAsB,IAAI,8CAA8C,CACzE,CAAC;AACJ,CAAC,CAAC;AAeK,MAAM,sBAAsB,GAA2B,CAAC,EAC7D,QAAQ,EACR,OAAO,EACR,GAAG,EAAE,EAAE,EAAE;IACR,MAAM,SAAS,GAAG,QAAQ,IAAI,eAAe,CAAC;IAC9C,MAAM,QAAQ,GAAG,OAAO,IAAI,cAAc,CAAC;IAE3C,OAAO,IAAA,iBAAO,EAAC,CAAC,GAAW,EAAE,EAAE,CAC7B,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QACxB,MAAM,OAAO,GAAG,EAAE,CAAC;QACnB,MAAM,MAAM,GAAG,EAAE,OAAO,EAAE,CAAC;QAE3B,MAAM,MAAM,GAAQ,CAAC,GAAG,IAAW,EAAE,EAAE;YACrC,IAAI,OAAiB,CAAC;YACtB,IAAI,IAAc,CAAC;YAEnB,IAAI,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CA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+1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
/**
|
|
4
4
|
* Memoizes a 1-arity function
|
|
5
5
|
*
|
|
6
6
|
* @param {Function} func Function to memoize
|
|
7
7
|
* @returns {Function} Memoized version of func.
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return
|
|
9
|
+
const memoize = (func) => {
|
|
10
|
+
const cache = {};
|
|
11
|
+
return (key) => {
|
|
12
12
|
if (key in cache == false) {
|
|
13
13
|
cache[key] = func(key);
|
|
14
14
|
}
|
|
15
15
|
return cache[key];
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
|
-
exports
|
|
18
|
+
exports.default = memoize;
|
|
19
19
|
//# sourceMappingURL=memoize.js.map
|
package/dist/lib/memoize.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memoize.js","sourceRoot":"","sources":["../../src/lib/memoize.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,
|
|
1
|
+
{"version":3,"file":"memoize.js","sourceRoot":"","sources":["../../src/lib/memoize.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,MAAM,OAAO,GAAG,CAAC,IAA0B,EAAE,EAAE;IAC7C,MAAM,KAAK,GAAwB,EAAE,CAAC;IACtC,OAAO,CAAC,GAAW,EAAE,EAAE;QACrB,IAAI,GAAG,IAAI,KAAK,IAAI,KAAK,EAAE,CAAC;YAC1B,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;QACzB,CAAC;QACD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
package/dist/lib/nodeFetcher.js
CHANGED
|
@@ -1,63 +1,82 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
if (
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
7
|
}
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const http = __importStar(require("http"));
|
|
37
|
+
const https = __importStar(require("https"));
|
|
38
|
+
const status_1 = require("./status");
|
|
15
39
|
/**
|
|
16
40
|
* Get's a url. Compatible with http and https.
|
|
17
41
|
*/
|
|
18
|
-
|
|
19
|
-
var args = [];
|
|
20
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
21
|
-
args[_i - 1] = arguments[_i];
|
|
22
|
-
}
|
|
42
|
+
const get = (url, ...args) => {
|
|
23
43
|
if (typeof url !== "string") {
|
|
24
44
|
return {
|
|
25
|
-
on
|
|
45
|
+
on(eventName, callback) {
|
|
26
46
|
callback(new Error("URL must be a string."));
|
|
27
47
|
}
|
|
28
48
|
};
|
|
29
49
|
}
|
|
30
50
|
return url.indexOf("https://") === 0
|
|
31
|
-
? https.get
|
|
51
|
+
? https.get(url, ...args)
|
|
52
|
+
: http.get(url, ...args);
|
|
32
53
|
};
|
|
33
54
|
/**
|
|
34
55
|
* Get's a URL and returns a Promise
|
|
35
56
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
57
|
+
const nodeFetcher = url => new Promise((resolve, reject) => {
|
|
58
|
+
get(url, (res) => {
|
|
59
|
+
if (res.statusCode !== status_1.OK) {
|
|
60
|
+
return reject(new Error(`HTTP Error Response: ${res.statusCode} ${res.statusMessage} (${url})`));
|
|
61
|
+
}
|
|
62
|
+
let data = null;
|
|
63
|
+
// called when a data chunk is received.
|
|
64
|
+
res.on("data", (chunk) => {
|
|
65
|
+
if (data === null) {
|
|
66
|
+
data = chunk;
|
|
67
|
+
return;
|
|
41
68
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (!res.complete) {
|
|
56
|
-
reject(new Error("Connection closed before response was complete (".concat(url, ")")));
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}).on("error", reject);
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
exports["default"] = nodeFetcher;
|
|
69
|
+
data += chunk;
|
|
70
|
+
});
|
|
71
|
+
// called when the complete response is received.
|
|
72
|
+
res.on("end", () => resolve(data));
|
|
73
|
+
// called when the connection is closed.
|
|
74
|
+
res.on("close", () => {
|
|
75
|
+
if (!res.complete) {
|
|
76
|
+
reject(new Error(`Connection closed before response was complete (${url})`));
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}).on("error", reject);
|
|
80
|
+
});
|
|
81
|
+
exports.default = nodeFetcher;
|
|
63
82
|
//# sourceMappingURL=nodeFetcher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeFetcher.js","sourceRoot":"","sources":["../../src/lib/nodeFetcher.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nodeFetcher.js","sourceRoot":"","sources":["../../src/lib/nodeFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAC7B,6CAA+B;AAE/B,qCAA6B;AAM7B;;GAEG;AACH,MAAM,GAAG,GAAY,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,EAAE;IACpC,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO;YACL,EAAE,CAAC,SAAiB,EAAE,QAA8B;gBAClD,QAAQ,CAAC,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC,CAAC;YAC/C,CAAC;SACoB,CAAC;IAC1B,CAAC;IACD,OAAO,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC;QAClC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;QACzB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,IA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
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
xhr.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
xhr.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
exports["default"] = xmlHttpRequestFetcher;
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const status_1 = require("../status");
|
|
4
|
+
const readyState_1 = require("./readyState");
|
|
5
|
+
const xmlHttpRequestFetcher = url => new Promise((resolve, reject) => {
|
|
6
|
+
const xhr = new XMLHttpRequest();
|
|
7
|
+
xhr.onreadystatechange = () => {
|
|
8
|
+
if (xhr.readyState !== readyState_1.DONE)
|
|
9
|
+
return;
|
|
10
|
+
xhr.status === status_1.OK
|
|
11
|
+
? resolve(xhr.responseText)
|
|
12
|
+
: reject(new Error(`HTTP Error Response: ${xhr.status} ${xhr.statusText} (${url})`));
|
|
13
|
+
};
|
|
14
|
+
xhr.open("GET", url, true);
|
|
15
|
+
xhr.send();
|
|
16
|
+
});
|
|
17
|
+
exports.default = xmlHttpRequestFetcher;
|
|
20
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/xmlHttpRequestFetcher/index.ts"],"names":[],"mappings":";;AACA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/xmlHttpRequestFetcher/index.ts"],"names":[],"mappings":";;AACA,sCAA+B;AAC/B,6CAAoC;AAEpC,MAAM,qBAAqB,GAAY,GAAG,CAAC,EAAE,CAC3C,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;IAC9B,MAAM,GAAG,GAAG,IAAI,cAAc,EAAE,CAAC;IACjC,GAAG,CAAC,kBAAkB,GAAG,GAAG,EAAE;QAC5B,IAAI,GAAG,CAAC,UAAU,KAAK,iBAAI;YAAE,OAAO;QACpC,GAAG,CAAC,MAAM,KAAK,WAAE;YACf,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;YAC3B,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,wBAAwB,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,UAAU,KAAK,GAAG,GAAG,CAAC,CAAC,CAAA;IACxF,CAAC,CAAC;IACF,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;IAC3B,GAAG,CAAC,IAAI,EAAE,CAAC;AACb,CAAC,CAAC,CAAC;AAEL,kBAAe,qBAAqB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DONE = exports.OPENED = exports.UNSENT = void 0;
|
|
4
4
|
exports.UNSENT = 0; // Client has been created. open() not called yet.
|
|
5
5
|
exports.OPENED = 1; // open() has been called.
|
package/dist/models/index.js
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import eslintPluginPrettier from "eslint-plugin-prettier/recommended";
|
|
2
|
+
|
|
3
|
+
export default [
|
|
4
|
+
{
|
|
5
|
+
ignores: ["dist/"]
|
|
6
|
+
},
|
|
7
|
+
eslintPluginPrettier,
|
|
8
|
+
{
|
|
9
|
+
languageOptions: {
|
|
10
|
+
ecmaVersion: 2019,
|
|
11
|
+
sourceType: "module",
|
|
12
|
+
globals: {
|
|
13
|
+
window: "readonly",
|
|
14
|
+
document: "readonly",
|
|
15
|
+
XMLHttpRequest: "readonly",
|
|
16
|
+
console: "readonly",
|
|
17
|
+
setTimeout: "readonly",
|
|
18
|
+
module: "readonly",
|
|
19
|
+
exports: "readonly",
|
|
20
|
+
require: "readonly",
|
|
21
|
+
process: "readonly",
|
|
22
|
+
__dirname: "readonly",
|
|
23
|
+
describe: "readonly",
|
|
24
|
+
test: "readonly",
|
|
25
|
+
expect: "readonly",
|
|
26
|
+
beforeAll: "readonly",
|
|
27
|
+
beforeEach: "readonly",
|
|
28
|
+
afterAll: "readonly",
|
|
29
|
+
jest: "readonly",
|
|
30
|
+
global: "readonly"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
rules: {
|
|
34
|
+
"prettier/prettier": "error",
|
|
35
|
+
"no-unused-vars": "error",
|
|
36
|
+
"no-undef": "error"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
];
|
package/gl-sast-report.json
CHANGED
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
"version": "1.145.0"
|
|
20
20
|
},
|
|
21
21
|
"type": "sast",
|
|
22
|
-
"start_time": "2026-
|
|
23
|
-
"end_time": "2026-
|
|
22
|
+
"start_time": "2026-04-03T22:48:31",
|
|
23
|
+
"end_time": "2026-04-03T22:48:54",
|
|
24
24
|
"status": "success",
|
|
25
25
|
"observability": {
|
|
26
26
|
"events": [
|
|
27
27
|
{
|
|
28
28
|
"event": "collect_sast_scan_metrics_from_pipeline",
|
|
29
|
-
"property": "
|
|
29
|
+
"property": "517c8743-14bb-4f03-bbd9-b829131f03ce",
|
|
30
30
|
"label": "semgrep",
|
|
31
31
|
"value": 0,
|
|
32
32
|
"version": "6.14.0",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"override_count": 0,
|
|
35
35
|
"passthrough_count": 4,
|
|
36
36
|
"custom_exclude_path_count": 0,
|
|
37
|
-
"time_s":
|
|
37
|
+
"time_s": 23,
|
|
38
38
|
"file_count": 20
|
|
39
39
|
}
|
|
40
40
|
]
|