whistle.script 1.2.2 → 1.2.3

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.
Files changed (2) hide show
  1. package/lib/util.js +5 -2
  2. package/package.json +4 -1
package/lib/util.js CHANGED
@@ -2,6 +2,7 @@ const zlib = require('zlib');
2
2
  const { EventEmitter } = require('events');
3
3
  const { parse: parseUrl } = require('url');
4
4
  const http = require('http');
5
+ const https = require('https');
5
6
  const dataSource = require('./dataSource');
6
7
 
7
8
  exports.AUTH_URL = 'x-whistle-.script-auth-url';
@@ -14,7 +15,7 @@ exports.noop = () => {};
14
15
 
15
16
  const POLICY = 'x-whistle-.script-policy';
16
17
  const isFunction = fn => typeof fn === 'function';
17
- const URL_RE = /^http:(?:\/\/|%3A%2F%2F)[\w.-]/;
18
+ const URL_RE = /^https?:(?:\/\/|%3A%2F%2F)[\w.-]/;
18
19
 
19
20
  exports.isFunction = isFunction;
20
21
  exports.noop = () => {};
@@ -141,7 +142,9 @@ const request = (url, headers, data) => {
141
142
  options.method = 'POST';
142
143
  }
143
144
  return new Promise((resolve, reject) => {
144
- const client = http.request(options, (res) => {
145
+ const httpModule = options.protocol === 'https:' ? https : http;
146
+ options.rejectUnauthorized = true;
147
+ const client = httpModule.request(options, (res) => {
145
148
  res.on('error', handleError); // eslint-disable-line
146
149
  let body;
147
150
  res.on('data', (chunk) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "whistle.script",
3
3
  "description": "The plugin for the extension script for whistle",
4
- "version": "1.2.2",
4
+ "version": "1.2.3",
5
5
  "author": "avenwu <avenwu@vip.qq.com>",
6
6
  "contributors": [],
7
7
  "license": "MIT",
@@ -15,6 +15,9 @@
15
15
  "ssi"
16
16
  ],
17
17
  "registry": "https://github.com/whistle-plugins/whistle.script",
18
+ "whistleConfig": {
19
+ "pluginVars": true
20
+ },
18
21
  "repository": {
19
22
  "type": "git",
20
23
  "url": "https://github.com/whistle-plugins/whistle.script.git"