@meteor-it/xrest
Advanced tools
Comparing version 0.2.1 to 0.3.1
249
index.js
@@ -1,21 +0,28 @@ | ||
import Logger from '@meteor-it/logger'; | ||
import * as multipart from './multipart'; | ||
import {EventEmitter} from 'events'; | ||
import {METHODS} from 'http'; | ||
import * as http from 'http'; | ||
import * as https from 'https'; | ||
import {parse as parseUrl,resolve} from 'url'; | ||
import {stringify} from 'querystring'; | ||
import * as zlib from 'zlib'; | ||
import iconv from 'iconv-lite'; | ||
export * from './multipart'; | ||
const POSSIBLE_EVENTS=[...METHODS]; | ||
const POSSIBLE_MIDDLEWARES=['STREAM']; | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const logger_1 = require("@meteor-it/logger"); | ||
const multipart = require("./multipart"); | ||
const events_1 = require("events"); | ||
const http_1 = require("http"); | ||
const http = require("http"); | ||
const https = require("https"); | ||
const url_1 = require("url"); | ||
const querystring_1 = require("querystring"); | ||
const zlib = require("zlib"); | ||
const iconv_lite_1 = require("iconv-lite"); | ||
__export(require("./multipart")); | ||
const POSSIBLE_EVENTS = [...http_1.METHODS]; | ||
const POSSIBLE_MIDDLEWARES = ['STREAM']; | ||
const USER_AGENT = 'Meteor-IT XRest'; | ||
const decoders = { | ||
@@ -29,59 +36,47 @@ gzip(buf, callback) { | ||
}; | ||
const parsers={ | ||
json(text,cb){ | ||
try{ | ||
cb(null,JSON.parse(text)); | ||
}catch(e){ | ||
cb(null,text); | ||
const parsers = { | ||
json(text, cb) { | ||
try { | ||
cb(null, JSON.parse(text)); | ||
} | ||
catch (e) { | ||
cb(null, text); | ||
} | ||
} | ||
}; | ||
class Request extends EventEmitter { | ||
url; | ||
options; | ||
headers; | ||
class Request extends events_1.EventEmitter { | ||
constructor(url, options) { | ||
super(); | ||
this.prepare(url,options); | ||
this.prepare(url, options); | ||
} | ||
prepare(url,options){ | ||
logger.debug('prepare(%s)',url); | ||
if(url.indexOf('undefined')+1){ | ||
prepare(url, options) { | ||
logger.debug('prepare(%s)', url); | ||
if (url.indexOf('undefined') + 1) { | ||
logger.warn('undefined found in request url! Stack for reference:'); | ||
logger.warn(new Error('reference stack').stack); | ||
} | ||
this.url = parseUrl(url); | ||
if(!this.url.hostname) | ||
this.url = url_1.parse(url); | ||
if (!this.url.hostname) | ||
console.log(this.url); | ||
this.options = options; | ||
this.headers = { | ||
'Accept': '*/*', | ||
'User-Agent': USER_AGENT, | ||
'Host': this.url.host, | ||
'Accept-Encoding': 'gzip, deflate', | ||
...options.headers | ||
}; | ||
this.headers = Object.assign({ 'Accept': '*/*', 'User-Agent': USER_AGENT, 'Host': this.url.host, 'Accept-Encoding': 'gzip, deflate' }, options.headers); | ||
// set port and method defaults | ||
if (!this.url.port) | ||
if (!this.url.port) | ||
this.url.port = (this.url.protocol == 'https:') ? '443' : '80'; | ||
if (!this.options.method) | ||
if (!this.options.method) | ||
this.options.method = (this.options.data) ? 'POST' : 'GET'; | ||
if (typeof this.options.followRedirects == 'undefined') | ||
if (typeof this.options.followRedirects == 'undefined') | ||
this.options.followRedirects = true; | ||
if(this.options.timeout===undefined) | ||
this.options.timeout=12000; | ||
if(!this.options.parser) | ||
this.options.parser=parsers.json; | ||
if (this.options.timeout === undefined) | ||
this.options.timeout = 12000; | ||
if (!this.options.parser) | ||
this.options.parser = parsers.json; | ||
// stringify query given in options of not given in URL | ||
if (this.options.query) { | ||
if (typeof this.options.query == 'object') | ||
this.url.query = stringify(this.options.query); | ||
else this.url.query = this.options.query; | ||
this.url.query = querystring_1.stringify(this.options.query); | ||
else | ||
this.url.query = this.options.query; | ||
} | ||
this.applyAuth(); | ||
if (this.options.multipart) { | ||
@@ -97,3 +92,3 @@ this.headers['Content-Type'] = `multipart/form-data; boundary=${multipart.DEFAULT_BOUNDARY}`; | ||
if (typeof this.options.data == 'object' && !Buffer.isBuffer(this.options.data)) { | ||
this.options.data = stringify(this.options.data); | ||
this.options.data = querystring_1.stringify(this.options.data); | ||
this.headers['Content-Type'] = 'application/x-www-form-urlencoded'; | ||
@@ -111,5 +106,3 @@ this.headers['Content-Length'] = this.options.data.length; | ||
} | ||
const proto = (this.url.protocol == 'https:') ? https : http; | ||
this.request = proto.request({ | ||
@@ -124,3 +117,2 @@ host: this.url.hostname, | ||
}); | ||
this.makeRequest(); | ||
@@ -133,4 +125,6 @@ } | ||
let path = this.url.pathname || '/'; | ||
if (this.url.hash) path += this.url.hash; | ||
if (this.url.query) path += `?${this.url.query}`; | ||
if (this.url.hash) | ||
path += this.url.hash; | ||
if (this.url.query) | ||
path += `?${this.url.query}`; | ||
return path; | ||
@@ -140,3 +134,2 @@ } | ||
let authParts; | ||
if (this.url.auth) { | ||
@@ -147,3 +140,2 @@ authParts = this.url.auth.split(':'); | ||
} | ||
if (this.options.username && this.options.password !== undefined) { | ||
@@ -163,3 +155,3 @@ const b = new Buffer([this.options.username, this.options.password].join(':')); | ||
if (response.statusCode === 303) { | ||
this.url = parseUrl(resolve(this.url.href, response.headers['location'])); | ||
this.url = url_1.parse(url_1.resolve(this.url.href, response.headers['location'])); | ||
this.options.method = 'GET'; | ||
@@ -170,3 +162,3 @@ delete this.options.data; | ||
else { | ||
this.url = parseUrl(resolve(this.url.href, response.headers['location'])); | ||
this.url = url_1.parse(url_1.resolve(this.url.href, response.headers['location'])); | ||
this.reRetry(); | ||
@@ -183,11 +175,8 @@ // TODO: Handle somehow infinite redirects | ||
let body = ''; | ||
// When using browserify, response.setEncoding is not defined | ||
if (typeof response.setEncoding == 'function') | ||
response.setEncoding('binary'); | ||
response.on('data', chunk => { | ||
body += chunk; | ||
}); | ||
response.on('end', () => { | ||
@@ -216,3 +205,2 @@ response.rawEncoded = body; | ||
const decoder = response.headers['content-encoding']; | ||
if (decoder in decoders) { | ||
@@ -233,5 +221,5 @@ decoders[decoder].call(response, body, callback); | ||
try { | ||
return iconv.decode(body, charset); | ||
return iconv_lite_1.default.decode(body, charset); | ||
} | ||
catch (err) {} | ||
catch (err) { } | ||
} | ||
@@ -273,3 +261,3 @@ } | ||
fireSuccess(body, response) { | ||
if (parseInt(response.statusCode,10) >= 400) { | ||
if (parseInt(response.statusCode, 10) >= 400) { | ||
this.emit('fail', body, response); | ||
@@ -303,3 +291,3 @@ } | ||
reRetry() { | ||
this.request.removeAllListeners().on('error', () => {}); | ||
this.request.removeAllListeners().on('error', () => { }); | ||
if (this.request.finished) { | ||
@@ -311,16 +299,17 @@ this.request.abort(); | ||
} | ||
async run() { | ||
if (this.options.multipart) { | ||
await multipart.write(this.request, this.options.data, () => { | ||
run() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (this.options.multipart) { | ||
yield multipart.write(this.request, this.options.data, () => { | ||
this.request.end(); | ||
}); | ||
} | ||
else { | ||
if (this.options.data) { | ||
this.request.write(this.options.data, this.options.encoding || 'utf8'); | ||
} | ||
this.request.end(); | ||
}); | ||
} | ||
else { | ||
if (this.options.data) { | ||
this.request.write(this.options.data, this.options.encoding || 'utf8'); | ||
} | ||
this.request.end(); | ||
} | ||
return this; | ||
return this; | ||
}); | ||
} | ||
@@ -340,3 +329,2 @@ abort(err) { | ||
} | ||
this.request.on('close', () => { | ||
@@ -350,3 +338,2 @@ if (err) { | ||
}); | ||
this.aborted = true; | ||
@@ -358,3 +345,3 @@ this.request.abort(); | ||
retry(timeout) { | ||
timeout = parseInt(timeout,10); | ||
timeout = parseInt(timeout, 10); | ||
const fn = this.reRetry.bind(this); | ||
@@ -370,49 +357,48 @@ if (!isFinite(timeout) || timeout <= 0) { | ||
} | ||
const logger=new Logger('xrest'); | ||
export function emit(eventString,options={}) { | ||
let [event,path,...middlewares]=eventString.split(' '); | ||
let middleFunctions=[]; | ||
for(let middleware of middlewares){ | ||
if(middleware.toUpperCase()!==middleware){ | ||
logger.warn('Upper case is preffered for middleware names! (Got: %s)',event); | ||
middleware=middleware.toUpperCase(); | ||
const logger = new logger_1.default('xrest'); | ||
function emit(eventString, options = {}) { | ||
let [event, path, ...middlewares] = eventString.split(' '); | ||
let middleFunctions = []; | ||
for (let middleware of middlewares) { | ||
if (middleware.toUpperCase() !== middleware) { | ||
logger.warn('Upper case is preffered for middleware names! (Got: %s)', event); | ||
middleware = middleware.toUpperCase(); | ||
} | ||
if(!~POSSIBLE_MIDDLEWARES.indexOf(middleware)) | ||
throw new Error('Unknown middleware: '+middleware); | ||
if (!~POSSIBLE_MIDDLEWARES.indexOf(middleware)) | ||
throw new Error('Unknown middleware: ' + middleware); | ||
middleFunctions.push(middleware); | ||
} | ||
if(event.toUpperCase()!==event){ | ||
logger.warn('Upper case is preffered for event names! (Got: %s)',event); | ||
event=event.toUpperCase(); | ||
if (event.toUpperCase() !== event) { | ||
logger.warn('Upper case is preffered for event names! (Got: %s)', event); | ||
event = event.toUpperCase(); | ||
} | ||
if(!~POSSIBLE_EVENTS.indexOf(event)){ | ||
throw new Error('Unknown event: '+event+', possible events are '+POSSIBLE_EVENTS.join(', ')+'!'); | ||
if (!~POSSIBLE_EVENTS.indexOf(event)) { | ||
throw new Error('Unknown event: ' + event + ', possible events are ' + POSSIBLE_EVENTS.join(', ') + '!'); | ||
} | ||
options.method = event; | ||
const request=new Request(path,options); | ||
if(~middleFunctions.indexOf('STREAM')){ | ||
const request = new Request(path, options); | ||
if (~middleFunctions.indexOf('STREAM')) { | ||
logger.debug('Streaming'); | ||
return new Promise((res,rej)=>{ | ||
return new Promise((res, rej) => { | ||
request.run(); | ||
request.on('timeout',(ms)=>{ | ||
rej(new Error('Timeout: '+ms)); | ||
request.on('timeout', (ms) => { | ||
rej(new Error('Timeout: ' + ms)); | ||
}); | ||
request.on('response',(response)=>{ | ||
request.on('response', (response) => { | ||
res(response); | ||
}); | ||
}); | ||
}else{ | ||
return new Promise((res,rej)=>{ | ||
} | ||
else { | ||
return new Promise((res, rej) => { | ||
request.run(); | ||
request.on('timeout',(ms)=>{ | ||
rej(new Error('Timeout: '+ms)); | ||
request.on('timeout', (ms) => { | ||
rej(new Error('Timeout: ' + ms)); | ||
}); | ||
request.on('complete',(result,response)=>{ | ||
if(result instanceof Error) { | ||
request.on('complete', (result, response) => { | ||
if (result instanceof Error) { | ||
rej(result); | ||
return; | ||
} | ||
response.body=result; | ||
response.body = result; | ||
res(response); | ||
@@ -423,15 +409,16 @@ }); | ||
} | ||
export default class XRest{ | ||
baseUrl; | ||
defaultOptions; | ||
constructor(url,defaultOptions){ | ||
logger.debug('new XRest(%s)',url); | ||
this.baseUrl=url; | ||
this.defaultOptions=defaultOptions; | ||
exports.emit = emit; | ||
class XRest { | ||
constructor(url, defaultOptions) { | ||
logger.debug('new XRest(%s)', url); | ||
this.baseUrl = url; | ||
this.defaultOptions = defaultOptions; | ||
} | ||
emit(eventString,options){ | ||
let [event,path,...middlewares]=eventString.split(' '); | ||
path=resolve(this.baseUrl, path); | ||
return emit([event,path,...middlewares].join(' '),options); | ||
emit(eventString, options) { | ||
let [event, path, ...middlewares] = eventString.split(' '); | ||
path = url_1.resolve(this.baseUrl, path); | ||
return emit([event, path, ...middlewares].join(' '), options); | ||
} | ||
} | ||
} | ||
exports.default = XRest; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInhyZXN0L2luZGV4LmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7QUFBQSw4Q0FBdUM7QUFFdkMseUNBQXlDO0FBRXpDLG1DQUFvQztBQUNwQywrQkFBNkI7QUFDN0IsNkJBQTZ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G4gICAgICAgICAgICAgICAgdGhpcy5oZWFkZXJzWydDb250ZW50LUxlbmd0aCddID0gdGhpcy5vcHRpb25zLmRhdGEubGVuZ3RoO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHR5cGVvZiB0aGlzLm9wdGlvbnMuZGF0YSA9PSAnc3RyaW5nJykge1xuICAgICAgICAgICAgICAgIGNvbnN0IGJ1ZmZlciA9IG5ldyBCdWZmZXIodGhpcy5vcHRpb25zLmRhdGEsIHRoaXMub3B0aW9ucy5lbmNvZGluZyB8fCAndXRmOCcpO1xuICAgICAgICAgICAgICAgIHRoaXMub3B0aW9ucy5kYXRhID0gYnVmZmVyO1xuICAgICAgICAgICAgICAgIHRoaXMuaGVhZGVyc1snQ29udGVudC1MZW5ndGgnXSA9IGJ1ZmZlci5sZW5ndGg7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoIXRoaXMub3B0aW9ucy5kYXRhKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5oZWFkZXJzWydDb250ZW50LUxlbmd0aCddID0gMDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGNvbnN0IHByb3RvID0gKHRoaXMudXJsLnByb3RvY29sID09ICdodHRwczonKSA/IGh0dHBzIDogaHR0cDtcblxuICAgICAgICB0aGlzLnJlcXVlc3QgPSBwcm90by5yZXF1ZXN0KHtcbiAgICAgICAgICAgIGhvc3Q6IHRoaXMudXJsLmhvc3RuYW1lLFxuICAgICAgICAgICAgcG9ydDogdGhpcy51cmwucG9ydCxcbiAgICAgICAgICAgIHBhdGg6IHRoaXMuZnVsbFBhdGgoKSxcbiAgICAgICAgICAgIG1ldGhvZDogdGhpcy5vcHRpb25zLm1ldGhvZCxcbiAgICAgICAgICAgIGhlYWRlcnM6IHRoaXMuaGVhZGVycyxcbiAgICAgICAgICAgIHJlamVjdFVuYXV0aG9yaXplZDogdGhpcy5vcHRpb25zLnJlamVjdFVuYXV0aG9yaXplZCxcbi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3JpemF0aW9uJ10gPSBgQmFzaWMgJHtiLnRvU3RyaW5nKCdiYXNlNjQnKX1gO1xuICAgICAgICB9XG4gICAgICAgIGVsc2UgaWYgKHRoaXMub3B0aW9ucy5hY2Nlc3NUb2tlbikge1xuICAgICAgICAgICAgdGhpcy5oZWFkZXJzWydBdXRob3JpemF0aW9uJ10gPSBgQmVhcmVyICR7dGhpcy5vcHRpb25zLmFjY2Vzc1Rva2VufWA7XG4gICAgICAgIH1cbiAgICB9XG4gICAgcmVzcG9uc2VIYW5kbGVyKHJlc3BvbnNlKSB7XG4gICAgICAgIGlmICh0aGlzLmlzUmVkaXJlY3QocmVzcG9uc2UpICYmIHRoaXMub3B0aW9ucy5mb2xsb3dSZWRpcmVjdHMpIHtcbiAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgLy8gMzAzIHNob3VsZCByZWRpcmVjdCBhbmQgcmV0cmlldmUgY29udGVudCB3aXRoIHRoZSBHRVQgbWV0aG9kXG4gICAgICAgICAgICAgICAgLy8gaHR0cDovL3d3dy53My5vcmcvUHJvdG9jb2xzL3JmYzI2MTYvcmZjMjYxNi1zZWMxMC5odG1sI3NlYzEwLjMuNFxuICAgICAgICAgICAgICAgIGlmIChyZXNwb25zZS5zdGF0dXNDb2RlID09PSAzMDMpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy51cmwgPSBwYXJzZVVybChyZXNvbHZlKHRoaXMudXJsLmhyZWYsIHJlc3BvbnNlLmhlYWRlcnNbJ2xvY2F0aW9uJ10pKTtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5vcHRpb25zLm1ldGhvZCA9ICdHRVQnO1xuICAgICAgICAgICAgICAgICAgICBkZWxldGUgdGhpcy5vcHRpb25zLmRhdGE7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMucmVSZXRyeSgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy51cmwgPSBwYXJzZVVybChyZXNvbHZlKHRoaXMudXJsLmhyZWYsIHJlc3BvbnNlLmhlYWRlcnNbJ2xvY2F0aW9uJ10pKTtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5yZVJldHJ5KCk7XG4gICAgICAgICAgICAgICAgICAgIC8vIFRPRE86IEhhbmRsZSBzb21laG93IGluZmluaXRlIHJlZGlyZWN0c1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGNhdGNoIChlcnIpIHtcbiAgICAgICAgICAgICAgICBlcnIubWVzc2FnZSA9IGBGYWlsZWQgdG8gZm9sbG93IHJlZGlyZWN0OiAke2Vyci5tZXNzYWdlfWA7XG4gICAgICAgICAgICAgICAgdGhpcy5maXJlRXJyb3IoZXJyLCByZXNwb25zZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICBsZXQgYm9keSA9ICcnO1xuXG4gICAgICAgICAgICAvLyBXaGVuIHVzaW5nIGJyb3dzZXJpZnksIHJlc3BvbnNlLnNldEVuY29kaW5nIGlzIG5vdCBkZWZpbmVkXG4gICAgICAgICAgICBpZiAodHlwZW9mIHJlc3BvbnNlLnNldEVuY29kaW5nID09ICdmdW5jdGlvbicpXG4gICAgICAgICAgICAgICAgcmVzcG9uc2Uuc2V0RW5jb2RpbmcoJ2JpbmFyeScpO1xuXG4gICAgICAgICAgICByZXNwb25zZS5vbignZGF0YScsIGNodW5rID0+IHtcbiAgICAgICAgICAgICAgICBib2R5ICs9IGNodW5rO1xuICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgIHJlc3BvbnNlLm9uKCdlbmQnLCAoKSA9PiB7XG4gICAgICAgICAgICAgICAgcmVzcG9uc2UucmF3RW5jb2RlZCA9IGJvZHk7XG4gICAgICAgICAgICAgICAgdGhpcy5kZWNvZGUobmV3IEJ1ZmZlcihib2R5LCAnYmluYXJ5JyksIHJlc3BvbnNlLCAoZXJyLCBib2R5KSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlyZUVycm9yKGVyciwgcmVzcG9uc2UpO1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIHJlc3BvbnNlLnJhdyA9IGJvZHk7XG4gICAgICAgICAgICAgICAgICAgIGJvZHkgPSB0aGlzLmljb252KGJvZHksIHJlc3BvbnNlKTtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5lbmNvZGUoYm9keSwgcmVzcG9uc2UsIChlcnIsIGJvZHkpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlcnIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpcmVFcnJvcihlcnIsIHJlc3BvbnNlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlyZVN1Y2Nlc3MoYm9keSwgcmVzcG9uc2UpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfVxuICAgIGRlY29kZShib2R5LCByZXNwb25zZSwgY2FsbGJhY2spIHtcbiAgICAgICAgY29uc3QgZGVjb2RlciA9IHJlc3BvbnNlLmhlYWRlcnNbJ2NvbnRlbnQtZW5jb2RpbmcnXTtcblxuICAgICAgICBpZiAoZGVjb2RlciBpbiBkZWNvZGVycykge1xuICAgICAgICAgICAgZGVjb2RlcnNbZGVjb2Rlcl0uY2FsbChyZXNwb25zZSwgYm9keSwgY2FsbGJhY2spO1xuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgY2FsbGJhY2sobnVsbCwgYm9keSk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgaWNvbnYoYm9keSwgcmVzcG9uc2UpIHtcbiAgICAgICAgbGV0IGNoYXJzZXQgPSByZXNwb25zZS5oZWFkZXJzWydjb250ZW50LXR5cGUnXTtcbiAgICAgICAgaWYgKGNoYXJzZXQpIHtcbiAgICAgICAgICAgIGNoYXJzZXQgPSAvXFxiY2hhcnNldD0oLispKD86O3wkKS9pLmV4ZWMoY2hhcnNldCk7XG4gICAgICAgICAgICBpZiAoY2hhcnNldCkge1xuICAgICAgICAgICAgICAgIGNoYXJzZXQgPSBjaGFyc2V0WzFdLnRyaW0oKS50b1VwcGVyQ2FzZSgpO1xuICAgICAgICAgICAgICAgIGlmIChjaGFyc2V0ICE9ICdVVEYtOCcpIHtcbiAgICAgICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpY29udi5kZWNvZGUoYm9keSwgY2hhcnNldCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgY2F0Y2ggKGVycikge31cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGJvZHk7XG4gICAgfVxuICAgIGVuY29kZShib2R5LCByZXNwb25zZSwgY2FsbGJhY2spIHtcbiAgICAgICAgaWYgKHRoaXMub3B0aW9ucy5kZWNvZGluZyA9PSAnYnVmZmVyJykge1xuICAgICAgICAgICAgY2FsbGJhY2sobnVsbCwgYm9keSk7XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICBib2R5ID0gYm9keS50b1N0cmluZyh0aGlzLm9wdGlvbnMuZGVjb2RpbmcpO1xuICAgICAgICAgICAgaWYgKHRoaXMub3B0aW9ucy5wYXJzZXIpIHtcbiAgICAgICAgICAgICAgICB0aGlzLm9wdGlvbnMucGFyc2VyLmNh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AgICAgICAgfVxuICAgICAgICAgICAgZWxzZSBpZiAoIShlcnIgaW5zdGFuY2VvZiBFcnJvcikpIHtcbiAgICAgICAgICAgICAgICBlcnIgPSBuZXcgRXJyb3IoJ0Fib3J0RXJyb3InKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVyci50eXBlID0gJ2Fib3J0JztcbiAgICAgICAgfVxuICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIGVyciA9IG51bGw7XG4gICAgICAgIH1cblxuICAgICAgICB0aGlzLnJlcXVlc3Qub24oJ2Nsb3NlJywgKCkgPT4ge1xuICAgICAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgICAgICAgIHRoaXMuZmlyZUVycm9yKGVyciwgbnVsbCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICB0aGlzLmVtaXQoJ2NvbXBsZXRlJywgbnVsbCwgbnVsbCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0pO1xuXG4gICAgICAgIHRoaXMuYWJvcnRlZCA9IHRydWU7XG4gICAgICAgIHRoaXMucmVxdWVzdC5hYm9ydCgpO1xuICAgICAgICB0aGlzLmVtaXQoJ2Fib3J0JywgZXJyKTtcbiAgICAgICAgcmV0dXJuIHRoaXM7XG4gICAgfVxuICAgIHJldHJ5KHRpbWVvdXQpIHtcbiAgICAgICAgdGltZW91dCA9IHBhcnNlSW50KHRpbWVvdXQsMTApO1xuICAgICAgICBjb25zdCBmbiA9IHRoaXMucmVSZXRyeS5iaW5kKHRoaXMpO1xuICAgICAgICBpZiAoIWlzRmluaXRlKHRpbWVvdXQpIHx8IHRpbWVvdXQgPD0gMCkge1xuICAgICAgICAgICAgcHJvY2Vzcy5uZXh0VGljayhmbiwgdGltZW91dCk7XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICBzZXRUaW1lb3V0KGZuLCB0aW1lb3V0KTtcbiAgICAgICAgfVxuICAgICAgIC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ICB0aHJvdyBuZXcgRXJyb3IoJ1Vua25vd24gZXZlbnQ6ICcrZXZlbnQrJywgcG9zc2libGUgZXZlbnRzIGFyZSAnK1BPU1NJQkxFX0VWRU5UUy5qb2luKCcsICcpKychJyk7XG4gICAgfVxuICAgIG9wdGlvbnMubWV0aG9kID0gZXZlbnQ7XG4gICAgY29uc3QgcmVxdWVzdD1uZXcgUmVxdWVzdChwYXRoLG9wdGlvbnMpO1xuICAgIGlmKH5taWRkbGVGdW5jdGlvbnMuaW5kZXhPZignU1RSRUFNJykpe1xuICAgICAgICBsb2dnZXIuZGVidWcoJ1N0cmVhbWluZycpO1xuICAgICAgICByZXR1cm4gbmV3IFByb21pc2UoKHJlcyxyZWopPT57XG4gICAgICAgICAgICByZXF1ZXN0LnJ1bigpO1xuICAgICAgICAgICAgcmVxdWVzdC5vbigndGltZW91dCcsKG1zKT0+e1xuICAgICAgICAgICAgICAgIHJlaihuZXcgRXJyb3IoJ1RpbWVvdXQ6ICcrbXMpKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgcmVxdWVzdC5vbigncmVzcG9uc2UnLChyZXNwb25zZSk9PntcbiAgICAgICAgICAgICAgICByZXMocmVzcG9uc2UpO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0pO1xuICAgIH1lbHNle1xuICAgICAgICByZXR1cm4gbmV3IFByb21pc2UoKHJlcyxyZWopPT57XG4gICAgICAgICAgICByZXF1ZXN0LnJ1bigpO1xuICAgICAgICAgICAgcmVxdWVzdC5vbigndGltZW91dCcsKG1zKT0+e1xuICAgICAgICAgICAgICAgIHJlaihuZXcgRXJyb3IoJ1RpbWVvdXQ6ICcrbXMpKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgcmVxdWVzdC5vbignY29tcGxldGUnLChyZXN1bHQscmVzcG9uc2UpPT57XG4gICAgICAgICAgICAgICAgaWYocmVzdWx0IGluc3RhbmNlb2YgRXJyb3IpIHtcbiAgICAgICAgICAgICAgICAgICAgcmVqKHJlc3VsdCk7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmVzcG9uc2UuYm9keT1yZXN1bHQ7XG4gICAgICAgICAgICAgICAgcmVzKHJlc3BvbnNlKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9KTtcbiAgICB9XG59XG5leHBvcnQgZGVmYXVsdCBjbGFzcyBYUmVzdHtcbiAgICBiYXNlVXJsO1xuICAgIGRlZmF1bHRPcHRpb25zO1xuICAgIGNvbnN0cnVjdG9yKHVybCxkZWZhdWx0T3B0aW9ucyl7XG4gICAgICAgIGxvZ2dlci5kZWJ1ZygnbmV3IFhSZXN0KCVzKScsdXJsKTtcbiAgICAgICAgdGhpcy5iYXNlVXJsPXVybDtcbiAgICAgICAgdGhpcy5kZWZhdWx0T3B0aW9ucz1kZWZhdWx0T3B0aW9ucztcbiAgICB9XG4gICAgZW1pdChldmVudFN0cmluZyxvcHRpb25zKXtcbiAgICAgICAgbGV0IFtldmVudCxwYXRoLC4uLm1pZGRsZXdhcmVzXT1ldmVudFN0cmluZy5zcGxpdCgnICcpO1xuICAgICAgICBwYXRoPXJlc29sdmUodGhpcy5iYXNlVXJsLCBwYXRoKTtcbiAgICAgICAgcmV0dXJuIGVtaXQoW2V2ZW50LHBhdGgsLi4ubWlkZGxld2FyZXNdLmpvaW4oJyAnKSxvcHRpb25zKTtcbiAgICB9XG59Il0sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9 |
197
multipart.js
@@ -1,29 +0,28 @@ | ||
import { | ||
basename | ||
} | ||
from 'path'; | ||
import { | ||
open, | ||
read, | ||
close | ||
} | ||
from '@meteor-it/fs'; | ||
export const DEFAULT_BOUNDARY = '84921024METEORITXREST74819204'; | ||
export class Stream { | ||
stream; | ||
string; | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const path_1 = require("path"); | ||
const fs_1 = require("@meteor-it/fs"); | ||
exports.DEFAULT_BOUNDARY = '84921024METEORITXREST74819204'; | ||
class Stream { | ||
constructor(stream) { | ||
if (this._isString(stream)) { | ||
this.string = ''; | ||
} | ||
this.stream = stream; | ||
if (this._isString(stream)) { | ||
this.string = ''; | ||
} | ||
this.stream = stream; | ||
} | ||
write(data) { | ||
if (this.string != undefined) { | ||
this.string += data; | ||
} else { | ||
this.stream.write(data, 'binary'); | ||
} | ||
if (this.string != undefined) { | ||
this.string += data; | ||
} | ||
else { | ||
this.stream.write(data, 'binary'); | ||
} | ||
} | ||
@@ -34,12 +33,7 @@ _isString(obj) { | ||
} | ||
export class File { | ||
path; | ||
filename; | ||
fileSize; | ||
encoding; | ||
contentType; | ||
exports.Stream = Stream; | ||
class File { | ||
constructor(path, filename, fileSize, encoding, contentType) { | ||
this.path = path; | ||
this.filename = filename || basename(path); | ||
this.filename = filename || path_1.basename(path); | ||
this.fileSize = fileSize; | ||
@@ -50,12 +44,8 @@ this.encoding = encoding || 'binary'; | ||
} | ||
export class FileStream { | ||
filename; | ||
fileSize; | ||
encoding; | ||
contentType; | ||
exports.File = File; | ||
class FileStream { | ||
constructor(stream, filename, dataLength, encoding, contentType) { | ||
if(!dataLength || dataLength!==dataLength) | ||
if (!dataLength || dataLength !== dataLength) | ||
throw new Error('Building FileStream without dataLength!'); | ||
this.stream=stream; | ||
this.stream = stream; | ||
this.filename = filename; | ||
@@ -67,8 +57,4 @@ this.fileSize = dataLength; | ||
} | ||
export class Data { | ||
filename; | ||
contentType; | ||
data; | ||
exports.FileStream = FileStream; | ||
class Data { | ||
constructor(filename, contentType, data) { | ||
@@ -80,7 +66,4 @@ this.filename = filename; | ||
} | ||
export class Part { | ||
name; | ||
value; | ||
boundary; | ||
exports.Data = Data; | ||
class Part { | ||
constructor(name, value, boundary) { | ||
@@ -91,7 +74,5 @@ this.name = name; | ||
} | ||
//returns the Content-Disposition header | ||
header() { | ||
let header; | ||
if (this.value.data) { | ||
@@ -103,3 +84,3 @@ header = `Content-Disposition: form-data; name='${this.name}'; filename='${this.value.filename}'\r\nContent-Length: ${this.value.data.length}\r\nContent-Type: ${this.value.contentType}`; | ||
} | ||
else if(this.value instanceof FileStream) { | ||
else if (this.value instanceof FileStream) { | ||
header = `Content-Disposition: form-data; name='${this.name}'; filename='${this.value.filename}'\r\nContent-Length: ${this.value.fileSize}\r\nContent-Type: ${this.value.contentType}`; | ||
@@ -110,6 +91,4 @@ } | ||
} | ||
return `--${this.boundary}\r\n${header}\r\n\r\n`; | ||
} | ||
//calculates the size of the Part | ||
@@ -135,19 +114,17 @@ sizeOf() { | ||
} | ||
// Writes the Part out to a writable stream that supports the write(data) method | ||
write(stream) { | ||
return new Promise(async (resolve,reject)=>{ | ||
if(!stream.on) | ||
if(stream.stream) | ||
stream=stream.stream; | ||
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { | ||
if (!stream.on) | ||
if (stream.stream) | ||
stream = stream.stream; | ||
//first write the Content-Disposition | ||
stream.write(this.header()); | ||
//Now write out the body of the Part | ||
if (this.value instanceof File) { | ||
let fd = await open(this.value.path, 'r', '0666'); | ||
let fd = yield fs_1.open(this.value.path, 'r', '0666'); | ||
let position = 0; | ||
let moreData = true; | ||
while (moreData) { | ||
let chunk = await read(fd, 4096, position, 'binary'); | ||
let chunk = yield fs_1.read(fd, 4096, position, 'binary'); | ||
stream.write(chunk); | ||
@@ -160,3 +137,3 @@ position += 4096; | ||
stream.write('\r\n'); | ||
close(fd); | ||
fs_1.close(fd); | ||
moreData = false; | ||
@@ -166,13 +143,13 @@ resolve(); | ||
} | ||
} else if(this.value instanceof FileStream){ | ||
this.value.stream.on('end', () =>{ | ||
} | ||
else if (this.value instanceof FileStream) { | ||
this.value.stream.on('end', () => { | ||
stream.write('\r\n'); | ||
resolve(); | ||
}); | ||
let s=this.value.stream.pipe(stream,{ | ||
end:false // Do not end writing streams, may be there is more data incoming | ||
let s = this.value.stream.pipe(stream, { | ||
end: false // Do not end writing streams, may be there is more data incoming | ||
}); | ||
} else if (this.value instanceof Data) { | ||
} | ||
else if (this.value instanceof Data) { | ||
stream.write(this.value.data); | ||
@@ -185,19 +162,14 @@ stream.write('\r\n'); | ||
resolve(); | ||
} | ||
}) | ||
} | ||
})); | ||
} | ||
} | ||
export class MultiPartRequest { | ||
encoding; | ||
boundary; | ||
data; | ||
partNames; | ||
exports.Part = Part; | ||
class MultiPartRequest { | ||
constructor(data, boundary) { | ||
this.encoding = 'binary'; | ||
this.boundary = boundary || DEFAULT_BOUNDARY; | ||
this.boundary = boundary || exports.DEFAULT_BOUNDARY; | ||
this.data = data; | ||
this.partNames = this._partNames(); | ||
} | ||
_partNames() { | ||
@@ -210,34 +182,37 @@ const partNames = []; | ||
} | ||
async write(stream) { | ||
let partCount = 0; | ||
// wrap the stream in our own Stream object | ||
// See the Stream function above for the benefits of this | ||
stream = new Stream(stream); | ||
while (true) { | ||
const partName = this.partNames[partCount]; | ||
const part = new Part(partName, this.data[partName], this.boundary); | ||
await part.write(stream); | ||
partCount++; | ||
if (partCount >= this.partNames.length) { | ||
stream.write(`--${this.boundary}--\r\n`); | ||
return stream.string || ''; | ||
write(stream) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let partCount = 0; | ||
// wrap the stream in our own Stream object | ||
// See the Stream function above for the benefits of this | ||
stream = new Stream(stream); | ||
while (true) { | ||
const partName = this.partNames[partCount]; | ||
const part = new Part(partName, this.data[partName], this.boundary); | ||
yield part.write(stream); | ||
partCount++; | ||
if (partCount >= this.partNames.length) { | ||
stream.write(`--${this.boundary}--\r\n`); | ||
return stream.string || ''; | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
export function sizeOf(parts, boundary=DEFAULT_BOUNDARY) { | ||
exports.MultiPartRequest = MultiPartRequest; | ||
function sizeOf(parts, boundary = exports.DEFAULT_BOUNDARY) { | ||
let totalSize = 0; | ||
for (let name in parts) | ||
totalSize += new Part(name, parts[name], boundary).sizeOf(); | ||
return totalSize + boundary.length + 6; | ||
for (let name in parts) | ||
totalSize += new Part(name, parts[name], boundary).sizeOf(); | ||
return totalSize + boundary.length + 6; | ||
} | ||
export async function write(stream, data, callback, boundary) { | ||
let r = new MultiPartRequest(data, boundary); | ||
await r.write(stream); | ||
return r; | ||
} | ||
exports.sizeOf = sizeOf; | ||
function write(stream, data, callback, boundary) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let r = new MultiPartRequest(data, boundary); | ||
yield r.write(stream); | ||
return r; | ||
}); | ||
} | ||
exports.write = write; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInhyZXN0L211bHRpcGFydC5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBQUEsK0JBR1k7QUFDWixzQ0FLcUI7QUFFUixRQUFBLGdCQUFnQixHQUFHLCtCQUErQixDQUFDO0FBRWhFO0lBR0ksWUFBWSxNQUFNO1FBQ2pCLEVBQUUsQ0FBQyxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDO1lBQzVCLElBQUksQ0FBQyxNQUFNLEdBQUcsRUFBRSxDQUFDO1FBQ2xCLENBQUM7UUFDRCxJQUFJLENBQUMsTUFBTSxHQUFHLE1BQU0sQ0FBQztJQUN0QixDQUFDO0lBQ0QsS0FBSyxDQUFDLElBQUk7UUFDVCxFQUFFLENBQUMsQ0FBQyxJQUFJLENBQUMsTUFBTSxJQUFJLFNBQVMsQ0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ICBsZXQgcG9zaXRpb24gPSAwO1xuICAgICAgICAgICAgICAgIGxldCBtb3JlRGF0YSA9IHRydWU7XG4gICAgICAgICAgICAgICAgd2hpbGUgKG1vcmVEYXRhKSB7XG4gICAgICAgICAgICAgICAgICAgIGxldCBjaHVuayA9IGF3YWl0IHJlYWQoZmQsIDQwOTYsIHBvc2l0aW9uLCAnYmluYXJ5Jyk7XG4gICAgICAgICAgICAgICAgICAgIHN0cmVhbS53cml0ZShjaHVuayk7XG4gICAgICAgICAgICAgICAgICAgIHBvc2l0aW9uICs9IDQwOTY7XG4gICAgICAgICAgICAgICAgICAgIGlmIChjaHVuaykge1xuICAgICAgICAgICAgICAgICAgICAgICAgbW9yZURhdGEgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtLndyaXRlKCdcXHJcXG4nKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNsb3NlKGZkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIG1vcmVEYXRhID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXNvbHZlKCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2UgaWYodGhpcy52YWx1ZSBpbnN0YW5jZW9mIEZpbGVTdHJlYW0pe1xuXG4gICAgICAgICAgICAgICAgdGhpcy52YWx1ZS5zdHJlYW0ub24oJ2VuZCcsICgpID0+e1xuICAgICAgICAgICAgICAgICAgICBzdHJlYW0ud3JpdGUoJ1xcclxcbicpO1xuICAgICAgICAgICAgICAgICAgICByZXNvbHZlKCk7XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgXG4gICAgICAgICAgICAgICAgbGV0IHM9dGhpcy52YWx1ZS5zdHJlYW0ucGlwZShzdHJlYW0se1xuICAgICAgICAgICAgICAgICAgICBlbmQ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0gbmV3IFBhcnQobmFtZSwgcGFydHNbbmFtZV0sIGJvdW5kYXJ5KS5zaXplT2YoKTtcbiAgXHRyZXR1cm4gdG90YWxTaXplICsgYm91bmRhcnkubGVuZ3RoICsgNjtcbn1cbmV4cG9ydCBhc3luYyBmdW5jdGlvbiB3cml0ZShzdHJlYW0sIGRhdGEsIGNhbGxiYWNrLCBib3VuZGFyeSkge1xuICAgIGxldCByID0gbmV3IE11bHRpUGFydFJlcXVlc3QoZGF0YSwgYm91bmRhcnkpO1xuICAgIGF3YWl0IHIud3JpdGUoc3RyZWFtKTtcbiAgICByZXR1cm4gcjtcbn0iXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0= |
{ | ||
"name": "@meteor-it/xrest", | ||
"version": "0.2.1", | ||
"version": "0.3.1", | ||
"description": "I", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
81349
833