signup request,validation, email ack,config
This commit is contained in:
parent
6441027b89
commit
bc607d8017
26
.env
26
.env
@ -1,14 +1,12 @@
|
|||||||
ENCRYPTION_SECRET=mySuperSecretKey123
|
ENCRYPTION_SECRET=mySuperSecretKey123
|
||||||
PORT=3000
|
PORT=3000
|
||||||
|
|
||||||
<<<<<<< HEAD
|
MYSQL_HOST = localhost
|
||||||
MYSQL_HOST = localhost
|
MYSQL_USER = guardian
|
||||||
MYSQL_USER = guardian
|
MYSQL_PASSWORD = Admin@123
|
||||||
MYSQL_PASSWORD = Admin@123
|
MYSQL_DATABASE = guardiandb
|
||||||
MYSQL_DATABASE = guardiandb
|
|
||||||
=======
|
GMAIL_PASS = coye ochr karf twdx
|
||||||
MYSQL_HOST =
|
GMAIL_USER = jassimsoopimohammed@gmail.com
|
||||||
MYSQL_USER =
|
gmail_admin = rohit.giri@tech4biz.org
|
||||||
MYSQL_PASSWORD =
|
|
||||||
MYSQL_DATABASE =
|
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
|
|||||||
14
.gitignore
vendored
Normal file
14
.gitignore
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/node_modules
|
||||||
|
/dist
|
||||||
|
/build
|
||||||
|
/logs
|
||||||
|
/temp
|
||||||
|
/uploads
|
||||||
|
/public
|
||||||
|
/config
|
||||||
|
/data
|
||||||
|
/backup
|
||||||
|
/cache
|
||||||
|
/logs
|
||||||
|
/frontend/node_modules
|
||||||
|
/certificates
|
||||||
191
app.js
191
app.js
@ -1,103 +1,88 @@
|
|||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const cors = require('cors');
|
const cors = require('cors');
|
||||||
const apiRoutes = require('./routes/apiRoutes');
|
const apiRoutes = require('./routes/apiRoutes');
|
||||||
const userRoutes = require('./routes/userRoutes');
|
const userRoutes = require('./routes/userRoutes');
|
||||||
const https = require('https');
|
const authRoutes = require('./routes/authRoutes');
|
||||||
const fs = require("fs")
|
const https = require('https');
|
||||||
|
const fs = require("fs")
|
||||||
<<<<<<< HEAD
|
|
||||||
|
|
||||||
const {initWebSocket} = require('./services/webSocket')
|
const {initWebSocket} = require('./services/webSocket')
|
||||||
const { connectDB } = require('./config/database');
|
const { connectDB } = require('./config/database');
|
||||||
connectDB();
|
connectDB();
|
||||||
=======
|
const app = express();
|
||||||
const {initWebSocket} = require('./services/webSocket')
|
const sslOptions = {
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
// key: fs.readFileSync('./certificates/fullchain.pem'),
|
||||||
const app = express();
|
// cert: fs.readFileSync('./certificates/privkey.pem'),
|
||||||
const sslOptions = {
|
};
|
||||||
// key: fs.readFileSync('./certificates/fullchain.pem'),
|
// Create HTTP server (use HTTP for now to avoid SSL issues, in production use HTTPS with valid certificates)
|
||||||
// cert: fs.readFileSync('./certificates/privkey.pem'),
|
const server = require('http').createServer(app);
|
||||||
};
|
|
||||||
// Create HTTP server (use HTTP for now to avoid SSL issues, in production use HTTPS with valid certificates)
|
|
||||||
const server = require('http').createServer(app);
|
// Initialize WebSocket server
|
||||||
|
initWebSocket(server);
|
||||||
<<<<<<< HEAD
|
console.log('WebSocket server initialized');
|
||||||
|
|
||||||
// Initialize WebSocket server
|
connectDB()
|
||||||
initWebSocket(server);
|
// Middleware to parse JSON bodies
|
||||||
console.log('WebSocket server initialized');
|
app.use(express.json()); // 👈 Add this line
|
||||||
|
|
||||||
connectDB()
|
// Serve static files from the public directory
|
||||||
=======
|
app.use(express.static('public'));
|
||||||
// Initialize WebSocket server
|
|
||||||
initWebSocket(server);
|
// CORS Configuration
|
||||||
console.log('WebSocket server initialized');
|
const allowedOrigins = ['https://guardiancalls.tech4bizsolutions.com','http://localhost:5174', 'https://dashboard.tech4biz.info','http://localhost:5173', 'http://192.168.1.35:5173',"https://guardiancall.blueskyaiautomation.com"]; // Replace as needed
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
// Middleware to parse JSON bodies
|
app.use((req, res, next) => {
|
||||||
app.use(express.json()); // 👈 Add this line
|
// Check if the request is for the WebSocket test page
|
||||||
|
if (req.path === '/websocket-test' || req.path === '/public/websocket-test.html') {
|
||||||
// Serve static files from the public directory
|
// Less restrictive CSP for WebSocket test page
|
||||||
app.use(express.static('public'));
|
res.setHeader(
|
||||||
|
'Content-Security-Policy',
|
||||||
// CORS Configuration
|
"default-src 'self'; connect-src 'self' ws: wss: http: https:; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline';"
|
||||||
<<<<<<< HEAD
|
);
|
||||||
const allowedOrigins = ['https://guardiancalls.tech4bizsolutions.com','http://localhost:5174', 'https://dashboard.tech4biz.info','http://localhost:5173', 'http://192.168.1.35:5173']; // Replace as needed
|
} else {
|
||||||
=======
|
// Original CSP for other pages
|
||||||
const allowedOrigins = ['https://guardiancalls.tech4bizsolutions.com','http://localhost:5174', 'https://yourfrontend.com','http://localhost:5173', 'http://192.168.1.35:5173']; // Replace as needed
|
res.setHeader(
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
'Content-Security-Policy',
|
||||||
|
"default-src 'self'; connect-src 'self' wss://guardiancalls.tech4bizsolutions.com https://your-api-domain.com; script-src 'self';"
|
||||||
app.use((req, res, next) => {
|
);
|
||||||
// Check if the request is for the WebSocket test page
|
}
|
||||||
if (req.path === '/websocket-test' || req.path === '/public/websocket-test.html') {
|
next();
|
||||||
// Less restrictive CSP for WebSocket test page
|
});
|
||||||
res.setHeader(
|
|
||||||
'Content-Security-Policy',
|
|
||||||
"default-src 'self'; connect-src 'self' ws: wss: http: https:; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline';"
|
app.use(cors({
|
||||||
);
|
origin: function (origin, callback) {
|
||||||
} else {
|
if (!origin) return callback(null, true); // Allow requests with no origin
|
||||||
// Original CSP for other pages
|
if (allowedOrigins.indexOf(origin) === -1) {
|
||||||
res.setHeader(
|
const msg = 'The CORS policy for this site does not allow access from the specified Origin.';
|
||||||
'Content-Security-Policy',
|
return callback(new Error(msg), false);
|
||||||
"default-src 'self'; connect-src 'self' wss://guardiancalls.tech4bizsolutions.com https://your-api-domain.com; script-src 'self';"
|
}
|
||||||
);
|
return callback(null, true);
|
||||||
}
|
},
|
||||||
next();
|
optionsSuccessStatus: 200
|
||||||
});
|
}));
|
||||||
|
|
||||||
|
// Routes
|
||||||
app.use(cors({
|
app.use('/api/user', userRoutes);
|
||||||
origin: function (origin, callback) {
|
app.use('/api/call-list', apiRoutes);
|
||||||
if (!origin) return callback(null, true); // Allow requests with no origin
|
app.use('/api/auth', authRoutes);
|
||||||
if (allowedOrigins.indexOf(origin) === -1) {
|
|
||||||
const msg = 'The CORS policy for this site does not allow access from the specified Origin.';
|
|
||||||
return callback(new Error(msg), false);
|
app.get('/', (req, res) => {
|
||||||
}
|
res.send("Backend is working!");
|
||||||
return callback(null, true);
|
});
|
||||||
},
|
|
||||||
optionsSuccessStatus: 200
|
// WebSocket test page
|
||||||
}));
|
app.get('/websocket-test', (req, res) => {
|
||||||
|
res.sendFile(__dirname + '/public/websocket-test.html');
|
||||||
// Routes
|
});
|
||||||
app.use('/api/user', userRoutes);
|
|
||||||
app.use('/api/call-list', apiRoutes);
|
// Start server
|
||||||
|
const PORT = process.env.PORT || 3000;
|
||||||
app.get('/', (req, res) => {
|
server.listen(PORT, () => {
|
||||||
res.send("Backend is working!");
|
console.log(`HTTP server running on port ${PORT}`);
|
||||||
});
|
console.log(`WebSocket server available at ws://localhost:${PORT}`);
|
||||||
|
});
|
||||||
// WebSocket test page
|
|
||||||
app.get('/websocket-test', (req, res) => {
|
|
||||||
res.sendFile(__dirname + '/public/websocket-test.html');
|
|
||||||
});
|
|
||||||
|
|
||||||
// Start server
|
|
||||||
const PORT = process.env.PORT || 3000;
|
|
||||||
server.listen(PORT, () => {
|
|
||||||
console.log(`HTTP server running on port ${PORT}`);
|
|
||||||
console.log(`WebSocket server available at ws://localhost:${PORT}`);
|
|
||||||
<<<<<<< HEAD
|
|
||||||
});
|
|
||||||
=======
|
|
||||||
});
|
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
@ -1,48 +0,0 @@
|
|||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIIDsjCCAzigAwIBAgISBVXyKhgq+z0CAq8r8xlfVOimMAoGCCqGSM49BAMDMDIx
|
|
||||||
CzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MQswCQYDVQQDEwJF
|
|
||||||
NTAeFw0yNTA1MjMwOTU3MjdaFw0yNTA4MjEwOTU3MjZaMC4xLDAqBgNVBAMTI2d1
|
|
||||||
YXJkaWFuY2FsbHMudGVjaDRiaXpzb2x1dGlvbnMuY29tMFkwEwYHKoZIzj0CAQYI
|
|
||||||
KoZIzj0DAQcDQgAEFkj1St8i4vM5I3bTlGcAqsc4YssKgdYV/OAy+3y8hMMPHbUi
|
|
||||||
zF/BMa42ycDEXtw1geS+bzJVFA7HXrco8oOvjqOCAjAwggIsMA4GA1UdDwEB/wQE
|
|
||||||
AwIHgDAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwDAYDVR0TAQH/BAIw
|
|
||||||
ADAdBgNVHQ4EFgQU9oBKl2iP0cojuMRm98APDaPPynQwHwYDVR0jBBgwFoAUnytf
|
|
||||||
zzwhT50Et+0rLMTGcIvS1w0wMgYIKwYBBQUHAQEEJjAkMCIGCCsGAQUFBzAChhZo
|
|
||||||
dHRwOi8vZTUuaS5sZW5jci5vcmcvMC4GA1UdEQQnMCWCI2d1YXJkaWFuY2FsbHMu
|
|
||||||
dGVjaDRiaXpzb2x1dGlvbnMuY29tMBMGA1UdIAQMMAowCAYGZ4EMAQIBMC0GA1Ud
|
|
||||||
HwQmMCQwIqAgoB6GHGh0dHA6Ly9lNS5jLmxlbmNyLm9yZy8zOS5jcmwwggEDBgor
|
|
||||||
BgEEAdZ5AgQCBIH0BIHxAO8AdQDM+w9qhXEJZf6Vm1PO6bJ8IumFXA2XjbapflTA
|
|
||||||
/kwNsAAAAZb8yRBYAAAEAwBGMEQCIHz+37rvli/z4bySkF6Agh4Y/jC0+y/nfK4f
|
|
||||||
U8DPeRimAiB8Em8y3E85EYbVFIN0z/IrlzSoCUprLW9fJIqjOTyoRgB2AA3h8jAr
|
|
||||||
0w3BQGISCepVLvxHdHyx1+kw7w5CHrR+Tqo0AAABlvzJEF0AAAQDAEcwRQIgHkAk
|
|
||||||
1qxFx/uC6tR9UsXyoCsNsQJebJQobahCGxLq7AcCIQDZ+61TBS1DWMoreCG+CEa0
|
|
||||||
HeZDfEdZHGXLPpaiPOSkITAKBggqhkjOPQQDAwNoADBlAjEA49BB3QqaDbT43Pdy
|
|
||||||
xwSI6Loq5eYJNMekJipVsvu+rSmDZ1KU4AEadpd5wZhQoWKlAjB9nS05qX1Q6Gcg
|
|
||||||
Fq7D/bA2inv7MF2riCMbfkp1nWRJ0LFcOOHlYbor0wrNAwd9w7c=
|
|
||||||
-----END CERTIFICATE-----
|
|
||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIIEVzCCAj+gAwIBAgIRAIOPbGPOsTmMYgZigxXJ/d4wDQYJKoZIhvcNAQELBQAw
|
|
||||||
TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
|
|
||||||
cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMjQwMzEzMDAwMDAw
|
|
||||||
WhcNMjcwMzEyMjM1OTU5WjAyMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNTGV0J3Mg
|
|
||||||
RW5jcnlwdDELMAkGA1UEAxMCRTUwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQNCzqK
|
|
||||||
a2GOtu/cX1jnxkJFVKtj9mZhSAouWXW0gQI3ULc/FnncmOyhKJdyIBwsz9V8UiBO
|
|
||||||
VHhbhBRrwJCuhezAUUE8Wod/Bk3U/mDR+mwt4X2VEIiiCFQPmRpM5uoKrNijgfgw
|
|
||||||
gfUwDgYDVR0PAQH/BAQDAgGGMB0GA1UdJQQWMBQGCCsGAQUFBwMCBggrBgEFBQcD
|
|
||||||
ATASBgNVHRMBAf8ECDAGAQH/AgEAMB0GA1UdDgQWBBSfK1/PPCFPnQS37SssxMZw
|
|
||||||
i9LXDTAfBgNVHSMEGDAWgBR5tFnme7bl5AFzgAiIyBpY9umbbjAyBggrBgEFBQcB
|
|
||||||
AQQmMCQwIgYIKwYBBQUHMAKGFmh0dHA6Ly94MS5pLmxlbmNyLm9yZy8wEwYDVR0g
|
|
||||||
BAwwCjAIBgZngQwBAgEwJwYDVR0fBCAwHjAcoBqgGIYWaHR0cDovL3gxLmMubGVu
|
|
||||||
Y3Iub3JnLzANBgkqhkiG9w0BAQsFAAOCAgEAH3KdNEVCQdqk0LKyuNImTKdRJY1C
|
|
||||||
2uw2SJajuhqkyGPY8C+zzsufZ+mgnhnq1A2KVQOSykOEnUbx1cy637rBAihx97r+
|
|
||||||
bcwbZM6sTDIaEriR/PLk6LKs9Be0uoVxgOKDcpG9svD33J+G9Lcfv1K9luDmSTgG
|
|
||||||
6XNFIN5vfI5gs/lMPyojEMdIzK9blcl2/1vKxO8WGCcjvsQ1nJ/Pwt8LQZBfOFyV
|
|
||||||
XP8ubAp/au3dc4EKWG9MO5zcx1qT9+NXRGdVWxGvmBFRAajciMfXME1ZuGmk3/GO
|
|
||||||
koAM7ZkjZmleyokP1LGzmfJcUd9s7eeu1/9/eg5XlXd/55GtYjAM+C4DG5i7eaNq
|
|
||||||
cm2F+yxYIPt6cbbtYVNJCGfHWqHEQ4FYStUyFnv8sjyqU8ypgZaNJ9aVcWSICLOI
|
|
||||||
E1/Qv/7oKsnZCWJ926wU6RqG1OYPGOi1zuABhLw61cuPVDT28nQS/e6z95cJXq0e
|
|
||||||
K1BcaJ6fJZsmbjRgD5p3mvEf5vdQM7MCEvU0tHbsx2I5mHHJoABHb8KVBgWp/lcX
|
|
||||||
GWiWaeOyB7RP+OfDtvi2OsapxXiV7vNVs7fMlrRjY1joKaqmmycnBvAq14AEbtyL
|
|
||||||
sVfOS66B8apkeFX2NY4XPEYV4ZSCe8VHPrdrERk2wILG3T/EGmSIkCYVUMSnjmJd
|
|
||||||
VQD9F6Na/+zmXCc=
|
|
||||||
-----END CERTIFICATE-----
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
-----BEGIN PRIVATE KEY-----
|
|
||||||
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgH6ulvQnwnXO+vjBV
|
|
||||||
IW7bkzyG1ZjAGYdpW2PSoK2JYtOhRANCAAQWSPVK3yLi8zkjdtOUZwCqxzhiywqB
|
|
||||||
1hX84DL7fLyEww8dtSLMX8ExrjbJwMRe3DWB5L5vMlUUDsdetyjyg6+O
|
|
||||||
-----END PRIVATE KEY-----
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"encryptedApiKey": "b86a778a96105b294c9e9e9cc0f33372:6440a322e08439e8638fdc37703601ea812efe013ad19cda2e92bef89edbcd0f9c6f69b0671ae505f1713bccbf13e1906a4d6cc74cee71595d845354a6dbb1215fa963f205eeb2f32bc1379ef0ce203e414d45f2f7a20c46298b7d314b112ad0660ff36ed9e58c6dabbce31a57c1865a062a7e7b8fa9cd2429013952fd58f3da2803ba7b5af13520ee017349b757dbca2c5a263471994b6d54b68584b07d2943fe1b4fbf484f0de7eb2a4d29050c21dadefb8d42819408a62f08784973b9cc98230533734755975d40c5f95e0d3290a161a1f17f5448590ab430d7cd5c1b506a",
|
"encryptedApiKey": "b86a778a96105b294c9e9e9cc0f33372:6440a322e08439e8638fdc37703601ea812efe013ad19cda2e92bef89edbcd0f9c6f69b0671ae505f1713bccbf13e1906a4d6cc74cee71595d845354a6dbb1215fa963f205eeb2f32bc1379ef0ce203e414d45f2f7a20c46298b7d314b112ad0660ff36ed9e58c6dabbce31a57c1865a062a7e7b8fa9cd2429013952fd58f3da2803ba7b5af13520ee017349b757dbca2c5a263471994b6d54b68584b07d2943fe1b4fbf484f0de7eb2a4d29050c21dadefb8d42819408a62f08784973b9cc98230533734755975d40c5f95e0d3290a161a1f17f5448590ab430d7cd5c1b506a",
|
||||||
"encryptedApiKey_callList" : "6500079791e1e53739fb8e5cc399af42:63ea6dabaeae63c91bccf1ff2fc1f814aba828ad3b938f20f2e1aa33635ba0f7743d3ea3fba15403c5e325034b776c29"
|
"encryptedApiKey_callList" : "6500079791e1e53739fb8e5cc399af42:63ea6dabaeae63c91bccf1ff2fc1f814aba828ad3b938f20f2e1aa33635ba0f7743d3ea3fba15403c5e325034b776c29"
|
||||||
}
|
}
|
||||||
@ -10,11 +10,7 @@ const connectDB = async () => {
|
|||||||
user: process.env.MYSQL_USER,
|
user: process.env.MYSQL_USER,
|
||||||
password: process.env.MYSQL_PASSWORD,
|
password: process.env.MYSQL_PASSWORD,
|
||||||
database: process.env.MYSQL_DATABASE,
|
database: process.env.MYSQL_DATABASE,
|
||||||
<<<<<<< HEAD
|
|
||||||
port: process.env.MYSQL_PORT || 3306,
|
port: process.env.MYSQL_PORT || 3306,
|
||||||
=======
|
|
||||||
port: process.env.PORT || 3306,
|
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
waitForConnections: true,
|
waitForConnections: true,
|
||||||
connectionLimit: 100,
|
connectionLimit: 100,
|
||||||
queueLimit: 0,
|
queueLimit: 0,
|
||||||
@ -35,8 +31,4 @@ const getPool = () => {
|
|||||||
return pool;
|
return pool;
|
||||||
};
|
};
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
module.exports = { connectDB, getPool };
|
module.exports = { connectDB, getPool };
|
||||||
=======
|
|
||||||
module.exports = { connectDB, getPool };
|
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
|
|||||||
@ -1,29 +1,29 @@
|
|||||||
const { fetchContacts, fetchCallList } = require('../services/apiService');
|
const { fetchContacts, fetchCallList } = require('../services/apiService');
|
||||||
|
|
||||||
async function getContacts(req, res) {
|
async function getContacts(req, res) {
|
||||||
try {
|
try {
|
||||||
const data = await fetchContacts();
|
const data = await fetchContacts();
|
||||||
res.json(data);
|
res.json(data);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
res.status(500).json({ error: err.message });
|
res.status(500).json({ error: err.message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getCallList(req, res) {
|
async function getCallList(req, res) {
|
||||||
|
|
||||||
const { assignedTo,call_id } = req.body || {};
|
const { assignedTo,call_id } = req.body || {};
|
||||||
|
|
||||||
if (!assignedTo && !call_id) {
|
if (!assignedTo && !call_id) {
|
||||||
return res.status(400).json({ error: "Missing assignedTo or call_id" });
|
return res.status(400).json({ error: "Missing assignedTo or call_id" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const data = await fetchCallList({assignedTo,call_id});
|
const data = await fetchCallList({assignedTo,call_id});
|
||||||
res.json(data);
|
res.json(data);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
res.status(500).json({ error: err.message });
|
res.status(500).json({ error: err.message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { getContacts, getCallList };
|
module.exports = { getContacts, getCallList };
|
||||||
60
controllers/authController.js
Normal file
60
controllers/authController.js
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
const axios = require('axios');
|
||||||
|
const { sendSignupEmail } = require('../utils/mailer');
|
||||||
|
const config = require('../config/config.json');
|
||||||
|
const { decrypt } = require('../services/encryptionService');
|
||||||
|
|
||||||
|
const signupUserRequest = async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { email, firstName, lastName, password } = req.body;
|
||||||
|
|
||||||
|
if (!email || !firstName || !lastName || !password) {
|
||||||
|
return res.status(400).json({ message: 'Email, firstName, lastName, and password are required.' });
|
||||||
|
}
|
||||||
|
|
||||||
|
const GHL_API_URL = 'https://rest.gohighlevel.com/v1/users';
|
||||||
|
const GHL_API_KEY = decrypt(config.encryptedApiKey); // Decrypt the API key
|
||||||
|
|
||||||
|
const response = await axios.get(GHL_API_URL, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${GHL_API_KEY}`
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const users = response.data?.users || [];
|
||||||
|
|
||||||
|
// Normalize emails for case-insensitive match
|
||||||
|
const requestedEmail = email.trim().toLowerCase();
|
||||||
|
|
||||||
|
const emailExists = users.some(user => {
|
||||||
|
const ghlEmail = user?.email?.trim().toLowerCase();
|
||||||
|
console.log(`🔍 Comparing: ${requestedEmail} === ${ghlEmail}`);
|
||||||
|
return ghlEmail === requestedEmail;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (emailExists) {
|
||||||
|
return res.status(409).json({ message: 'Email already exists in GoHighLevel.' });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attempt to send signup email (admin + user)
|
||||||
|
try {
|
||||||
|
const emailResponse = await sendSignupEmail(email, firstName, lastName, password);
|
||||||
|
return res.status(200).json({ message: 'Signup request successful.', emailResponse });
|
||||||
|
} catch (emailError) {
|
||||||
|
// Check if it's a rate limit error (thrown from sendSignupEmail)
|
||||||
|
if (emailError.status === 429) {
|
||||||
|
return res.status(429).json({ message: emailError.message });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unknown email send failure
|
||||||
|
console.error('📧 Email send error:', emailError);
|
||||||
|
return res.status(500).json({ message: 'Signup failed while sending email.', error: emailError.message });
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
console.error('❌ Signup process error:', err?.response?.data || err.message);
|
||||||
|
res.status(500).json({ message: 'Signup failed.', error: err.message });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = { signupUserRequest };
|
||||||
@ -1,143 +1,135 @@
|
|||||||
const { fetchContacts } = require("../services/apiService");
|
const { fetchContacts } = require("../services/apiService");
|
||||||
<<<<<<< HEAD
|
const { sendAlertToUser } = require("../services/webSocket");
|
||||||
const { sendAlertToUser } = require("../services/webSocket");
|
const jwt = require("jsonwebtoken");
|
||||||
const jwt = require("jsonwebtoken");
|
const {getPool} = require("../config/database")
|
||||||
const {getPool} = require("../config/database")
|
|
||||||
=======
|
const fieldTitleMap = {
|
||||||
const { sendAlertToUser } = require("../services/webSocket")
|
Hq5fePgYMo1lfrJeSXkr: "call_frequency",
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
QL0rzaEwmJaEk9jdYMs9: "greeting_script",
|
||||||
|
upW8g15t9YnYiWlnaBpr: "primary_caregiver_phone",
|
||||||
const fieldTitleMap = {
|
gdsuDxKmmudOEDk3FiQX: "call_active",
|
||||||
Hq5fePgYMo1lfrJeSXkr: "call_frequency",
|
"3U3ZJgLL1rpJJroD0Az7": "question_1_type",
|
||||||
QL0rzaEwmJaEk9jdYMs9: "greeting_script",
|
iCdzNGVcI9TXCMZB9VAA: "call_priority",
|
||||||
upW8g15t9YnYiWlnaBpr: "primary_caregiver_phone",
|
Q0tV2XVHkCCp3oYCc1uG: "closing_script",
|
||||||
gdsuDxKmmudOEDk3FiQX: "call_active",
|
lC7wcDZ1iwVMuVvCBKrQ: "voice_gender",
|
||||||
"3U3ZJgLL1rpJJroD0Az7": "question_1_type",
|
GAw9gU6eHmJCmVqpmrf3: "retry_max",
|
||||||
iCdzNGVcI9TXCMZB9VAA: "call_priority",
|
"24kfk9oSCFzPh2ebpyUl": "emergency_contact_name",
|
||||||
Q0tV2XVHkCCp3oYCc1uG: "closing_script",
|
cikiuNK65qNw4V5Gy4TR: "call_time",
|
||||||
lC7wcDZ1iwVMuVvCBKrQ: "voice_gender",
|
J3fWeliXkIMuYnkKk2yt: "voice_style",
|
||||||
GAw9gU6eHmJCmVqpmrf3: "retry_max",
|
u7WmIttXGLrmvGqnT9CH: "contact_type",
|
||||||
"24kfk9oSCFzPh2ebpyUl": "emergency_contact_name",
|
eEc7gSzB3fmqahLlr9xX: "retry_interval",
|
||||||
cikiuNK65qNw4V5Gy4TR: "call_time",
|
wZwE35nLUt4ofApaJSLk: "emergency_contact_phone",
|
||||||
J3fWeliXkIMuYnkKk2yt: "voice_style",
|
LYZXV61lONvQF3SoM95G: "primary_caregiver_name",
|
||||||
u7WmIttXGLrmvGqnT9CH: "contact_type",
|
"635VPvmnotbVwZOXMGf8": "primary_caregiver_email",
|
||||||
eEc7gSzB3fmqahLlr9xX: "retry_interval",
|
v6iwpMuopjEfPWBLMXEN: "secondary_caregiver_name",
|
||||||
wZwE35nLUt4ofApaJSLk: "emergency_contact_phone",
|
sPa3DwpIM6z5tDSfWxwf: "question_1_alert_on",
|
||||||
LYZXV61lONvQF3SoM95G: "primary_caregiver_name",
|
RrJXvwDnybenFmd31BnM: "secondary_caregiver_phone",
|
||||||
"635VPvmnotbVwZOXMGf8": "primary_caregiver_email",
|
mbqkQQaYyAovaxHfgWz0: "secondary_caregiver_email",
|
||||||
v6iwpMuopjEfPWBLMXEN: "secondary_caregiver_name",
|
cEnullg0BPqHvcbRLYKz: "escalation_order",
|
||||||
sPa3DwpIM6z5tDSfWxwf: "question_1_alert_on",
|
qY4kgf4j8qxbLrWJPDqJ: "question_2",
|
||||||
RrJXvwDnybenFmd31BnM: "secondary_caregiver_phone",
|
Ft47Zo8DdD3U0ZJw6dS3: "question_2_type",
|
||||||
mbqkQQaYyAovaxHfgWz0: "secondary_caregiver_email",
|
"7eXeyWZwLg7f55NJdOUI": "question_2_alert_on",
|
||||||
cEnullg0BPqHvcbRLYKz: "escalation_order",
|
kpyhzADdBf2WSfAL3X5M: "How r you",
|
||||||
qY4kgf4j8qxbLrWJPDqJ: "question_2",
|
};
|
||||||
Ft47Zo8DdD3U0ZJw6dS3: "question_2_type",
|
|
||||||
"7eXeyWZwLg7f55NJdOUI": "question_2_alert_on",
|
async function getUserData(req, res) {
|
||||||
kpyhzADdBf2WSfAL3X5M: "How r you",
|
|
||||||
};
|
const { userId, token } = req.body || {};
|
||||||
|
|
||||||
async function getUserData(req, res) {
|
if (!userId || !token) {
|
||||||
|
return res.status(400).json({ error: "Missing userId or token" });
|
||||||
const { userId, token } = req.body || {};
|
}
|
||||||
|
|
||||||
if (!userId || !token) {
|
try {
|
||||||
return res.status(400).json({ error: "Missing userId or token" });
|
const allContacts = await fetchContacts();
|
||||||
}
|
|
||||||
|
const filteredContacts = allContacts.contacts
|
||||||
try {
|
.filter((contact) => contact.assignedTo === userId)
|
||||||
const allContacts = await fetchContacts();
|
.map((contact) => {
|
||||||
|
// Map customField array to fields object with mapped keys
|
||||||
const filteredContacts = allContacts.contacts
|
const mappedFields = {};
|
||||||
.filter((contact) => contact.assignedTo === userId)
|
|
||||||
.map((contact) => {
|
(contact.customField || []).forEach(({ id, value }) => {
|
||||||
// Map customField array to fields object with mapped keys
|
const mappedKey = fieldTitleMap[id] || id;
|
||||||
const mappedFields = {};
|
mappedFields[mappedKey] = value;
|
||||||
|
});
|
||||||
(contact.customField || []).forEach(({ id, value }) => {
|
|
||||||
const mappedKey = fieldTitleMap[id] || id;
|
return {
|
||||||
mappedFields[mappedKey] = value;
|
...contact,
|
||||||
});
|
fields: mappedFields,
|
||||||
|
customField: undefined, // or delete contact.customField to omit
|
||||||
return {
|
};
|
||||||
...contact,
|
});
|
||||||
fields: mappedFields,
|
|
||||||
customField: undefined, // or delete contact.customField to omit
|
return res.json({ filteredContacts });
|
||||||
};
|
} catch (error) {
|
||||||
});
|
return res.status(500).json({ error: error.message });
|
||||||
|
}
|
||||||
return res.json({ filteredContacts });
|
}
|
||||||
} catch (error) {
|
|
||||||
return res.status(500).json({ error: error.message });
|
async function getNotifications(req,res){
|
||||||
}
|
if(req.body){
|
||||||
}
|
|
||||||
|
console.log("req body---",req.body)
|
||||||
async function getNotifications(req,res){
|
sendAlertToUser(req.body.userId,req.body.alert)
|
||||||
if(req.body){
|
return res.status(200).json({ message : "sent alert !!" });
|
||||||
|
}
|
||||||
console.log("req body---",req.body)
|
else{
|
||||||
sendAlertToUser(req.body.userId,req.body.alert)
|
return res.status(403).json({ message : "Please send notifications!!" });
|
||||||
return res.status(200).json({ message : "sent alert !!" });
|
}
|
||||||
}
|
|
||||||
else{
|
|
||||||
return res.status(403).json({ message : "Please send notifications!!" });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function updateAlerts(req, res) {
|
||||||
|
|
||||||
}
|
let id = req.body.id
|
||||||
|
|
||||||
<<<<<<< HEAD
|
const authHeader = req.headers['authorization'];
|
||||||
async function updateAlerts(req, res) {
|
if (!authHeader || !authHeader.startsWith('Bearer ')) {
|
||||||
|
return res.status(401).json({ error: 'Missing or invalid Authorization header' });
|
||||||
let id = req.body.id
|
}
|
||||||
|
|
||||||
const authHeader = req.headers['authorization'];
|
const token = authHeader.split(' ')[1];
|
||||||
if (!authHeader || !authHeader.startsWith('Bearer ')) {
|
if(!token || !id){
|
||||||
return res.status(401).json({ error: 'Missing or invalid Authorization header' });
|
return res.status(401).json({ error: 'token and id both are required' });
|
||||||
}
|
}
|
||||||
|
|
||||||
const token = authHeader.split(' ')[1];
|
console.log("ack token---",token)
|
||||||
if(!token || !id){
|
|
||||||
return res.status(401).json({ error: 'token and id both are required' });
|
let userId;
|
||||||
}
|
|
||||||
|
|
||||||
console.log("ack token---",token)
|
try {
|
||||||
|
const decoded = jwt.decode(token); // Use jwt.verify(token, secret) if validation is needed
|
||||||
let userId;
|
userId = decoded?.claims?.user_id;
|
||||||
|
|
||||||
|
if (!userId) {
|
||||||
try {
|
return res.status(401).json({ error: 'Invalid token: user_id missing' });
|
||||||
const decoded = jwt.decode(token); // Use jwt.verify(token, secret) if validation is needed
|
}
|
||||||
userId = decoded?.claims?.user_id;
|
} catch (err) {
|
||||||
|
console.error('Token decode failed:', err);
|
||||||
if (!userId) {
|
return res.status(401).json({ error: 'Failed to decode token' });
|
||||||
return res.status(401).json({ error: 'Invalid token: user_id missing' });
|
}
|
||||||
}
|
|
||||||
} catch (err) {
|
try {
|
||||||
console.error('Token decode failed:', err);
|
const pool = getPool();
|
||||||
return res.status(401).json({ error: 'Failed to decode token' });
|
// const placeholders = alertIds.map(() => '?').join(',');
|
||||||
}
|
|
||||||
|
const [result] = await pool.query(
|
||||||
try {
|
`UPDATE user_alerts SET acknowledged = 1 WHERE user_id = ? AND id = ?`,
|
||||||
const pool = getPool();
|
[userId, id]
|
||||||
// const placeholders = alertIds.map(() => '?').join(',');
|
);
|
||||||
|
|
||||||
const [result] = await pool.query(
|
|
||||||
`UPDATE user_alerts SET acknowledged = 1 WHERE user_id = ? AND id = ?`,
|
res.status(200).json({
|
||||||
[userId, id]
|
message: 'Alerts updated successfully',
|
||||||
);
|
affectedRows: result.affectedRows,
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
res.status(200).json({
|
console.error('❌ Failed to update alerts:', err);
|
||||||
message: 'Alerts updated successfully',
|
res.status(500).json({ error: 'Internal server error' });
|
||||||
affectedRows: result.affectedRows,
|
}
|
||||||
});
|
}
|
||||||
} catch (err) {
|
module.exports = { getUserData ,getNotifications,updateAlerts};
|
||||||
console.error('❌ Failed to update alerts:', err);
|
|
||||||
res.status(500).json({ error: 'Internal server error' });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
module.exports = { getUserData ,getNotifications,updateAlerts};
|
|
||||||
=======
|
|
||||||
module.exports = { getUserData ,getNotifications};
|
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
34
node_modules/.bin/mkdirp.cmd
generated
vendored
Normal file → Executable file
34
node_modules/.bin/mkdirp.cmd
generated
vendored
Normal file → Executable file
@ -1,17 +1,17 @@
|
|||||||
@ECHO off
|
@ECHO off
|
||||||
GOTO start
|
GOTO start
|
||||||
:find_dp0
|
:find_dp0
|
||||||
SET dp0=%~dp0
|
SET dp0=%~dp0
|
||||||
EXIT /b
|
EXIT /b
|
||||||
:start
|
:start
|
||||||
SETLOCAL
|
SETLOCAL
|
||||||
CALL :find_dp0
|
CALL :find_dp0
|
||||||
|
|
||||||
IF EXIST "%dp0%\node.exe" (
|
IF EXIST "%dp0%\node.exe" (
|
||||||
SET "_prog=%dp0%\node.exe"
|
SET "_prog=%dp0%\node.exe"
|
||||||
) ELSE (
|
) ELSE (
|
||||||
SET "_prog=node"
|
SET "_prog=node"
|
||||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||||
)
|
)
|
||||||
|
|
||||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\mkdirp\bin\cmd.js" %*
|
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\mkdirp\bin\cmd.js" %*
|
||||||
|
|||||||
34
node_modules/.bin/nodemon.cmd
generated
vendored
Normal file → Executable file
34
node_modules/.bin/nodemon.cmd
generated
vendored
Normal file → Executable file
@ -1,17 +1,17 @@
|
|||||||
@ECHO off
|
@ECHO off
|
||||||
GOTO start
|
GOTO start
|
||||||
:find_dp0
|
:find_dp0
|
||||||
SET dp0=%~dp0
|
SET dp0=%~dp0
|
||||||
EXIT /b
|
EXIT /b
|
||||||
:start
|
:start
|
||||||
SETLOCAL
|
SETLOCAL
|
||||||
CALL :find_dp0
|
CALL :find_dp0
|
||||||
|
|
||||||
IF EXIST "%dp0%\node.exe" (
|
IF EXIST "%dp0%\node.exe" (
|
||||||
SET "_prog=%dp0%\node.exe"
|
SET "_prog=%dp0%\node.exe"
|
||||||
) ELSE (
|
) ELSE (
|
||||||
SET "_prog=node"
|
SET "_prog=node"
|
||||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||||
)
|
)
|
||||||
|
|
||||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\nodemon\bin\nodemon.js" %*
|
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\nodemon\bin\nodemon.js" %*
|
||||||
|
|||||||
34
node_modules/.bin/nodetouch.cmd
generated
vendored
Normal file → Executable file
34
node_modules/.bin/nodetouch.cmd
generated
vendored
Normal file → Executable file
@ -1,17 +1,17 @@
|
|||||||
@ECHO off
|
@ECHO off
|
||||||
GOTO start
|
GOTO start
|
||||||
:find_dp0
|
:find_dp0
|
||||||
SET dp0=%~dp0
|
SET dp0=%~dp0
|
||||||
EXIT /b
|
EXIT /b
|
||||||
:start
|
:start
|
||||||
SETLOCAL
|
SETLOCAL
|
||||||
CALL :find_dp0
|
CALL :find_dp0
|
||||||
|
|
||||||
IF EXIST "%dp0%\node.exe" (
|
IF EXIST "%dp0%\node.exe" (
|
||||||
SET "_prog=%dp0%\node.exe"
|
SET "_prog=%dp0%\node.exe"
|
||||||
) ELSE (
|
) ELSE (
|
||||||
SET "_prog=node"
|
SET "_prog=node"
|
||||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||||
)
|
)
|
||||||
|
|
||||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\touch\bin\nodetouch.js" %*
|
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\touch\bin\nodetouch.js" %*
|
||||||
|
|||||||
34
node_modules/.bin/semver.cmd
generated
vendored
Normal file → Executable file
34
node_modules/.bin/semver.cmd
generated
vendored
Normal file → Executable file
@ -1,17 +1,17 @@
|
|||||||
@ECHO off
|
@ECHO off
|
||||||
GOTO start
|
GOTO start
|
||||||
:find_dp0
|
:find_dp0
|
||||||
SET dp0=%~dp0
|
SET dp0=%~dp0
|
||||||
EXIT /b
|
EXIT /b
|
||||||
:start
|
:start
|
||||||
SETLOCAL
|
SETLOCAL
|
||||||
CALL :find_dp0
|
CALL :find_dp0
|
||||||
|
|
||||||
IF EXIST "%dp0%\node.exe" (
|
IF EXIST "%dp0%\node.exe" (
|
||||||
SET "_prog=%dp0%\node.exe"
|
SET "_prog=%dp0%\node.exe"
|
||||||
) ELSE (
|
) ELSE (
|
||||||
SET "_prog=node"
|
SET "_prog=node"
|
||||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||||
)
|
)
|
||||||
|
|
||||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\semver\bin\semver.js" %*
|
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\semver\bin\semver.js" %*
|
||||||
|
|||||||
95
node_modules/.package-lock.json
generated
vendored
95
node_modules/.package-lock.json
generated
vendored
@ -39,7 +39,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||||
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
|
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
|
||||||
},
|
},
|
||||||
<<<<<<< HEAD
|
|
||||||
"node_modules/aws-ssl-profiles": {
|
"node_modules/aws-ssl-profiles": {
|
||||||
"version": "1.1.2",
|
"version": "1.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/aws-ssl-profiles/-/aws-ssl-profiles-1.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/aws-ssl-profiles/-/aws-ssl-profiles-1.1.2.tgz",
|
||||||
@ -49,8 +48,6 @@
|
|||||||
"node": ">= 6.0.0"
|
"node": ">= 6.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
=======
|
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
"node_modules/axios": {
|
"node_modules/axios": {
|
||||||
"version": "1.9.0",
|
"version": "1.9.0",
|
||||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.9.0.tgz",
|
"resolved": "https://registry.npmjs.org/axios/-/axios-1.9.0.tgz",
|
||||||
@ -67,7 +64,6 @@
|
|||||||
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
|
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
<<<<<<< HEAD
|
|
||||||
"node_modules/bignumber.js": {
|
"node_modules/bignumber.js": {
|
||||||
"version": "9.0.0",
|
"version": "9.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.0.tgz",
|
||||||
@ -77,8 +73,6 @@
|
|||||||
"node": "*"
|
"node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
=======
|
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
"node_modules/binary-extensions": {
|
"node_modules/binary-extensions": {
|
||||||
"version": "2.3.0",
|
"version": "2.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz",
|
||||||
@ -141,7 +135,8 @@
|
|||||||
"node_modules/buffer-from": {
|
"node_modules/buffer-from": {
|
||||||
"version": "1.1.2",
|
"version": "1.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
|
||||||
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ=="
|
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
|
||||||
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/busboy": {
|
"node_modules/busboy": {
|
||||||
"version": "1.6.0",
|
"version": "1.6.0",
|
||||||
@ -231,16 +226,17 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/concat-stream": {
|
"node_modules/concat-stream": {
|
||||||
"version": "1.6.2",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
|
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz",
|
||||||
"integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==",
|
"integrity": "sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==",
|
||||||
"engines": [
|
"engines": [
|
||||||
"node >= 0.8"
|
"node >= 6.0"
|
||||||
],
|
],
|
||||||
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"buffer-from": "^1.0.0",
|
"buffer-from": "^1.0.0",
|
||||||
"inherits": "^2.0.3",
|
"inherits": "^2.0.3",
|
||||||
"readable-stream": "^2.2.2",
|
"readable-stream": "^3.0.2",
|
||||||
"typedarray": "^0.0.6"
|
"typedarray": "^0.0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -326,7 +322,6 @@
|
|||||||
"node": ">=0.4.0"
|
"node": ">=0.4.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
<<<<<<< HEAD
|
|
||||||
"node_modules/denque": {
|
"node_modules/denque": {
|
||||||
"version": "2.1.0",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/denque/-/denque-2.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/denque/-/denque-2.1.0.tgz",
|
||||||
@ -336,8 +331,6 @@
|
|||||||
"node": ">=0.10"
|
"node": ">=0.10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
=======
|
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
"node_modules/depd": {
|
"node_modules/depd": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
|
||||||
@ -597,7 +590,6 @@
|
|||||||
"url": "https://github.com/sponsors/ljharb"
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
<<<<<<< HEAD
|
|
||||||
"node_modules/generate-function": {
|
"node_modules/generate-function": {
|
||||||
"version": "2.3.1",
|
"version": "2.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.3.1.tgz",
|
||||||
@ -607,8 +599,6 @@
|
|||||||
"is-property": "^1.0.2"
|
"is-property": "^1.0.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
=======
|
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
"node_modules/get-intrinsic": {
|
"node_modules/get-intrinsic": {
|
||||||
"version": "1.3.0",
|
"version": "1.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
|
||||||
@ -810,15 +800,12 @@
|
|||||||
"resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz",
|
||||||
"integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ=="
|
"integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ=="
|
||||||
},
|
},
|
||||||
<<<<<<< HEAD
|
|
||||||
"node_modules/is-property": {
|
"node_modules/is-property": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz",
|
||||||
"integrity": "sha512-Ks/IoX00TtClbGQr4TWXemAnktAQvYB7HzcCxDGqEZU6oCmb2INHuOoKxbtR+HFkmYWBKv/dOZtGRiAjDhj92g==",
|
"integrity": "sha512-Ks/IoX00TtClbGQr4TWXemAnktAQvYB7HzcCxDGqEZU6oCmb2INHuOoKxbtR+HFkmYWBKv/dOZtGRiAjDhj92g==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
=======
|
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
"node_modules/isarray": {
|
"node_modules/isarray": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
|
||||||
@ -909,7 +896,6 @@
|
|||||||
"integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==",
|
"integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
<<<<<<< HEAD
|
|
||||||
"node_modules/long": {
|
"node_modules/long": {
|
||||||
"version": "5.3.2",
|
"version": "5.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/long/-/long-5.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/long/-/long-5.3.2.tgz",
|
||||||
@ -940,8 +926,6 @@
|
|||||||
"url": "https://github.com/sponsors/wellwelwel"
|
"url": "https://github.com/sponsors/wellwelwel"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
=======
|
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
"node_modules/math-intrinsics": {
|
"node_modules/math-intrinsics": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
|
||||||
@ -1025,17 +1009,18 @@
|
|||||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
|
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
|
||||||
},
|
},
|
||||||
"node_modules/multer": {
|
"node_modules/multer": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/multer/-/multer-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/multer/-/multer-2.0.1.tgz",
|
||||||
"integrity": "sha512-bS8rPZurbAuHGAnApbM9d4h1wSoYqrOqkE+6a64KLMK9yWU7gJXBDDVklKQ3TPi9DRb85cRs6yXaC0+cjxRtRg==",
|
"integrity": "sha512-Ug8bXeTIUlxurg8xLTEskKShvcKDZALo1THEX5E41pYCD2sCVub5/kIRIGqWNoqV6szyLyQKV6mD4QUrWE5GCQ==",
|
||||||
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"append-field": "^1.0.0",
|
"append-field": "^1.0.0",
|
||||||
"busboy": "^1.0.0",
|
"busboy": "^1.6.0",
|
||||||
"concat-stream": "^1.5.2",
|
"concat-stream": "^2.0.0",
|
||||||
"mkdirp": "^0.5.4",
|
"mkdirp": "^0.5.6",
|
||||||
"object-assign": "^4.1.1",
|
"object-assign": "^4.1.1",
|
||||||
"type-is": "^1.6.4",
|
"type-is": "^1.6.18",
|
||||||
"xtend": "^4.0.0"
|
"xtend": "^4.0.2"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 10.16.0"
|
"node": ">= 10.16.0"
|
||||||
@ -1080,7 +1065,6 @@
|
|||||||
"node": ">= 0.6"
|
"node": ">= 0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
<<<<<<< HEAD
|
|
||||||
"node_modules/mysql": {
|
"node_modules/mysql": {
|
||||||
"version": "2.18.1",
|
"version": "2.18.1",
|
||||||
"resolved": "https://registry.npmjs.org/mysql/-/mysql-2.18.1.tgz",
|
"resolved": "https://registry.npmjs.org/mysql/-/mysql-2.18.1.tgz",
|
||||||
@ -1158,8 +1142,6 @@
|
|||||||
"node": ">=12.0.0"
|
"node": ">=12.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
=======
|
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
"node_modules/negotiator": {
|
"node_modules/negotiator": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz",
|
||||||
@ -1168,6 +1150,15 @@
|
|||||||
"node": ">= 0.6"
|
"node": ">= 0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/nodemailer": {
|
||||||
|
"version": "7.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-7.0.3.tgz",
|
||||||
|
"integrity": "sha512-Ajq6Sz1x7cIK3pN6KesGTah+1gnwMnx5gKl3piQlQQE/PwyJ4Mbc8is2psWYxK3RJTVeqsDaCv8ZzXLCDHMTZw==",
|
||||||
|
"license": "MIT-0",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/nodemon": {
|
"node_modules/nodemon": {
|
||||||
"version": "3.1.10",
|
"version": "3.1.10",
|
||||||
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.10.tgz",
|
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.10.tgz",
|
||||||
@ -1336,24 +1327,19 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/readable-stream": {
|
"node_modules/readable-stream": {
|
||||||
"version": "2.3.8",
|
"version": "3.6.2",
|
||||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz",
|
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz",
|
||||||
"integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==",
|
"integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==",
|
||||||
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core-util-is": "~1.0.0",
|
"inherits": "^2.0.3",
|
||||||
"inherits": "~2.0.3",
|
"string_decoder": "^1.1.1",
|
||||||
"isarray": "~1.0.0",
|
"util-deprecate": "^1.0.1"
|
||||||
"process-nextick-args": "~2.0.0",
|
},
|
||||||
"safe-buffer": "~5.1.1",
|
"engines": {
|
||||||
"string_decoder": "~1.1.1",
|
"node": ">= 6"
|
||||||
"util-deprecate": "~1.0.1"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/readable-stream/node_modules/safe-buffer": {
|
|
||||||
"version": "5.1.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
|
||||||
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
|
|
||||||
},
|
|
||||||
"node_modules/readdirp": {
|
"node_modules/readdirp": {
|
||||||
"version": "3.6.0",
|
"version": "3.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz",
|
||||||
@ -1437,14 +1423,11 @@
|
|||||||
"node": ">= 18"
|
"node": ">= 18"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
<<<<<<< HEAD
|
|
||||||
"node_modules/seq-queue": {
|
"node_modules/seq-queue": {
|
||||||
"version": "0.0.5",
|
"version": "0.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/seq-queue/-/seq-queue-0.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/seq-queue/-/seq-queue-0.0.5.tgz",
|
||||||
"integrity": "sha512-hr3Wtp/GZIc/6DAGPDcV4/9WoZhjrkXsi5B/07QgX8tsdc6ilr7BFM6PM6rbdAX1kFSDYeZGLipIZZKyQP0O5Q=="
|
"integrity": "sha512-hr3Wtp/GZIc/6DAGPDcV4/9WoZhjrkXsi5B/07QgX8tsdc6ilr7BFM6PM6rbdAX1kFSDYeZGLipIZZKyQP0O5Q=="
|
||||||
},
|
},
|
||||||
=======
|
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
"node_modules/serve-static": {
|
"node_modules/serve-static": {
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.0.tgz",
|
||||||
@ -1544,7 +1527,6 @@
|
|||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
<<<<<<< HEAD
|
|
||||||
"node_modules/sqlstring": {
|
"node_modules/sqlstring": {
|
||||||
"version": "2.3.1",
|
"version": "2.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/sqlstring/-/sqlstring-2.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/sqlstring/-/sqlstring-2.3.1.tgz",
|
||||||
@ -1554,8 +1536,6 @@
|
|||||||
"node": ">= 0.6"
|
"node": ">= 0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
=======
|
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
"node_modules/statuses": {
|
"node_modules/statuses": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
|
||||||
@ -1642,7 +1622,8 @@
|
|||||||
"node_modules/typedarray": {
|
"node_modules/typedarray": {
|
||||||
"version": "0.0.6",
|
"version": "0.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
|
||||||
"integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA=="
|
"integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==",
|
||||||
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/undefsafe": {
|
"node_modules/undefsafe": {
|
||||||
"version": "2.0.5",
|
"version": "2.0.5",
|
||||||
|
|||||||
0
node_modules/aws-ssl-profiles/package.json
generated
vendored
Normal file → Executable file
0
node_modules/aws-ssl-profiles/package.json
generated
vendored
Normal file → Executable file
1854
node_modules/axios/CHANGELOG.md
generated
vendored
1854
node_modules/axios/CHANGELOG.md
generated
vendored
File diff suppressed because it is too large
Load Diff
532
node_modules/bignumber.js/CHANGELOG.md
generated
vendored
532
node_modules/bignumber.js/CHANGELOG.md
generated
vendored
@ -1,266 +1,266 @@
|
|||||||
#### 9.0.0
|
#### 9.0.0
|
||||||
* 27/05/2019
|
* 27/05/2019
|
||||||
* For compatibility with legacy browsers, remove `Symbol` references.
|
* For compatibility with legacy browsers, remove `Symbol` references.
|
||||||
|
|
||||||
#### 8.1.1
|
#### 8.1.1
|
||||||
* 24/02/2019
|
* 24/02/2019
|
||||||
* [BUGFIX] #222 Restore missing `var` to `export BigNumber`.
|
* [BUGFIX] #222 Restore missing `var` to `export BigNumber`.
|
||||||
* Allow any key in BigNumber.Instance in *bignumber.d.ts*.
|
* Allow any key in BigNumber.Instance in *bignumber.d.ts*.
|
||||||
|
|
||||||
#### 8.1.0
|
#### 8.1.0
|
||||||
* 23/02/2019
|
* 23/02/2019
|
||||||
* [NEW FEATURE] #220 Create a BigNumber using `{s, e, c}`.
|
* [NEW FEATURE] #220 Create a BigNumber using `{s, e, c}`.
|
||||||
* [NEW FEATURE] `isBigNumber`: if `BigNumber.DEBUG` is `true`, also check that the BigNumber instance is well-formed.
|
* [NEW FEATURE] `isBigNumber`: if `BigNumber.DEBUG` is `true`, also check that the BigNumber instance is well-formed.
|
||||||
* Remove `instanceof` checks; just use `_isBigNumber` to identify a BigNumber instance.
|
* Remove `instanceof` checks; just use `_isBigNumber` to identify a BigNumber instance.
|
||||||
* Add `_isBigNumber` to prototype in *bignumber.mjs*.
|
* Add `_isBigNumber` to prototype in *bignumber.mjs*.
|
||||||
* Add tests for BigNumber creation from object.
|
* Add tests for BigNumber creation from object.
|
||||||
* Update *API.html*.
|
* Update *API.html*.
|
||||||
|
|
||||||
#### 8.0.2
|
#### 8.0.2
|
||||||
* 13/01/2019
|
* 13/01/2019
|
||||||
* #209 `toPrecision` without argument should follow `toString`.
|
* #209 `toPrecision` without argument should follow `toString`.
|
||||||
* Improve *Use* section of *README*.
|
* Improve *Use* section of *README*.
|
||||||
* Optimise `toString(10)`.
|
* Optimise `toString(10)`.
|
||||||
* Add verson number to API doc.
|
* Add verson number to API doc.
|
||||||
|
|
||||||
#### 8.0.1
|
#### 8.0.1
|
||||||
* 01/11/2018
|
* 01/11/2018
|
||||||
* Rest parameter must be array type in *bignumber.d.ts*.
|
* Rest parameter must be array type in *bignumber.d.ts*.
|
||||||
|
|
||||||
#### 8.0.0
|
#### 8.0.0
|
||||||
* 01/11/2018
|
* 01/11/2018
|
||||||
* [NEW FEATURE] Add `BigNumber.sum` method.
|
* [NEW FEATURE] Add `BigNumber.sum` method.
|
||||||
* [NEW FEATURE]`toFormat`: add `prefix` and `suffix` options.
|
* [NEW FEATURE]`toFormat`: add `prefix` and `suffix` options.
|
||||||
* [NEW FEATURE] #178 Pass custom formatting to `toFormat`.
|
* [NEW FEATURE] #178 Pass custom formatting to `toFormat`.
|
||||||
* [BREAKING CHANGE] #184 `toFraction`: return array of BigNumbers not strings.
|
* [BREAKING CHANGE] #184 `toFraction`: return array of BigNumbers not strings.
|
||||||
* [NEW FEATURE] #185 Enable overwrite of `valueOf` to prevent accidental addition to string.
|
* [NEW FEATURE] #185 Enable overwrite of `valueOf` to prevent accidental addition to string.
|
||||||
* #183 Add Node.js `crypto` requirement to documentation.
|
* #183 Add Node.js `crypto` requirement to documentation.
|
||||||
* [BREAKING CHANGE] #198 Disallow signs and whitespace in custom alphabet.
|
* [BREAKING CHANGE] #198 Disallow signs and whitespace in custom alphabet.
|
||||||
* [NEW FEATURE] #188 Implement `util.inspect.custom` for Node.js REPL.
|
* [NEW FEATURE] #188 Implement `util.inspect.custom` for Node.js REPL.
|
||||||
* #170 Make `isBigNumber` a type guard in *bignumber.d.ts*.
|
* #170 Make `isBigNumber` a type guard in *bignumber.d.ts*.
|
||||||
* [BREAKING CHANGE] `BigNumber.min` and `BigNumber.max`: don't accept an array.
|
* [BREAKING CHANGE] `BigNumber.min` and `BigNumber.max`: don't accept an array.
|
||||||
* Update *.travis.yml*.
|
* Update *.travis.yml*.
|
||||||
* Remove *bower.json*.
|
* Remove *bower.json*.
|
||||||
|
|
||||||
#### 7.2.1
|
#### 7.2.1
|
||||||
* 24/05/2018
|
* 24/05/2018
|
||||||
* Add `browser` field to *package.json*.
|
* Add `browser` field to *package.json*.
|
||||||
|
|
||||||
#### 7.2.0
|
#### 7.2.0
|
||||||
* 22/05/2018
|
* 22/05/2018
|
||||||
* #166 Correct *.mjs* file. Remove extension from `main` field in *package.json*.
|
* #166 Correct *.mjs* file. Remove extension from `main` field in *package.json*.
|
||||||
|
|
||||||
#### 7.1.0
|
#### 7.1.0
|
||||||
* 18/05/2018
|
* 18/05/2018
|
||||||
* Add `module` field to *package.json* for *bignumber.mjs*.
|
* Add `module` field to *package.json* for *bignumber.mjs*.
|
||||||
|
|
||||||
#### 7.0.2
|
#### 7.0.2
|
||||||
* 17/05/2018
|
* 17/05/2018
|
||||||
* #165 Bugfix: upper-case letters for bases 11-36 in a custom alphabet.
|
* #165 Bugfix: upper-case letters for bases 11-36 in a custom alphabet.
|
||||||
* Add note to *README* regarding creating BigNumbers from Number values.
|
* Add note to *README* regarding creating BigNumbers from Number values.
|
||||||
|
|
||||||
#### 7.0.1
|
#### 7.0.1
|
||||||
* 26/04/2018
|
* 26/04/2018
|
||||||
* #158 Fix global object variable name typo.
|
* #158 Fix global object variable name typo.
|
||||||
|
|
||||||
#### 7.0.0
|
#### 7.0.0
|
||||||
* 26/04/2018
|
* 26/04/2018
|
||||||
* #143 Remove global BigNumber from typings.
|
* #143 Remove global BigNumber from typings.
|
||||||
* #144 Enable compatibility with `Object.freeze(Object.prototype)`.
|
* #144 Enable compatibility with `Object.freeze(Object.prototype)`.
|
||||||
* #148 #123 #11 Only throw on a number primitive with more than 15 significant digits if `BigNumber.DEBUG` is `true`.
|
* #148 #123 #11 Only throw on a number primitive with more than 15 significant digits if `BigNumber.DEBUG` is `true`.
|
||||||
* Only throw on an invalid BigNumber value if `BigNumber.DEBUG` is `true`. Return BigNumber `NaN` instead.
|
* Only throw on an invalid BigNumber value if `BigNumber.DEBUG` is `true`. Return BigNumber `NaN` instead.
|
||||||
* #154 `exponentiatedBy`: allow BigNumber exponent.
|
* #154 `exponentiatedBy`: allow BigNumber exponent.
|
||||||
* #156 Prevent Content Security Policy *unsafe-eval* issue.
|
* #156 Prevent Content Security Policy *unsafe-eval* issue.
|
||||||
* `toFraction`: allow `Infinity` maximum denominator.
|
* `toFraction`: allow `Infinity` maximum denominator.
|
||||||
* Comment-out some excess tests to reduce test time.
|
* Comment-out some excess tests to reduce test time.
|
||||||
* Amend indentation and other spacing.
|
* Amend indentation and other spacing.
|
||||||
|
|
||||||
#### 6.0.0
|
#### 6.0.0
|
||||||
* 26/01/2018
|
* 26/01/2018
|
||||||
* #137 Implement `APLHABET` configuration option.
|
* #137 Implement `APLHABET` configuration option.
|
||||||
* Remove `ERRORS` configuration option.
|
* Remove `ERRORS` configuration option.
|
||||||
* Remove `toDigits` method; extend `precision` method accordingly.
|
* Remove `toDigits` method; extend `precision` method accordingly.
|
||||||
* Remove s`round` method; extend `decimalPlaces` method accordingly.
|
* Remove s`round` method; extend `decimalPlaces` method accordingly.
|
||||||
* Remove methods: `ceil`, `floor`, and `truncated`.
|
* Remove methods: `ceil`, `floor`, and `truncated`.
|
||||||
* Remove method aliases: `add`, `cmp`, `isInt`, `isNeg`, `trunc`, `mul`, `neg` and `sub`.
|
* Remove method aliases: `add`, `cmp`, `isInt`, `isNeg`, `trunc`, `mul`, `neg` and `sub`.
|
||||||
* Rename methods: `shift` to `shiftedBy`, `another` to `clone`, `toPower` to `exponentiatedBy`, and `equals` to `isEqualTo`.
|
* Rename methods: `shift` to `shiftedBy`, `another` to `clone`, `toPower` to `exponentiatedBy`, and `equals` to `isEqualTo`.
|
||||||
* Rename methods: add `is` prefix to `greaterThan`, `greaterThanOrEqualTo`, `lessThan` and `lessThanOrEqualTo`.
|
* Rename methods: add `is` prefix to `greaterThan`, `greaterThanOrEqualTo`, `lessThan` and `lessThanOrEqualTo`.
|
||||||
* Add methods: `multipliedBy`, `isBigNumber`, `isPositive`, `integerValue`, `maximum` and `minimum`.
|
* Add methods: `multipliedBy`, `isBigNumber`, `isPositive`, `integerValue`, `maximum` and `minimum`.
|
||||||
* Refactor test suite.
|
* Refactor test suite.
|
||||||
* Add *CHANGELOG.md*.
|
* Add *CHANGELOG.md*.
|
||||||
* Rewrite *bignumber.d.ts*.
|
* Rewrite *bignumber.d.ts*.
|
||||||
* Redo API image.
|
* Redo API image.
|
||||||
|
|
||||||
#### 5.0.0
|
#### 5.0.0
|
||||||
* 27/11/2017
|
* 27/11/2017
|
||||||
* #81 Don't throw on constructor call without `new`.
|
* #81 Don't throw on constructor call without `new`.
|
||||||
|
|
||||||
#### 4.1.0
|
#### 4.1.0
|
||||||
* 26/09/2017
|
* 26/09/2017
|
||||||
* Remove node 0.6 from *.travis.yml*.
|
* Remove node 0.6 from *.travis.yml*.
|
||||||
* Add *bignumber.mjs*.
|
* Add *bignumber.mjs*.
|
||||||
|
|
||||||
#### 4.0.4
|
#### 4.0.4
|
||||||
* 03/09/2017
|
* 03/09/2017
|
||||||
* Add missing aliases to *bignumber.d.ts*.
|
* Add missing aliases to *bignumber.d.ts*.
|
||||||
|
|
||||||
#### 4.0.3
|
#### 4.0.3
|
||||||
* 30/08/2017
|
* 30/08/2017
|
||||||
* Add types: *bignumber.d.ts*.
|
* Add types: *bignumber.d.ts*.
|
||||||
|
|
||||||
#### 4.0.2
|
#### 4.0.2
|
||||||
* 03/05/2017
|
* 03/05/2017
|
||||||
* #120 Workaround Safari/Webkit bug.
|
* #120 Workaround Safari/Webkit bug.
|
||||||
|
|
||||||
#### 4.0.1
|
#### 4.0.1
|
||||||
* 05/04/2017
|
* 05/04/2017
|
||||||
* #121 BigNumber.default to BigNumber['default'].
|
* #121 BigNumber.default to BigNumber['default'].
|
||||||
|
|
||||||
#### 4.0.0
|
#### 4.0.0
|
||||||
* 09/01/2017
|
* 09/01/2017
|
||||||
* Replace BigNumber.isBigNumber method with isBigNumber prototype property.
|
* Replace BigNumber.isBigNumber method with isBigNumber prototype property.
|
||||||
|
|
||||||
#### 3.1.2
|
#### 3.1.2
|
||||||
* 08/01/2017
|
* 08/01/2017
|
||||||
* Minor documentation edit.
|
* Minor documentation edit.
|
||||||
|
|
||||||
#### 3.1.1
|
#### 3.1.1
|
||||||
* 08/01/2017
|
* 08/01/2017
|
||||||
* Uncomment `isBigNumber` tests.
|
* Uncomment `isBigNumber` tests.
|
||||||
* Ignore dot files.
|
* Ignore dot files.
|
||||||
|
|
||||||
#### 3.1.0
|
#### 3.1.0
|
||||||
* 08/01/2017
|
* 08/01/2017
|
||||||
* Add `isBigNumber` method.
|
* Add `isBigNumber` method.
|
||||||
|
|
||||||
#### 3.0.2
|
#### 3.0.2
|
||||||
* 08/01/2017
|
* 08/01/2017
|
||||||
* Bugfix: Possible incorrect value of `ERRORS` after a `BigNumber.another` call (due to `parseNumeric` declaration in outer scope).
|
* Bugfix: Possible incorrect value of `ERRORS` after a `BigNumber.another` call (due to `parseNumeric` declaration in outer scope).
|
||||||
|
|
||||||
#### 3.0.1
|
#### 3.0.1
|
||||||
* 23/11/2016
|
* 23/11/2016
|
||||||
* Apply fix for old ipads with `%` issue, see #57 and #102.
|
* Apply fix for old ipads with `%` issue, see #57 and #102.
|
||||||
* Correct error message.
|
* Correct error message.
|
||||||
|
|
||||||
#### 3.0.0
|
#### 3.0.0
|
||||||
* 09/11/2016
|
* 09/11/2016
|
||||||
* Remove `require('crypto')` - leave it to the user.
|
* Remove `require('crypto')` - leave it to the user.
|
||||||
* Add `BigNumber.set` as `BigNumber.config` alias.
|
* Add `BigNumber.set` as `BigNumber.config` alias.
|
||||||
* Default `POW_PRECISION` to `0`.
|
* Default `POW_PRECISION` to `0`.
|
||||||
|
|
||||||
#### 2.4.0
|
#### 2.4.0
|
||||||
* 14/07/2016
|
* 14/07/2016
|
||||||
* #97 Add exports to support ES6 imports.
|
* #97 Add exports to support ES6 imports.
|
||||||
|
|
||||||
#### 2.3.0
|
#### 2.3.0
|
||||||
* 07/03/2016
|
* 07/03/2016
|
||||||
* #86 Add modulus parameter to `toPower`.
|
* #86 Add modulus parameter to `toPower`.
|
||||||
|
|
||||||
#### 2.2.0
|
#### 2.2.0
|
||||||
* 03/03/2016
|
* 03/03/2016
|
||||||
* #91 Permit larger JS integers.
|
* #91 Permit larger JS integers.
|
||||||
|
|
||||||
#### 2.1.4
|
#### 2.1.4
|
||||||
* 15/12/2015
|
* 15/12/2015
|
||||||
* Correct UMD.
|
* Correct UMD.
|
||||||
|
|
||||||
#### 2.1.3
|
#### 2.1.3
|
||||||
* 13/12/2015
|
* 13/12/2015
|
||||||
* Refactor re global object and crypto availability when bundling.
|
* Refactor re global object and crypto availability when bundling.
|
||||||
|
|
||||||
#### 2.1.2
|
#### 2.1.2
|
||||||
* 10/12/2015
|
* 10/12/2015
|
||||||
* Bugfix: `window.crypto` not assigned to `crypto`.
|
* Bugfix: `window.crypto` not assigned to `crypto`.
|
||||||
|
|
||||||
#### 2.1.1
|
#### 2.1.1
|
||||||
* 09/12/2015
|
* 09/12/2015
|
||||||
* Prevent code bundler from adding `crypto` shim.
|
* Prevent code bundler from adding `crypto` shim.
|
||||||
|
|
||||||
#### 2.1.0
|
#### 2.1.0
|
||||||
* 26/10/2015
|
* 26/10/2015
|
||||||
* For `valueOf` and `toJSON`, include the minus sign with negative zero.
|
* For `valueOf` and `toJSON`, include the minus sign with negative zero.
|
||||||
|
|
||||||
#### 2.0.8
|
#### 2.0.8
|
||||||
* 2/10/2015
|
* 2/10/2015
|
||||||
* Internal round function bugfix.
|
* Internal round function bugfix.
|
||||||
|
|
||||||
#### 2.0.6
|
#### 2.0.6
|
||||||
* 31/03/2015
|
* 31/03/2015
|
||||||
* Add bower.json. Tweak division after in-depth review.
|
* Add bower.json. Tweak division after in-depth review.
|
||||||
|
|
||||||
#### 2.0.5
|
#### 2.0.5
|
||||||
* 25/03/2015
|
* 25/03/2015
|
||||||
* Amend README. Remove bitcoin address.
|
* Amend README. Remove bitcoin address.
|
||||||
|
|
||||||
#### 2.0.4
|
#### 2.0.4
|
||||||
* 25/03/2015
|
* 25/03/2015
|
||||||
* Critical bugfix #58: division.
|
* Critical bugfix #58: division.
|
||||||
|
|
||||||
#### 2.0.3
|
#### 2.0.3
|
||||||
* 18/02/2015
|
* 18/02/2015
|
||||||
* Amend README. Add source map.
|
* Amend README. Add source map.
|
||||||
|
|
||||||
#### 2.0.2
|
#### 2.0.2
|
||||||
* 18/02/2015
|
* 18/02/2015
|
||||||
* Correct links.
|
* Correct links.
|
||||||
|
|
||||||
#### 2.0.1
|
#### 2.0.1
|
||||||
* 18/02/2015
|
* 18/02/2015
|
||||||
* Add `max`, `min`, `precision`, `random`, `shiftedBy`, `toDigits` and `truncated` methods.
|
* Add `max`, `min`, `precision`, `random`, `shiftedBy`, `toDigits` and `truncated` methods.
|
||||||
* Add the short-forms: `add`, `mul`, `sd`, `sub` and `trunc`.
|
* Add the short-forms: `add`, `mul`, `sd`, `sub` and `trunc`.
|
||||||
* Add an `another` method to enable multiple independent constructors to be created.
|
* Add an `another` method to enable multiple independent constructors to be created.
|
||||||
* Add support for the base 2, 8 and 16 prefixes `0b`, `0o` and `0x`.
|
* Add support for the base 2, 8 and 16 prefixes `0b`, `0o` and `0x`.
|
||||||
* Enable a rounding mode to be specified as a second parameter to `toExponential`, `toFixed`, `toFormat` and `toPrecision`.
|
* Enable a rounding mode to be specified as a second parameter to `toExponential`, `toFixed`, `toFormat` and `toPrecision`.
|
||||||
* Add a `CRYPTO` configuration property so cryptographically-secure pseudo-random number generation can be specified.
|
* Add a `CRYPTO` configuration property so cryptographically-secure pseudo-random number generation can be specified.
|
||||||
* Add a `MODULO_MODE` configuration property to enable the rounding mode used by the `modulo` operation to be specified.
|
* Add a `MODULO_MODE` configuration property to enable the rounding mode used by the `modulo` operation to be specified.
|
||||||
* Add a `POW_PRECISION` configuration property to enable the number of significant digits calculated by the power operation to be limited.
|
* Add a `POW_PRECISION` configuration property to enable the number of significant digits calculated by the power operation to be limited.
|
||||||
* Improve code quality.
|
* Improve code quality.
|
||||||
* Improve documentation.
|
* Improve documentation.
|
||||||
|
|
||||||
#### 2.0.0
|
#### 2.0.0
|
||||||
* 29/12/2014
|
* 29/12/2014
|
||||||
* Add `dividedToIntegerBy`, `isInteger` and `toFormat` methods.
|
* Add `dividedToIntegerBy`, `isInteger` and `toFormat` methods.
|
||||||
* Remove the following short-forms: `isF`, `isZ`, `toE`, `toF`, `toFr`, `toN`, `toP`, `toS`.
|
* Remove the following short-forms: `isF`, `isZ`, `toE`, `toF`, `toFr`, `toN`, `toP`, `toS`.
|
||||||
* Store a BigNumber's coefficient in base 1e14, rather than base 10.
|
* Store a BigNumber's coefficient in base 1e14, rather than base 10.
|
||||||
* Add fast path for integers to BigNumber constructor.
|
* Add fast path for integers to BigNumber constructor.
|
||||||
* Incorporate the library into the online documentation.
|
* Incorporate the library into the online documentation.
|
||||||
|
|
||||||
#### 1.5.0
|
#### 1.5.0
|
||||||
* 13/11/2014
|
* 13/11/2014
|
||||||
* Add `toJSON` and `decimalPlaces` methods.
|
* Add `toJSON` and `decimalPlaces` methods.
|
||||||
|
|
||||||
#### 1.4.1
|
#### 1.4.1
|
||||||
* 08/06/2014
|
* 08/06/2014
|
||||||
* Amend README.
|
* Amend README.
|
||||||
|
|
||||||
#### 1.4.0
|
#### 1.4.0
|
||||||
* 08/05/2014
|
* 08/05/2014
|
||||||
* Add `toNumber`.
|
* Add `toNumber`.
|
||||||
|
|
||||||
#### 1.3.0
|
#### 1.3.0
|
||||||
* 08/11/2013
|
* 08/11/2013
|
||||||
* Ensure correct rounding of `sqrt` in all, rather than almost all, cases.
|
* Ensure correct rounding of `sqrt` in all, rather than almost all, cases.
|
||||||
* Maximum radix to 64.
|
* Maximum radix to 64.
|
||||||
|
|
||||||
#### 1.2.1
|
#### 1.2.1
|
||||||
* 17/10/2013
|
* 17/10/2013
|
||||||
* Sign of zero when x < 0 and x + (-x) = 0.
|
* Sign of zero when x < 0 and x + (-x) = 0.
|
||||||
|
|
||||||
#### 1.2.0
|
#### 1.2.0
|
||||||
* 19/9/2013
|
* 19/9/2013
|
||||||
* Throw Error objects for stack.
|
* Throw Error objects for stack.
|
||||||
|
|
||||||
#### 1.1.1
|
#### 1.1.1
|
||||||
* 22/8/2013
|
* 22/8/2013
|
||||||
* Show original value in constructor error message.
|
* Show original value in constructor error message.
|
||||||
|
|
||||||
#### 1.1.0
|
#### 1.1.0
|
||||||
* 1/8/2013
|
* 1/8/2013
|
||||||
* Allow numbers with trailing radix point.
|
* Allow numbers with trailing radix point.
|
||||||
|
|
||||||
#### 1.0.1
|
#### 1.0.1
|
||||||
* Bugfix: error messages with incorrect method name
|
* Bugfix: error messages with incorrect method name
|
||||||
|
|
||||||
#### 1.0.0
|
#### 1.0.0
|
||||||
* 8/11/2012
|
* 8/11/2012
|
||||||
* Initial release
|
* Initial release
|
||||||
|
|||||||
46
node_modules/bignumber.js/LICENCE
generated
vendored
46
node_modules/bignumber.js/LICENCE
generated
vendored
@ -1,23 +1,23 @@
|
|||||||
The MIT Licence.
|
The MIT Licence.
|
||||||
|
|
||||||
Copyright (c) 2019 Michael Mclaughlin
|
Copyright (c) 2019 Michael Mclaughlin
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
a copy of this software and associated documentation files (the
|
a copy of this software and associated documentation files (the
|
||||||
'Software'), to deal in the Software without restriction, including
|
'Software'), to deal in the Software without restriction, including
|
||||||
without limitation the rights to use, copy, modify, merge, publish,
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
distribute, sublicense, and/or sell copies of the Software, and to
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
permit persons to whom the Software is furnished to do so, subject to
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
the following conditions:
|
the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be
|
The above copyright notice and this permission notice shall be
|
||||||
included in all copies or substantial portions of the Software.
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
|||||||
536
node_modules/bignumber.js/README.md
generated
vendored
536
node_modules/bignumber.js/README.md
generated
vendored
@ -1,268 +1,268 @@
|
|||||||

|

|
||||||
|
|
||||||
A JavaScript library for arbitrary-precision decimal and non-decimal arithmetic.
|
A JavaScript library for arbitrary-precision decimal and non-decimal arithmetic.
|
||||||
|
|
||||||
[](https://travis-ci.org/MikeMcl/bignumber.js)
|
[](https://travis-ci.org/MikeMcl/bignumber.js)
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- Integers and decimals
|
- Integers and decimals
|
||||||
- Simple API but full-featured
|
- Simple API but full-featured
|
||||||
- Faster, smaller, and perhaps easier to use than JavaScript versions of Java's BigDecimal
|
- Faster, smaller, and perhaps easier to use than JavaScript versions of Java's BigDecimal
|
||||||
- 8 KB minified and gzipped
|
- 8 KB minified and gzipped
|
||||||
- Replicates the `toExponential`, `toFixed`, `toPrecision` and `toString` methods of JavaScript's Number type
|
- Replicates the `toExponential`, `toFixed`, `toPrecision` and `toString` methods of JavaScript's Number type
|
||||||
- Includes a `toFraction` and a correctly-rounded `squareRoot` method
|
- Includes a `toFraction` and a correctly-rounded `squareRoot` method
|
||||||
- Supports cryptographically-secure pseudo-random number generation
|
- Supports cryptographically-secure pseudo-random number generation
|
||||||
- No dependencies
|
- No dependencies
|
||||||
- Wide platform compatibility: uses JavaScript 1.5 (ECMAScript 3) features only
|
- Wide platform compatibility: uses JavaScript 1.5 (ECMAScript 3) features only
|
||||||
- Comprehensive [documentation](http://mikemcl.github.io/bignumber.js/) and test set
|
- Comprehensive [documentation](http://mikemcl.github.io/bignumber.js/) and test set
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
If a smaller and simpler library is required see [big.js](https://github.com/MikeMcl/big.js/).
|
If a smaller and simpler library is required see [big.js](https://github.com/MikeMcl/big.js/).
|
||||||
It's less than half the size but only works with decimal numbers and only has half the methods.
|
It's less than half the size but only works with decimal numbers and only has half the methods.
|
||||||
It also does not allow `NaN` or `Infinity`, or have the configuration options of this library.
|
It also does not allow `NaN` or `Infinity`, or have the configuration options of this library.
|
||||||
|
|
||||||
See also [decimal.js](https://github.com/MikeMcl/decimal.js/), which among other things adds support for non-integer powers, and performs all operations to a specified number of significant digits.
|
See also [decimal.js](https://github.com/MikeMcl/decimal.js/), which among other things adds support for non-integer powers, and performs all operations to a specified number of significant digits.
|
||||||
|
|
||||||
## Load
|
## Load
|
||||||
|
|
||||||
The library is the single JavaScript file *bignumber.js* (or minified, *bignumber.min.js*).
|
The library is the single JavaScript file *bignumber.js* (or minified, *bignumber.min.js*).
|
||||||
|
|
||||||
Browser:
|
Browser:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<script src='path/to/bignumber.js'></script>
|
<script src='path/to/bignumber.js'></script>
|
||||||
```
|
```
|
||||||
|
|
||||||
[Node.js](http://nodejs.org):
|
[Node.js](http://nodejs.org):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ npm install bignumber.js
|
$ npm install bignumber.js
|
||||||
```
|
```
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const BigNumber = require('bignumber.js');
|
const BigNumber = require('bignumber.js');
|
||||||
```
|
```
|
||||||
|
|
||||||
ES6 module:
|
ES6 module:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
import BigNumber from "./bignumber.mjs"
|
import BigNumber from "./bignumber.mjs"
|
||||||
```
|
```
|
||||||
|
|
||||||
AMD loader libraries such as [requireJS](http://requirejs.org/):
|
AMD loader libraries such as [requireJS](http://requirejs.org/):
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
require(['bignumber'], function(BigNumber) {
|
require(['bignumber'], function(BigNumber) {
|
||||||
// Use BigNumber here in local scope. No global BigNumber.
|
// Use BigNumber here in local scope. No global BigNumber.
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
## Use
|
## Use
|
||||||
|
|
||||||
The library exports a single constructor function, [`BigNumber`](http://mikemcl.github.io/bignumber.js/#bignumber), which accepts a value of type Number, String or BigNumber,
|
The library exports a single constructor function, [`BigNumber`](http://mikemcl.github.io/bignumber.js/#bignumber), which accepts a value of type Number, String or BigNumber,
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
let x = new BigNumber(123.4567);
|
let x = new BigNumber(123.4567);
|
||||||
let y = BigNumber('123456.7e-3');
|
let y = BigNumber('123456.7e-3');
|
||||||
let z = new BigNumber(x);
|
let z = new BigNumber(x);
|
||||||
x.isEqualTo(y) && y.isEqualTo(z) && x.isEqualTo(z); // true
|
x.isEqualTo(y) && y.isEqualTo(z) && x.isEqualTo(z); // true
|
||||||
```
|
```
|
||||||
|
|
||||||
To get the string value of a BigNumber use [`toString()`](http://mikemcl.github.io/bignumber.js/#toS) or [`toFixed()`](http://mikemcl.github.io/bignumber.js/#toFix). Using `toFixed()` prevents exponential notation being returned, no matter how large or small the value.
|
To get the string value of a BigNumber use [`toString()`](http://mikemcl.github.io/bignumber.js/#toS) or [`toFixed()`](http://mikemcl.github.io/bignumber.js/#toFix). Using `toFixed()` prevents exponential notation being returned, no matter how large or small the value.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
let x = new BigNumber('1111222233334444555566');
|
let x = new BigNumber('1111222233334444555566');
|
||||||
x.toString(); // "1.111222233334444555566e+21"
|
x.toString(); // "1.111222233334444555566e+21"
|
||||||
x.toFixed(); // "1111222233334444555566"
|
x.toFixed(); // "1111222233334444555566"
|
||||||
```
|
```
|
||||||
|
|
||||||
If the limited precision of Number values is not well understood, it is recommended to create BigNumbers from String values rather than Number values to avoid a potential loss of precision.
|
If the limited precision of Number values is not well understood, it is recommended to create BigNumbers from String values rather than Number values to avoid a potential loss of precision.
|
||||||
|
|
||||||
*In all further examples below, `let`, semicolons and `toString` calls are not shown. If a commented-out value is in quotes it means `toString` has been called on the preceding expression.*
|
*In all further examples below, `let`, semicolons and `toString` calls are not shown. If a commented-out value is in quotes it means `toString` has been called on the preceding expression.*
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
// Precision loss from using numeric literals with more than 15 significant digits.
|
// Precision loss from using numeric literals with more than 15 significant digits.
|
||||||
new BigNumber(1.0000000000000001) // '1'
|
new BigNumber(1.0000000000000001) // '1'
|
||||||
new BigNumber(88259496234518.57) // '88259496234518.56'
|
new BigNumber(88259496234518.57) // '88259496234518.56'
|
||||||
new BigNumber(99999999999999999999) // '100000000000000000000'
|
new BigNumber(99999999999999999999) // '100000000000000000000'
|
||||||
|
|
||||||
// Precision loss from using numeric literals outside the range of Number values.
|
// Precision loss from using numeric literals outside the range of Number values.
|
||||||
new BigNumber(2e+308) // 'Infinity'
|
new BigNumber(2e+308) // 'Infinity'
|
||||||
new BigNumber(1e-324) // '0'
|
new BigNumber(1e-324) // '0'
|
||||||
|
|
||||||
// Precision loss from the unexpected result of arithmetic with Number values.
|
// Precision loss from the unexpected result of arithmetic with Number values.
|
||||||
new BigNumber(0.7 + 0.1) // '0.7999999999999999'
|
new BigNumber(0.7 + 0.1) // '0.7999999999999999'
|
||||||
```
|
```
|
||||||
|
|
||||||
When creating a BigNumber from a Number, note that a BigNumber is created from a Number's decimal `toString()` value not from its underlying binary value. If the latter is required, then pass the Number's `toString(2)` value and specify base 2.
|
When creating a BigNumber from a Number, note that a BigNumber is created from a Number's decimal `toString()` value not from its underlying binary value. If the latter is required, then pass the Number's `toString(2)` value and specify base 2.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
new BigNumber(Number.MAX_VALUE.toString(2), 2)
|
new BigNumber(Number.MAX_VALUE.toString(2), 2)
|
||||||
```
|
```
|
||||||
|
|
||||||
BigNumbers can be created from values in bases from 2 to 36. See [`ALPHABET`](http://mikemcl.github.io/bignumber.js/#alphabet) to extend this range.
|
BigNumbers can be created from values in bases from 2 to 36. See [`ALPHABET`](http://mikemcl.github.io/bignumber.js/#alphabet) to extend this range.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
a = new BigNumber(1011, 2) // "11"
|
a = new BigNumber(1011, 2) // "11"
|
||||||
b = new BigNumber('zz.9', 36) // "1295.25"
|
b = new BigNumber('zz.9', 36) // "1295.25"
|
||||||
c = a.plus(b) // "1306.25"
|
c = a.plus(b) // "1306.25"
|
||||||
```
|
```
|
||||||
|
|
||||||
Performance is better if base 10 is NOT specified for decimal values. Only specify base 10 when it is desired that the number of decimal places of the input value be limited to the current [`DECIMAL_PLACES`](http://mikemcl.github.io/bignumber.js/#decimal-places) setting.
|
Performance is better if base 10 is NOT specified for decimal values. Only specify base 10 when it is desired that the number of decimal places of the input value be limited to the current [`DECIMAL_PLACES`](http://mikemcl.github.io/bignumber.js/#decimal-places) setting.
|
||||||
|
|
||||||
A BigNumber is immutable in the sense that it is not changed by its methods.
|
A BigNumber is immutable in the sense that it is not changed by its methods.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
0.3 - 0.1 // 0.19999999999999998
|
0.3 - 0.1 // 0.19999999999999998
|
||||||
x = new BigNumber(0.3)
|
x = new BigNumber(0.3)
|
||||||
x.minus(0.1) // "0.2"
|
x.minus(0.1) // "0.2"
|
||||||
x // "0.3"
|
x // "0.3"
|
||||||
```
|
```
|
||||||
|
|
||||||
The methods that return a BigNumber can be chained.
|
The methods that return a BigNumber can be chained.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
x.dividedBy(y).plus(z).times(9)
|
x.dividedBy(y).plus(z).times(9)
|
||||||
x.times('1.23456780123456789e+9').plus(9876.5432321).dividedBy('4444562598.111772').integerValue()
|
x.times('1.23456780123456789e+9').plus(9876.5432321).dividedBy('4444562598.111772').integerValue()
|
||||||
```
|
```
|
||||||
|
|
||||||
Some of the longer method names have a shorter alias.
|
Some of the longer method names have a shorter alias.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
x.squareRoot().dividedBy(y).exponentiatedBy(3).isEqualTo(x.sqrt().div(y).pow(3)) // true
|
x.squareRoot().dividedBy(y).exponentiatedBy(3).isEqualTo(x.sqrt().div(y).pow(3)) // true
|
||||||
x.modulo(y).multipliedBy(z).eq(x.mod(y).times(z)) // true
|
x.modulo(y).multipliedBy(z).eq(x.mod(y).times(z)) // true
|
||||||
```
|
```
|
||||||
|
|
||||||
As with JavaScript's Number type, there are [`toExponential`](http://mikemcl.github.io/bignumber.js/#toE), [`toFixed`](http://mikemcl.github.io/bignumber.js/#toFix) and [`toPrecision`](http://mikemcl.github.io/bignumber.js/#toP) methods.
|
As with JavaScript's Number type, there are [`toExponential`](http://mikemcl.github.io/bignumber.js/#toE), [`toFixed`](http://mikemcl.github.io/bignumber.js/#toFix) and [`toPrecision`](http://mikemcl.github.io/bignumber.js/#toP) methods.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
x = new BigNumber(255.5)
|
x = new BigNumber(255.5)
|
||||||
x.toExponential(5) // "2.55500e+2"
|
x.toExponential(5) // "2.55500e+2"
|
||||||
x.toFixed(5) // "255.50000"
|
x.toFixed(5) // "255.50000"
|
||||||
x.toPrecision(5) // "255.50"
|
x.toPrecision(5) // "255.50"
|
||||||
x.toNumber() // 255.5
|
x.toNumber() // 255.5
|
||||||
```
|
```
|
||||||
|
|
||||||
A base can be specified for [`toString`](http://mikemcl.github.io/bignumber.js/#toS). Performance is better if base 10 is NOT specified, i.e. use `toString()` not `toString(10)`. Only specify base 10 when it is desired that the number of decimal places be limited to the current [`DECIMAL_PLACES`](http://mikemcl.github.io/bignumber.js/#decimal-places) setting.
|
A base can be specified for [`toString`](http://mikemcl.github.io/bignumber.js/#toS). Performance is better if base 10 is NOT specified, i.e. use `toString()` not `toString(10)`. Only specify base 10 when it is desired that the number of decimal places be limited to the current [`DECIMAL_PLACES`](http://mikemcl.github.io/bignumber.js/#decimal-places) setting.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
x.toString(16) // "ff.8"
|
x.toString(16) // "ff.8"
|
||||||
```
|
```
|
||||||
|
|
||||||
There is a [`toFormat`](http://mikemcl.github.io/bignumber.js/#toFor) method which may be useful for internationalisation.
|
There is a [`toFormat`](http://mikemcl.github.io/bignumber.js/#toFor) method which may be useful for internationalisation.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
y = new BigNumber('1234567.898765')
|
y = new BigNumber('1234567.898765')
|
||||||
y.toFormat(2) // "1,234,567.90"
|
y.toFormat(2) // "1,234,567.90"
|
||||||
```
|
```
|
||||||
|
|
||||||
The maximum number of decimal places of the result of an operation involving division (i.e. a division, square root, base conversion or negative power operation) is set using the `set` or `config` method of the `BigNumber` constructor.
|
The maximum number of decimal places of the result of an operation involving division (i.e. a division, square root, base conversion or negative power operation) is set using the `set` or `config` method of the `BigNumber` constructor.
|
||||||
|
|
||||||
The other arithmetic operations always give the exact result.
|
The other arithmetic operations always give the exact result.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
BigNumber.set({ DECIMAL_PLACES: 10, ROUNDING_MODE: 4 })
|
BigNumber.set({ DECIMAL_PLACES: 10, ROUNDING_MODE: 4 })
|
||||||
|
|
||||||
x = new BigNumber(2)
|
x = new BigNumber(2)
|
||||||
y = new BigNumber(3)
|
y = new BigNumber(3)
|
||||||
z = x.dividedBy(y) // "0.6666666667"
|
z = x.dividedBy(y) // "0.6666666667"
|
||||||
z.squareRoot() // "0.8164965809"
|
z.squareRoot() // "0.8164965809"
|
||||||
z.exponentiatedBy(-3) // "3.3749999995"
|
z.exponentiatedBy(-3) // "3.3749999995"
|
||||||
z.toString(2) // "0.1010101011"
|
z.toString(2) // "0.1010101011"
|
||||||
z.multipliedBy(z) // "0.44444444448888888889"
|
z.multipliedBy(z) // "0.44444444448888888889"
|
||||||
z.multipliedBy(z).decimalPlaces(10) // "0.4444444445"
|
z.multipliedBy(z).decimalPlaces(10) // "0.4444444445"
|
||||||
```
|
```
|
||||||
|
|
||||||
There is a [`toFraction`](http://mikemcl.github.io/bignumber.js/#toFr) method with an optional *maximum denominator* argument
|
There is a [`toFraction`](http://mikemcl.github.io/bignumber.js/#toFr) method with an optional *maximum denominator* argument
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
y = new BigNumber(355)
|
y = new BigNumber(355)
|
||||||
pi = y.dividedBy(113) // "3.1415929204"
|
pi = y.dividedBy(113) // "3.1415929204"
|
||||||
pi.toFraction() // [ "7853982301", "2500000000" ]
|
pi.toFraction() // [ "7853982301", "2500000000" ]
|
||||||
pi.toFraction(1000) // [ "355", "113" ]
|
pi.toFraction(1000) // [ "355", "113" ]
|
||||||
```
|
```
|
||||||
|
|
||||||
and [`isNaN`](http://mikemcl.github.io/bignumber.js/#isNaN) and [`isFinite`](http://mikemcl.github.io/bignumber.js/#isF) methods, as `NaN` and `Infinity` are valid `BigNumber` values.
|
and [`isNaN`](http://mikemcl.github.io/bignumber.js/#isNaN) and [`isFinite`](http://mikemcl.github.io/bignumber.js/#isF) methods, as `NaN` and `Infinity` are valid `BigNumber` values.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
x = new BigNumber(NaN) // "NaN"
|
x = new BigNumber(NaN) // "NaN"
|
||||||
y = new BigNumber(Infinity) // "Infinity"
|
y = new BigNumber(Infinity) // "Infinity"
|
||||||
x.isNaN() && !y.isNaN() && !x.isFinite() && !y.isFinite() // true
|
x.isNaN() && !y.isNaN() && !x.isFinite() && !y.isFinite() // true
|
||||||
```
|
```
|
||||||
|
|
||||||
The value of a BigNumber is stored in a decimal floating point format in terms of a coefficient, exponent and sign.
|
The value of a BigNumber is stored in a decimal floating point format in terms of a coefficient, exponent and sign.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
x = new BigNumber(-123.456);
|
x = new BigNumber(-123.456);
|
||||||
x.c // [ 123, 45600000000000 ] coefficient (i.e. significand)
|
x.c // [ 123, 45600000000000 ] coefficient (i.e. significand)
|
||||||
x.e // 2 exponent
|
x.e // 2 exponent
|
||||||
x.s // -1 sign
|
x.s // -1 sign
|
||||||
```
|
```
|
||||||
|
|
||||||
For advanced usage, multiple BigNumber constructors can be created, each with their own independent configuration.
|
For advanced usage, multiple BigNumber constructors can be created, each with their own independent configuration.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
// Set DECIMAL_PLACES for the original BigNumber constructor
|
// Set DECIMAL_PLACES for the original BigNumber constructor
|
||||||
BigNumber.set({ DECIMAL_PLACES: 10 })
|
BigNumber.set({ DECIMAL_PLACES: 10 })
|
||||||
|
|
||||||
// Create another BigNumber constructor, optionally passing in a configuration object
|
// Create another BigNumber constructor, optionally passing in a configuration object
|
||||||
BN = BigNumber.clone({ DECIMAL_PLACES: 5 })
|
BN = BigNumber.clone({ DECIMAL_PLACES: 5 })
|
||||||
|
|
||||||
x = new BigNumber(1)
|
x = new BigNumber(1)
|
||||||
y = new BN(1)
|
y = new BN(1)
|
||||||
|
|
||||||
x.div(3) // '0.3333333333'
|
x.div(3) // '0.3333333333'
|
||||||
y.div(3) // '0.33333'
|
y.div(3) // '0.33333'
|
||||||
```
|
```
|
||||||
|
|
||||||
For further information see the [API](http://mikemcl.github.io/bignumber.js/) reference in the *doc* directory.
|
For further information see the [API](http://mikemcl.github.io/bignumber.js/) reference in the *doc* directory.
|
||||||
|
|
||||||
## Test
|
## Test
|
||||||
|
|
||||||
The *test/modules* directory contains the test scripts for each method.
|
The *test/modules* directory contains the test scripts for each method.
|
||||||
|
|
||||||
The tests can be run with Node.js or a browser. For Node.js use
|
The tests can be run with Node.js or a browser. For Node.js use
|
||||||
|
|
||||||
$ npm test
|
$ npm test
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
$ node test/test
|
$ node test/test
|
||||||
|
|
||||||
To test a single method, use, for example
|
To test a single method, use, for example
|
||||||
|
|
||||||
$ node test/methods/toFraction
|
$ node test/methods/toFraction
|
||||||
|
|
||||||
For the browser, open *test/test.html*.
|
For the browser, open *test/test.html*.
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
For Node, if [uglify-js](https://github.com/mishoo/UglifyJS2) is installed
|
For Node, if [uglify-js](https://github.com/mishoo/UglifyJS2) is installed
|
||||||
|
|
||||||
npm install uglify-js -g
|
npm install uglify-js -g
|
||||||
|
|
||||||
then
|
then
|
||||||
|
|
||||||
npm run build
|
npm run build
|
||||||
|
|
||||||
will create *bignumber.min.js*.
|
will create *bignumber.min.js*.
|
||||||
|
|
||||||
A source map will also be created in the root directory.
|
A source map will also be created in the root directory.
|
||||||
|
|
||||||
## Feedback
|
## Feedback
|
||||||
|
|
||||||
Open an issue, or email
|
Open an issue, or email
|
||||||
|
|
||||||
Michael
|
Michael
|
||||||
|
|
||||||
<a href="mailto:M8ch88l@gmail.com">M8ch88l@gmail.com</a>
|
<a href="mailto:M8ch88l@gmail.com">M8ch88l@gmail.com</a>
|
||||||
|
|
||||||
## Licence
|
## Licence
|
||||||
|
|
||||||
The MIT Licence.
|
The MIT Licence.
|
||||||
|
|
||||||
See [LICENCE](https://github.com/MikeMcl/bignumber.js/blob/master/LICENCE).
|
See [LICENCE](https://github.com/MikeMcl/bignumber.js/blob/master/LICENCE).
|
||||||
|
|||||||
3658
node_modules/bignumber.js/bignumber.d.ts
generated
vendored
3658
node_modules/bignumber.js/bignumber.d.ts
generated
vendored
File diff suppressed because it is too large
Load Diff
5804
node_modules/bignumber.js/bignumber.js
generated
vendored
5804
node_modules/bignumber.js/bignumber.js
generated
vendored
File diff suppressed because it is too large
Load Diff
5776
node_modules/bignumber.js/bignumber.mjs
generated
vendored
5776
node_modules/bignumber.js/bignumber.mjs
generated
vendored
File diff suppressed because it is too large
Load Diff
4474
node_modules/bignumber.js/doc/API.html
generated
vendored
4474
node_modules/bignumber.js/doc/API.html
generated
vendored
File diff suppressed because it is too large
Load Diff
80
node_modules/bignumber.js/package.json
generated
vendored
80
node_modules/bignumber.js/package.json
generated
vendored
@ -1,40 +1,40 @@
|
|||||||
{
|
{
|
||||||
"name": "bignumber.js",
|
"name": "bignumber.js",
|
||||||
"description": "A library for arbitrary-precision decimal and non-decimal arithmetic",
|
"description": "A library for arbitrary-precision decimal and non-decimal arithmetic",
|
||||||
"version": "9.0.0",
|
"version": "9.0.0",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"arbitrary",
|
"arbitrary",
|
||||||
"precision",
|
"precision",
|
||||||
"arithmetic",
|
"arithmetic",
|
||||||
"big",
|
"big",
|
||||||
"number",
|
"number",
|
||||||
"decimal",
|
"decimal",
|
||||||
"float",
|
"float",
|
||||||
"biginteger",
|
"biginteger",
|
||||||
"bigdecimal",
|
"bigdecimal",
|
||||||
"bignumber",
|
"bignumber",
|
||||||
"bigint",
|
"bigint",
|
||||||
"bignum"
|
"bignum"
|
||||||
],
|
],
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/MikeMcl/bignumber.js.git"
|
"url": "https://github.com/MikeMcl/bignumber.js.git"
|
||||||
},
|
},
|
||||||
"main": "bignumber",
|
"main": "bignumber",
|
||||||
"module": "bignumber.mjs",
|
"module": "bignumber.mjs",
|
||||||
"browser": "bignumber.js",
|
"browser": "bignumber.js",
|
||||||
"types": "bignumber.d.ts",
|
"types": "bignumber.d.ts",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Michael Mclaughlin",
|
"name": "Michael Mclaughlin",
|
||||||
"email": "M8ch88l@gmail.com"
|
"email": "M8ch88l@gmail.com"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "*"
|
"node": "*"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "node test/test",
|
"test": "node test/test",
|
||||||
"build": "uglifyjs bignumber.js --source-map -c -m -o bignumber.min.js"
|
"build": "uglifyjs bignumber.js --source-map -c -m -o bignumber.min.js"
|
||||||
},
|
},
|
||||||
"dependencies": {}
|
"dependencies": {}
|
||||||
}
|
}
|
||||||
|
|||||||
6
node_modules/concat-stream/package.json
generated
vendored
6
node_modules/concat-stream/package.json
generated
vendored
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "concat-stream",
|
"name": "concat-stream",
|
||||||
"version": "1.6.2",
|
"version": "2.0.0",
|
||||||
"description": "writable stream that concatenates strings or binary data and calls a callback with the result",
|
"description": "writable stream that concatenates strings or binary data and calls a callback with the result",
|
||||||
"tags": [
|
"tags": [
|
||||||
"stream",
|
"stream",
|
||||||
@ -17,7 +17,7 @@
|
|||||||
"url": "http://github.com/maxogden/concat-stream/issues"
|
"url": "http://github.com/maxogden/concat-stream/issues"
|
||||||
},
|
},
|
||||||
"engines": [
|
"engines": [
|
||||||
"node >= 0.8"
|
"node >= 6.0"
|
||||||
],
|
],
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"files": [
|
"files": [
|
||||||
@ -30,7 +30,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"buffer-from": "^1.0.0",
|
"buffer-from": "^1.0.0",
|
||||||
"inherits": "^2.0.3",
|
"inherits": "^2.0.3",
|
||||||
"readable-stream": "^2.2.2",
|
"readable-stream": "^3.0.2",
|
||||||
"typedarray": "^0.0.6"
|
"typedarray": "^0.0.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
55
node_modules/multer/README.md
generated
vendored
55
node_modules/multer/README.md
generated
vendored
@ -1,25 +1,30 @@
|
|||||||
# Multer [](https://github.com/expressjs/multer/actions/workflows/ci.yml) [](https://coveralls.io/r/expressjs/multer?branch=master) [](https://badge.fury.io/js/multer) [](https://github.com/feross/standard)
|
# Multer [![NPM Version][npm-version-image]][npm-url] [![NPM Downloads][npm-downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Test Coverage][test-image]][test-url] [![OpenSSF Scorecard Badge][ossf-scorecard-badge]][ossf-scorecard-visualizer]
|
||||||
|
|
||||||
Multer is a node.js middleware for handling `multipart/form-data`, which is primarily used for uploading files. It is written
|
Multer is a node.js middleware for handling `multipart/form-data`, which is primarily used for uploading files. It is written
|
||||||
on top of [busboy](https://github.com/mscdex/busboy) for maximum efficiency.
|
on top of [busboy](https://github.com/mscdex/busboy) for maximum efficiency.
|
||||||
|
|
||||||
**NOTE**: Multer will not process any form which is not multipart (`multipart/form-data`).
|
**NOTE**: Multer will not process any form which is not multipart (`multipart/form-data`).
|
||||||
|
|
||||||
## Translations
|
## Translations
|
||||||
|
|
||||||
This README is also available in other languages:
|
This README is also available in other languages:
|
||||||
|
|
||||||
- [Español](https://github.com/expressjs/multer/blob/master/doc/README-es.md) (Spanish)
|
| | |
|
||||||
- [简体中文](https://github.com/expressjs/multer/blob/master/doc/README-zh-cn.md) (Chinese)
|
| ------------------------------------------------------------------------------ | --------------- |
|
||||||
- [한국어](https://github.com/expressjs/multer/blob/master/doc/README-ko.md) (Korean)
|
| [العربية](https://github.com/expressjs/multer/blob/main/doc/README-ar.md) | Arabic |
|
||||||
- [Русский язык](https://github.com/expressjs/multer/blob/master/doc/README-ru.md) (Russian)
|
| [简体中文](https://github.com/expressjs/multer/blob/main/doc/README-zh-cn.md) | Chinese |
|
||||||
- [Việt Nam](https://github.com/expressjs/multer/blob/master/doc/README-vi.md) (Vietnam)
|
| [Français](https://github.com/expressjs/multer/blob/main/doc/README-fr.md) | French |
|
||||||
- [Português](https://github.com/expressjs/multer/blob/master/doc/README-pt-br.md) (Portuguese Brazil)
|
| [한국어](https://github.com/expressjs/multer/blob/main/doc/README-ko.md) | Korean |
|
||||||
|
| [Português](https://github.com/expressjs/multer/blob/main/doc/README-pt-br.md) | Portuguese (BR) |
|
||||||
|
| [Русский язык](https://github.com/expressjs/multer/blob/main/doc/README-ru.md) | Russian |
|
||||||
|
| [Español](https://github.com/expressjs/multer/blob/main/doc/README-es.md) | Spanish |
|
||||||
|
| [O'zbek tili](https://github.com/expressjs/multer/blob/main/doc/README-uz.md) | Uzbek |
|
||||||
|
| [Việt Nam](https://github.com/expressjs/multer/blob/main/doc/README-vi.md) | Vietnamese |
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ npm install --save multer
|
$ npm install multer
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
@ -53,8 +58,8 @@ app.post('/photos/upload', upload.array('photos', 12), function (req, res, next)
|
|||||||
// req.body will contain the text fields, if there were any
|
// req.body will contain the text fields, if there were any
|
||||||
})
|
})
|
||||||
|
|
||||||
const cpUpload = upload.fields([{ name: 'avatar', maxCount: 1 }, { name: 'gallery', maxCount: 8 }])
|
const uploadMiddleware = upload.fields([{ name: 'avatar', maxCount: 1 }, { name: 'gallery', maxCount: 8 }])
|
||||||
app.post('/cool-profile', cpUpload, function (req, res, next) {
|
app.post('/cool-profile', uploadMiddleware, function (req, res, next) {
|
||||||
// req.files is an object (String -> Array) where fieldname is the key, and the value is array of files
|
// req.files is an object (String -> Array) where fieldname is the key, and the value is array of files
|
||||||
//
|
//
|
||||||
// e.g.
|
// e.g.
|
||||||
@ -78,14 +83,14 @@ app.post('/profile', upload.none(), function (req, res, next) {
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
Here's an example on how multer is used an HTML form. Take special note of the `enctype="multipart/form-data"` and `name="uploaded_file"` fields:
|
Here's an example on how multer is used in a HTML form. Take special note of the `enctype="multipart/form-data"` and `name="uploaded_file"` fields:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<form action="/stats" enctype="multipart/form-data" method="post">
|
<form action="/stats" enctype="multipart/form-data" method="post">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="file" class="form-control-file" name="uploaded_file">
|
<input type="file" class="form-control-file" name="uploaded_file">
|
||||||
<input type="text" class="form-control" placeholder="Number of speakers" name="nspeakers">
|
<input type="text" class="form-control" placeholder="Number of speakers" name="nspeakers">
|
||||||
<input type="submit" value="Get me the stats!" class="btn btn-default">
|
<input type="submit" value="Get me the stats!" class="btn btn-default">
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
```
|
```
|
||||||
@ -96,9 +101,9 @@ Then in your javascript file you would add these lines to access both the file a
|
|||||||
const multer = require('multer')
|
const multer = require('multer')
|
||||||
const upload = multer({ dest: './public/data/uploads/' })
|
const upload = multer({ dest: './public/data/uploads/' })
|
||||||
app.post('/stats', upload.single('uploaded_file'), function (req, res) {
|
app.post('/stats', upload.single('uploaded_file'), function (req, res) {
|
||||||
// req.file is the name of your file in the form above, here 'uploaded_file'
|
// req.file is the name of your file in the form above, here 'uploaded_file'
|
||||||
// req.body will hold the text fields, if there were any
|
// req.body will hold the text fields, if there were any
|
||||||
console.log(req.file, req.body)
|
console.log(req.file, req.body)
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -229,7 +234,7 @@ If no `filename` is given, each file will be given a random name that doesn't
|
|||||||
include any file extension.
|
include any file extension.
|
||||||
|
|
||||||
**Note:** Multer will not append any file extension for you, your function
|
**Note:** Multer will not append any file extension for you, your function
|
||||||
should return a filename complete with an file extension.
|
should return a filename complete with a file extension.
|
||||||
|
|
||||||
Each function gets passed both the request (`req`) and some information about
|
Each function gets passed both the request (`req`) and some information about
|
||||||
the file (`file`) to aid with the decision.
|
the file (`file`) to aid with the decision.
|
||||||
@ -239,7 +244,7 @@ order that the client transmits fields and files to the server.
|
|||||||
|
|
||||||
For understanding the calling convention used in the callback (needing to pass
|
For understanding the calling convention used in the callback (needing to pass
|
||||||
null as the first param), refer to
|
null as the first param), refer to
|
||||||
[Node.js error handling](https://www.joyent.com/node-js/production/design/errors)
|
[Node.js error handling](https://web.archive.org/web/20220417042018/https://www.joyent.com/node-js/production/design/errors)
|
||||||
|
|
||||||
#### `MemoryStorage`
|
#### `MemoryStorage`
|
||||||
|
|
||||||
@ -305,7 +310,7 @@ When encountering an error, Multer will delegate the error to Express. You can
|
|||||||
display a nice error page using [the standard express way](http://expressjs.com/guide/error-handling.html).
|
display a nice error page using [the standard express way](http://expressjs.com/guide/error-handling.html).
|
||||||
|
|
||||||
If you want to catch errors specifically from Multer, you can call the
|
If you want to catch errors specifically from Multer, you can call the
|
||||||
middleware function by yourself. Also, if you want to catch only [the Multer errors](https://github.com/expressjs/multer/blob/master/lib/multer-error.js), you can use the `MulterError` class that is attached to the `multer` object itself (e.g. `err instanceof multer.MulterError`).
|
middleware function by yourself. Also, if you want to catch only [the Multer errors](https://github.com/expressjs/multer/blob/main/lib/multer-error.js), you can use the `MulterError` class that is attached to the `multer` object itself (e.g. `err instanceof multer.MulterError`).
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const multer = require('multer')
|
const multer = require('multer')
|
||||||
@ -326,8 +331,18 @@ app.post('/profile', function (req, res) {
|
|||||||
|
|
||||||
## Custom storage engine
|
## Custom storage engine
|
||||||
|
|
||||||
For information on how to build your own storage engine, see [Multer Storage Engine](https://github.com/expressjs/multer/blob/master/StorageEngine.md).
|
For information on how to build your own storage engine, see [Multer Storage Engine](https://github.com/expressjs/multer/blob/main/StorageEngine.md).
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
[MIT](LICENSE)
|
[MIT](LICENSE)
|
||||||
|
|
||||||
|
[ci-image]: https://github.com/expressjs/multer/actions/workflows/ci.yml/badge.svg
|
||||||
|
[ci-url]: https://github.com/expressjs/multer/actions/workflows/ci.yml
|
||||||
|
[test-url]: https://coveralls.io/r/expressjs/multer?branch=main
|
||||||
|
[test-image]: https://badgen.net/coveralls/c/github/expressjs/multer/main
|
||||||
|
[npm-downloads-image]: https://badgen.net/npm/dm/multer
|
||||||
|
[npm-url]: https://npmjs.org/package/multer
|
||||||
|
[npm-version-image]: https://badgen.net/npm/v/multer
|
||||||
|
[ossf-scorecard-badge]: https://api.scorecard.dev/projects/github.com/expressjs/multer/badge
|
||||||
|
[ossf-scorecard-visualizer]: https://ossf.github.io/scorecard-visualizer/#/projects/github.com/expressjs/multer
|
||||||
2
node_modules/multer/lib/make-middleware.js
generated
vendored
2
node_modules/multer/lib/make-middleware.js
generated
vendored
@ -101,6 +101,8 @@ function makeMiddleware (setup) {
|
|||||||
|
|
||||||
// handle files
|
// handle files
|
||||||
busboy.on('file', function (fieldname, fileStream, { filename, encoding, mimeType }) {
|
busboy.on('file', function (fieldname, fileStream, { filename, encoding, mimeType }) {
|
||||||
|
if (fieldname == null) return abortWithCode('MISSING_FIELD_NAME')
|
||||||
|
|
||||||
// don't attach to the files object, if there is no file
|
// don't attach to the files object, if there is no file
|
||||||
if (!filename) return fileStream.resume()
|
if (!filename) return fileStream.resume()
|
||||||
|
|
||||||
|
|||||||
21
node_modules/multer/package.json
generated
vendored
21
node_modules/multer/package.json
generated
vendored
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "multer",
|
"name": "multer",
|
||||||
"description": "Middleware for handling `multipart/form-data`.",
|
"description": "Middleware for handling `multipart/form-data`.",
|
||||||
"version": "2.0.0",
|
"version": "2.0.1",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
"Hage Yaapa <captain@hacksparrow.com> (http://www.hacksparrow.com)",
|
"Hage Yaapa <captain@hacksparrow.com> (http://www.hacksparrow.com)",
|
||||||
"Jaret Pfluger <https://github.com/jpfluger>",
|
"Jaret Pfluger <https://github.com/jpfluger>",
|
||||||
@ -20,19 +20,20 @@
|
|||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"append-field": "^1.0.0",
|
"append-field": "^1.0.0",
|
||||||
"busboy": "^1.0.0",
|
"busboy": "^1.6.0",
|
||||||
"concat-stream": "^1.5.2",
|
"concat-stream": "^2.0.0",
|
||||||
"mkdirp": "^0.5.4",
|
"mkdirp": "^0.5.6",
|
||||||
"object-assign": "^4.1.1",
|
"object-assign": "^4.1.1",
|
||||||
"type-is": "^1.6.4",
|
"type-is": "^1.6.18",
|
||||||
"xtend": "^4.0.0"
|
"xtend": "^4.0.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"deep-equal": "^2.0.3",
|
"deep-equal": "^2.0.3",
|
||||||
"express": "^4.13.1",
|
"express": "^4.21.2",
|
||||||
"form-data": "^1.0.0-rc1",
|
"form-data": "^4.0.2",
|
||||||
"fs-temp": "^1.1.2",
|
"fs-temp": "^1.2.1",
|
||||||
"mocha": "^11.3.0",
|
"mocha": "^11.5.0",
|
||||||
|
"nyc": "^15.1.0",
|
||||||
"rimraf": "^2.4.1",
|
"rimraf": "^2.4.1",
|
||||||
"standard": "^14.3.3",
|
"standard": "^14.3.3",
|
||||||
"testdata-w3c-json-form": "^1.0.0"
|
"testdata-w3c-json-form": "^1.0.0"
|
||||||
|
|||||||
0
node_modules/nodemon/bin/windows-kill.exe
generated
vendored
Normal file → Executable file
0
node_modules/nodemon/bin/windows-kill.exe
generated
vendored
Normal file → Executable file
34
node_modules/readable-stream/.travis.yml
generated
vendored
34
node_modules/readable-stream/.travis.yml
generated
vendored
@ -1,34 +0,0 @@
|
|||||||
sudo: false
|
|
||||||
language: node_js
|
|
||||||
before_install:
|
|
||||||
- (test $NPM_LEGACY && npm install -g npm@2 && npm install -g npm@3) || true
|
|
||||||
notifications:
|
|
||||||
email: false
|
|
||||||
matrix:
|
|
||||||
fast_finish: true
|
|
||||||
include:
|
|
||||||
- node_js: '0.8'
|
|
||||||
env: NPM_LEGACY=true
|
|
||||||
- node_js: '0.10'
|
|
||||||
env: NPM_LEGACY=true
|
|
||||||
- node_js: '0.11'
|
|
||||||
env: NPM_LEGACY=true
|
|
||||||
- node_js: '0.12'
|
|
||||||
env: NPM_LEGACY=true
|
|
||||||
- node_js: 1
|
|
||||||
env: NPM_LEGACY=true
|
|
||||||
- node_js: 2
|
|
||||||
env: NPM_LEGACY=true
|
|
||||||
- node_js: 3
|
|
||||||
env: NPM_LEGACY=true
|
|
||||||
- node_js: 4
|
|
||||||
- node_js: 5
|
|
||||||
- node_js: 6
|
|
||||||
- node_js: 7
|
|
||||||
- node_js: 8
|
|
||||||
- node_js: 9
|
|
||||||
script: "npm run test"
|
|
||||||
env:
|
|
||||||
global:
|
|
||||||
- secure: rE2Vvo7vnjabYNULNyLFxOyt98BoJexDqsiOnfiD6kLYYsiQGfr/sbZkPMOFm9qfQG7pjqx+zZWZjGSswhTt+626C0t/njXqug7Yps4c3dFblzGfreQHp7wNX5TFsvrxd6dAowVasMp61sJcRnB2w8cUzoe3RAYUDHyiHktwqMc=
|
|
||||||
- secure: g9YINaKAdMatsJ28G9jCGbSaguXCyxSTy+pBO6Ch0Cf57ZLOTka3HqDj8p3nV28LUIHZ3ut5WO43CeYKwt4AUtLpBS3a0dndHdY6D83uY6b2qh5hXlrcbeQTq2cvw2y95F7hm4D1kwrgZ7ViqaKggRcEupAL69YbJnxeUDKWEdI=
|
|
||||||
74
node_modules/readable-stream/README.md
generated
vendored
74
node_modules/readable-stream/README.md
generated
vendored
@ -1,30 +1,81 @@
|
|||||||
# readable-stream
|
# readable-stream
|
||||||
|
|
||||||
***Node-core v8.17.0 streams for userland*** [](https://travis-ci.org/nodejs/readable-stream)
|
***Node.js core streams for userland*** [](https://travis-ci.com/nodejs/readable-stream)
|
||||||
|
|
||||||
|
|
||||||
[](https://nodei.co/npm/readable-stream/)
|
[](https://nodei.co/npm/readable-stream/)
|
||||||
[](https://nodei.co/npm/readable-stream/)
|
[](https://nodei.co/npm/readable-stream/)
|
||||||
|
|
||||||
|
|
||||||
[](https://saucelabs.com/u/readable-stream)
|
[](https://saucelabs.com/u/readabe-stream)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install --save readable-stream
|
npm install --save readable-stream
|
||||||
```
|
```
|
||||||
|
|
||||||
***Node-core streams for userland***
|
This package is a mirror of the streams implementations in Node.js.
|
||||||
|
|
||||||
This package is a mirror of the Streams2 and Streams3 implementations in
|
Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v10.18.1/docs/api/stream.html).
|
||||||
Node-core.
|
|
||||||
|
|
||||||
Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v8.17.0/docs/api/stream.html).
|
|
||||||
|
|
||||||
If you want to guarantee a stable streams base, regardless of what version of
|
If you want to guarantee a stable streams base, regardless of what version of
|
||||||
Node you, or the users of your libraries are using, use **readable-stream** *only* and avoid the *"stream"* module in Node-core, for background see [this blogpost](http://r.va.gg/2014/06/why-i-dont-use-nodes-core-stream-module.html).
|
Node you, or the users of your libraries are using, use **readable-stream** *only* and avoid the *"stream"* module in Node-core, for background see [this blogpost](http://r.va.gg/2014/06/why-i-dont-use-nodes-core-stream-module.html).
|
||||||
|
|
||||||
As of version 2.0.0 **readable-stream** uses semantic versioning.
|
As of version 2.0.0 **readable-stream** uses semantic versioning.
|
||||||
|
|
||||||
|
## Version 3.x.x
|
||||||
|
|
||||||
|
v3.x.x of `readable-stream` is a cut from Node 10. This version supports Node 6, 8, and 10, as well as evergreen browsers, IE 11 and latest Safari. The breaking changes introduced by v3 are composed by the combined breaking changes in [Node v9](https://nodejs.org/en/blog/release/v9.0.0/) and [Node v10](https://nodejs.org/en/blog/release/v10.0.0/), as follows:
|
||||||
|
|
||||||
|
1. Error codes: https://github.com/nodejs/node/pull/13310,
|
||||||
|
https://github.com/nodejs/node/pull/13291,
|
||||||
|
https://github.com/nodejs/node/pull/16589,
|
||||||
|
https://github.com/nodejs/node/pull/15042,
|
||||||
|
https://github.com/nodejs/node/pull/15665,
|
||||||
|
https://github.com/nodejs/readable-stream/pull/344
|
||||||
|
2. 'readable' have precedence over flowing
|
||||||
|
https://github.com/nodejs/node/pull/18994
|
||||||
|
3. make virtual methods errors consistent
|
||||||
|
https://github.com/nodejs/node/pull/18813
|
||||||
|
4. updated streams error handling
|
||||||
|
https://github.com/nodejs/node/pull/18438
|
||||||
|
5. writable.end should return this.
|
||||||
|
https://github.com/nodejs/node/pull/18780
|
||||||
|
6. readable continues to read when push('')
|
||||||
|
https://github.com/nodejs/node/pull/18211
|
||||||
|
7. add custom inspect to BufferList
|
||||||
|
https://github.com/nodejs/node/pull/17907
|
||||||
|
8. always defer 'readable' with nextTick
|
||||||
|
https://github.com/nodejs/node/pull/17979
|
||||||
|
|
||||||
|
## Version 2.x.x
|
||||||
|
v2.x.x of `readable-stream` is a cut of the stream module from Node 8 (there have been no semver-major changes from Node 4 to 8). This version supports all Node.js versions from 0.8, as well as evergreen browsers and IE 10 & 11.
|
||||||
|
|
||||||
|
### Big Thanks
|
||||||
|
|
||||||
|
Cross-browser Testing Platform and Open Source <3 Provided by [Sauce Labs][sauce]
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
|
||||||
|
You can swap your `require('stream')` with `require('readable-stream')`
|
||||||
|
without any changes, if you are just using one of the main classes and
|
||||||
|
functions.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const {
|
||||||
|
Readable,
|
||||||
|
Writable,
|
||||||
|
Transform,
|
||||||
|
Duplex,
|
||||||
|
pipeline,
|
||||||
|
finished
|
||||||
|
} = require('readable-stream')
|
||||||
|
````
|
||||||
|
|
||||||
|
Note that `require('stream')` will return `Stream`, while
|
||||||
|
`require('readable-stream')` will return `Readable`. We discourage using
|
||||||
|
whatever is exported directly, but rather use one of the properties as
|
||||||
|
shown in the example above.
|
||||||
|
|
||||||
# Streams Working Group
|
# Streams Working Group
|
||||||
|
|
||||||
`readable-stream` is maintained by the Streams Working Group, which
|
`readable-stream` is maintained by the Streams Working Group, which
|
||||||
@ -44,15 +95,12 @@ Node.js. The responsibilities of the Streams Working Group include:
|
|||||||
<a name="members"></a>
|
<a name="members"></a>
|
||||||
## Team Members
|
## Team Members
|
||||||
|
|
||||||
* **Chris Dickinson** ([@chrisdickinson](https://github.com/chrisdickinson)) <christopher.s.dickinson@gmail.com>
|
|
||||||
- Release GPG key: 9554F04D7259F04124DE6B476D5A82AC7E37093B
|
|
||||||
* **Calvin Metcalf** ([@calvinmetcalf](https://github.com/calvinmetcalf)) <calvin.metcalf@gmail.com>
|
* **Calvin Metcalf** ([@calvinmetcalf](https://github.com/calvinmetcalf)) <calvin.metcalf@gmail.com>
|
||||||
- Release GPG key: F3EF5F62A87FC27A22E643F714CE4FF5015AA242
|
- Release GPG key: F3EF5F62A87FC27A22E643F714CE4FF5015AA242
|
||||||
* **Rod Vagg** ([@rvagg](https://github.com/rvagg)) <rod@vagg.org>
|
|
||||||
- Release GPG key: DD8F2338BAE7501E3DD5AC78C273792F7D83545D
|
|
||||||
* **Sam Newman** ([@sonewman](https://github.com/sonewman)) <newmansam@outlook.com>
|
|
||||||
* **Mathias Buus** ([@mafintosh](https://github.com/mafintosh)) <mathiasbuus@gmail.com>
|
* **Mathias Buus** ([@mafintosh](https://github.com/mafintosh)) <mathiasbuus@gmail.com>
|
||||||
* **Domenic Denicola** ([@domenic](https://github.com/domenic)) <d@domenic.me>
|
|
||||||
* **Matteo Collina** ([@mcollina](https://github.com/mcollina)) <matteo.collina@gmail.com>
|
* **Matteo Collina** ([@mcollina](https://github.com/mcollina)) <matteo.collina@gmail.com>
|
||||||
- Release GPG key: 3ABC01543F22DD2239285CDD818674489FBC127E
|
- Release GPG key: 3ABC01543F22DD2239285CDD818674489FBC127E
|
||||||
* **Irina Shestak** ([@lrlna](https://github.com/lrlna)) <shestak.irina@gmail.com>
|
* **Irina Shestak** ([@lrlna](https://github.com/lrlna)) <shestak.irina@gmail.com>
|
||||||
|
* **Yoshua Wyuts** ([@yoshuawuyts](https://github.com/yoshuawuyts)) <yoshuawuyts@gmail.com>
|
||||||
|
|
||||||
|
[sauce]: https://saucelabs.com
|
||||||
|
|||||||
60
node_modules/readable-stream/doc/wg-meetings/2015-01-30.md
generated
vendored
60
node_modules/readable-stream/doc/wg-meetings/2015-01-30.md
generated
vendored
@ -1,60 +0,0 @@
|
|||||||
# streams WG Meeting 2015-01-30
|
|
||||||
|
|
||||||
## Links
|
|
||||||
|
|
||||||
* **Google Hangouts Video**: http://www.youtube.com/watch?v=I9nDOSGfwZg
|
|
||||||
* **GitHub Issue**: https://github.com/iojs/readable-stream/issues/106
|
|
||||||
* **Original Minutes Google Doc**: https://docs.google.com/document/d/17aTgLnjMXIrfjgNaTUnHQO7m3xgzHR2VXBTmi03Qii4/
|
|
||||||
|
|
||||||
## Agenda
|
|
||||||
|
|
||||||
Extracted from https://github.com/iojs/readable-stream/labels/wg-agenda prior to meeting.
|
|
||||||
|
|
||||||
* adopt a charter [#105](https://github.com/iojs/readable-stream/issues/105)
|
|
||||||
* release and versioning strategy [#101](https://github.com/iojs/readable-stream/issues/101)
|
|
||||||
* simpler stream creation [#102](https://github.com/iojs/readable-stream/issues/102)
|
|
||||||
* proposal: deprecate implicit flowing of streams [#99](https://github.com/iojs/readable-stream/issues/99)
|
|
||||||
|
|
||||||
## Minutes
|
|
||||||
|
|
||||||
### adopt a charter
|
|
||||||
|
|
||||||
* group: +1's all around
|
|
||||||
|
|
||||||
### What versioning scheme should be adopted?
|
|
||||||
* group: +1’s 3.0.0
|
|
||||||
* domenic+group: pulling in patches from other sources where appropriate
|
|
||||||
* mikeal: version independently, suggesting versions for io.js
|
|
||||||
* mikeal+domenic: work with TC to notify in advance of changes
|
|
||||||
simpler stream creation
|
|
||||||
|
|
||||||
### streamline creation of streams
|
|
||||||
* sam: streamline creation of streams
|
|
||||||
* domenic: nice simple solution posted
|
|
||||||
but, we lose the opportunity to change the model
|
|
||||||
may not be backwards incompatible (double check keys)
|
|
||||||
|
|
||||||
**action item:** domenic will check
|
|
||||||
|
|
||||||
### remove implicit flowing of streams on(‘data’)
|
|
||||||
* add isFlowing / isPaused
|
|
||||||
* mikeal: worrying that we’re documenting polyfill methods – confuses users
|
|
||||||
* domenic: more reflective API is probably good, with warning labels for users
|
|
||||||
* new section for mad scientists (reflective stream access)
|
|
||||||
* calvin: name the “third state”
|
|
||||||
* mikeal: maybe borrow the name from whatwg?
|
|
||||||
* domenic: we’re missing the “third state”
|
|
||||||
* consensus: kind of difficult to name the third state
|
|
||||||
* mikeal: figure out differences in states / compat
|
|
||||||
* mathias: always flow on data – eliminates third state
|
|
||||||
* explore what it breaks
|
|
||||||
|
|
||||||
**action items:**
|
|
||||||
* ask isaac for ability to list packages by what public io.js APIs they use (esp. Stream)
|
|
||||||
* ask rod/build for infrastructure
|
|
||||||
* **chris**: explore the “flow on data” approach
|
|
||||||
* add isPaused/isFlowing
|
|
||||||
* add new docs section
|
|
||||||
* move isPaused to that section
|
|
||||||
|
|
||||||
|
|
||||||
1
node_modules/readable-stream/duplex-browser.js
generated
vendored
1
node_modules/readable-stream/duplex-browser.js
generated
vendored
@ -1 +0,0 @@
|
|||||||
module.exports = require('./lib/_stream_duplex.js');
|
|
||||||
1
node_modules/readable-stream/duplex.js
generated
vendored
1
node_modules/readable-stream/duplex.js
generated
vendored
@ -1 +0,0 @@
|
|||||||
module.exports = require('./readable').Duplex
|
|
||||||
87
node_modules/readable-stream/lib/_stream_duplex.js
generated
vendored
87
node_modules/readable-stream/lib/_stream_duplex.js
generated
vendored
@ -26,90 +26,92 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/*<replacement>*/
|
|
||||||
|
|
||||||
var pna = require('process-nextick-args');
|
|
||||||
/*</replacement>*/
|
|
||||||
|
|
||||||
/*<replacement>*/
|
/*<replacement>*/
|
||||||
var objectKeys = Object.keys || function (obj) {
|
var objectKeys = Object.keys || function (obj) {
|
||||||
var keys = [];
|
var keys = [];
|
||||||
for (var key in obj) {
|
for (var key in obj) keys.push(key);
|
||||||
keys.push(key);
|
return keys;
|
||||||
}return keys;
|
|
||||||
};
|
};
|
||||||
/*</replacement>*/
|
/*</replacement>*/
|
||||||
|
|
||||||
module.exports = Duplex;
|
module.exports = Duplex;
|
||||||
|
|
||||||
/*<replacement>*/
|
|
||||||
var util = Object.create(require('core-util-is'));
|
|
||||||
util.inherits = require('inherits');
|
|
||||||
/*</replacement>*/
|
|
||||||
|
|
||||||
var Readable = require('./_stream_readable');
|
var Readable = require('./_stream_readable');
|
||||||
var Writable = require('./_stream_writable');
|
var Writable = require('./_stream_writable');
|
||||||
|
require('inherits')(Duplex, Readable);
|
||||||
util.inherits(Duplex, Readable);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
// avoid scope creep, the keys array can then be collected
|
// Allow the keys array to be GC'ed.
|
||||||
var keys = objectKeys(Writable.prototype);
|
var keys = objectKeys(Writable.prototype);
|
||||||
for (var v = 0; v < keys.length; v++) {
|
for (var v = 0; v < keys.length; v++) {
|
||||||
var method = keys[v];
|
var method = keys[v];
|
||||||
if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
|
if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Duplex(options) {
|
function Duplex(options) {
|
||||||
if (!(this instanceof Duplex)) return new Duplex(options);
|
if (!(this instanceof Duplex)) return new Duplex(options);
|
||||||
|
|
||||||
Readable.call(this, options);
|
Readable.call(this, options);
|
||||||
Writable.call(this, options);
|
Writable.call(this, options);
|
||||||
|
|
||||||
if (options && options.readable === false) this.readable = false;
|
|
||||||
|
|
||||||
if (options && options.writable === false) this.writable = false;
|
|
||||||
|
|
||||||
this.allowHalfOpen = true;
|
this.allowHalfOpen = true;
|
||||||
if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
|
if (options) {
|
||||||
|
if (options.readable === false) this.readable = false;
|
||||||
this.once('end', onend);
|
if (options.writable === false) this.writable = false;
|
||||||
|
if (options.allowHalfOpen === false) {
|
||||||
|
this.allowHalfOpen = false;
|
||||||
|
this.once('end', onend);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
|
Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
|
||||||
// making it explicit this property is not enumerable
|
// making it explicit this property is not enumerable
|
||||||
// because otherwise some prototype manipulation in
|
// because otherwise some prototype manipulation in
|
||||||
// userland will fail
|
// userland will fail
|
||||||
enumerable: false,
|
enumerable: false,
|
||||||
get: function () {
|
get: function get() {
|
||||||
return this._writableState.highWaterMark;
|
return this._writableState.highWaterMark;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Object.defineProperty(Duplex.prototype, 'writableBuffer', {
|
||||||
|
// making it explicit this property is not enumerable
|
||||||
|
// because otherwise some prototype manipulation in
|
||||||
|
// userland will fail
|
||||||
|
enumerable: false,
|
||||||
|
get: function get() {
|
||||||
|
return this._writableState && this._writableState.getBuffer();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Object.defineProperty(Duplex.prototype, 'writableLength', {
|
||||||
|
// making it explicit this property is not enumerable
|
||||||
|
// because otherwise some prototype manipulation in
|
||||||
|
// userland will fail
|
||||||
|
enumerable: false,
|
||||||
|
get: function get() {
|
||||||
|
return this._writableState.length;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// the no-half-open enforcer
|
// the no-half-open enforcer
|
||||||
function onend() {
|
function onend() {
|
||||||
// if we allow half-open state, or if the writable side ended,
|
// If the writable side ended, then we're ok.
|
||||||
// then we're ok.
|
if (this._writableState.ended) return;
|
||||||
if (this.allowHalfOpen || this._writableState.ended) return;
|
|
||||||
|
|
||||||
// no more data can be written.
|
// no more data can be written.
|
||||||
// But allow more writes to happen in this tick.
|
// But allow more writes to happen in this tick.
|
||||||
pna.nextTick(onEndNT, this);
|
process.nextTick(onEndNT, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onEndNT(self) {
|
function onEndNT(self) {
|
||||||
self.end();
|
self.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.defineProperty(Duplex.prototype, 'destroyed', {
|
Object.defineProperty(Duplex.prototype, 'destroyed', {
|
||||||
get: function () {
|
// making it explicit this property is not enumerable
|
||||||
|
// because otherwise some prototype manipulation in
|
||||||
|
// userland will fail
|
||||||
|
enumerable: false,
|
||||||
|
get: function get() {
|
||||||
if (this._readableState === undefined || this._writableState === undefined) {
|
if (this._readableState === undefined || this._writableState === undefined) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return this._readableState.destroyed && this._writableState.destroyed;
|
return this._readableState.destroyed && this._writableState.destroyed;
|
||||||
},
|
},
|
||||||
set: function (value) {
|
set: function set(value) {
|
||||||
// we ignore the value if the stream
|
// we ignore the value if the stream
|
||||||
// has not been initialized yet
|
// has not been initialized yet
|
||||||
if (this._readableState === undefined || this._writableState === undefined) {
|
if (this._readableState === undefined || this._writableState === undefined) {
|
||||||
@ -121,11 +123,4 @@ Object.defineProperty(Duplex.prototype, 'destroyed', {
|
|||||||
this._readableState.destroyed = value;
|
this._readableState.destroyed = value;
|
||||||
this._writableState.destroyed = value;
|
this._writableState.destroyed = value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Duplex.prototype._destroy = function (err, cb) {
|
|
||||||
this.push(null);
|
|
||||||
this.end();
|
|
||||||
|
|
||||||
pna.nextTick(cb, err);
|
|
||||||
};
|
|
||||||
12
node_modules/readable-stream/lib/_stream_passthrough.js
generated
vendored
12
node_modules/readable-stream/lib/_stream_passthrough.js
generated
vendored
@ -26,22 +26,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
module.exports = PassThrough;
|
module.exports = PassThrough;
|
||||||
|
|
||||||
var Transform = require('./_stream_transform');
|
var Transform = require('./_stream_transform');
|
||||||
|
require('inherits')(PassThrough, Transform);
|
||||||
/*<replacement>*/
|
|
||||||
var util = Object.create(require('core-util-is'));
|
|
||||||
util.inherits = require('inherits');
|
|
||||||
/*</replacement>*/
|
|
||||||
|
|
||||||
util.inherits(PassThrough, Transform);
|
|
||||||
|
|
||||||
function PassThrough(options) {
|
function PassThrough(options) {
|
||||||
if (!(this instanceof PassThrough)) return new PassThrough(options);
|
if (!(this instanceof PassThrough)) return new PassThrough(options);
|
||||||
|
|
||||||
Transform.call(this, options);
|
Transform.call(this, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
PassThrough.prototype._transform = function (chunk, encoding, cb) {
|
PassThrough.prototype._transform = function (chunk, encoding, cb) {
|
||||||
cb(null, chunk);
|
cb(null, chunk);
|
||||||
};
|
};
|
||||||
528
node_modules/readable-stream/lib/_stream_readable.js
generated
vendored
528
node_modules/readable-stream/lib/_stream_readable.js
generated
vendored
File diff suppressed because it is too large
Load Diff
60
node_modules/readable-stream/lib/_stream_transform.js
generated
vendored
60
node_modules/readable-stream/lib/_stream_transform.js
generated
vendored
@ -64,46 +64,35 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
module.exports = Transform;
|
module.exports = Transform;
|
||||||
|
var _require$codes = require('../errors').codes,
|
||||||
|
ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
|
||||||
|
ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
|
||||||
|
ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING,
|
||||||
|
ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0;
|
||||||
var Duplex = require('./_stream_duplex');
|
var Duplex = require('./_stream_duplex');
|
||||||
|
require('inherits')(Transform, Duplex);
|
||||||
/*<replacement>*/
|
|
||||||
var util = Object.create(require('core-util-is'));
|
|
||||||
util.inherits = require('inherits');
|
|
||||||
/*</replacement>*/
|
|
||||||
|
|
||||||
util.inherits(Transform, Duplex);
|
|
||||||
|
|
||||||
function afterTransform(er, data) {
|
function afterTransform(er, data) {
|
||||||
var ts = this._transformState;
|
var ts = this._transformState;
|
||||||
ts.transforming = false;
|
ts.transforming = false;
|
||||||
|
|
||||||
var cb = ts.writecb;
|
var cb = ts.writecb;
|
||||||
|
if (cb === null) {
|
||||||
if (!cb) {
|
return this.emit('error', new ERR_MULTIPLE_CALLBACK());
|
||||||
return this.emit('error', new Error('write callback called multiple times'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ts.writechunk = null;
|
ts.writechunk = null;
|
||||||
ts.writecb = null;
|
ts.writecb = null;
|
||||||
|
if (data != null)
|
||||||
if (data != null) // single equals check for both `null` and `undefined`
|
// single equals check for both `null` and `undefined`
|
||||||
this.push(data);
|
this.push(data);
|
||||||
|
|
||||||
cb(er);
|
cb(er);
|
||||||
|
|
||||||
var rs = this._readableState;
|
var rs = this._readableState;
|
||||||
rs.reading = false;
|
rs.reading = false;
|
||||||
if (rs.needReadable || rs.length < rs.highWaterMark) {
|
if (rs.needReadable || rs.length < rs.highWaterMark) {
|
||||||
this._read(rs.highWaterMark);
|
this._read(rs.highWaterMark);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Transform(options) {
|
function Transform(options) {
|
||||||
if (!(this instanceof Transform)) return new Transform(options);
|
if (!(this instanceof Transform)) return new Transform(options);
|
||||||
|
|
||||||
Duplex.call(this, options);
|
Duplex.call(this, options);
|
||||||
|
|
||||||
this._transformState = {
|
this._transformState = {
|
||||||
afterTransform: afterTransform.bind(this),
|
afterTransform: afterTransform.bind(this),
|
||||||
needTransform: false,
|
needTransform: false,
|
||||||
@ -120,21 +109,17 @@ function Transform(options) {
|
|||||||
// that Readable wants before the first _read call, so unset the
|
// that Readable wants before the first _read call, so unset the
|
||||||
// sync guard flag.
|
// sync guard flag.
|
||||||
this._readableState.sync = false;
|
this._readableState.sync = false;
|
||||||
|
|
||||||
if (options) {
|
if (options) {
|
||||||
if (typeof options.transform === 'function') this._transform = options.transform;
|
if (typeof options.transform === 'function') this._transform = options.transform;
|
||||||
|
|
||||||
if (typeof options.flush === 'function') this._flush = options.flush;
|
if (typeof options.flush === 'function') this._flush = options.flush;
|
||||||
}
|
}
|
||||||
|
|
||||||
// When the writable side finishes, then flush out anything remaining.
|
// When the writable side finishes, then flush out anything remaining.
|
||||||
this.on('prefinish', prefinish);
|
this.on('prefinish', prefinish);
|
||||||
}
|
}
|
||||||
|
|
||||||
function prefinish() {
|
function prefinish() {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
|
if (typeof this._flush === 'function' && !this._readableState.destroyed) {
|
||||||
if (typeof this._flush === 'function') {
|
|
||||||
this._flush(function (er, data) {
|
this._flush(function (er, data) {
|
||||||
done(_this, er, data);
|
done(_this, er, data);
|
||||||
});
|
});
|
||||||
@ -142,7 +127,6 @@ function prefinish() {
|
|||||||
done(this, null, null);
|
done(this, null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform.prototype.push = function (chunk, encoding) {
|
Transform.prototype.push = function (chunk, encoding) {
|
||||||
this._transformState.needTransform = false;
|
this._transformState.needTransform = false;
|
||||||
return Duplex.prototype.push.call(this, chunk, encoding);
|
return Duplex.prototype.push.call(this, chunk, encoding);
|
||||||
@ -159,9 +143,8 @@ Transform.prototype.push = function (chunk, encoding) {
|
|||||||
// an error, then that'll put the hurt on the whole operation. If you
|
// an error, then that'll put the hurt on the whole operation. If you
|
||||||
// never call cb(), then you'll never get another chunk.
|
// never call cb(), then you'll never get another chunk.
|
||||||
Transform.prototype._transform = function (chunk, encoding, cb) {
|
Transform.prototype._transform = function (chunk, encoding, cb) {
|
||||||
throw new Error('_transform() is not implemented');
|
cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()'));
|
||||||
};
|
};
|
||||||
|
|
||||||
Transform.prototype._write = function (chunk, encoding, cb) {
|
Transform.prototype._write = function (chunk, encoding, cb) {
|
||||||
var ts = this._transformState;
|
var ts = this._transformState;
|
||||||
ts.writecb = cb;
|
ts.writecb = cb;
|
||||||
@ -178,8 +161,7 @@ Transform.prototype._write = function (chunk, encoding, cb) {
|
|||||||
// That we got here means that the readable side wants more data.
|
// That we got here means that the readable side wants more data.
|
||||||
Transform.prototype._read = function (n) {
|
Transform.prototype._read = function (n) {
|
||||||
var ts = this._transformState;
|
var ts = this._transformState;
|
||||||
|
if (ts.writechunk !== null && !ts.transforming) {
|
||||||
if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
|
|
||||||
ts.transforming = true;
|
ts.transforming = true;
|
||||||
this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
|
this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
|
||||||
} else {
|
} else {
|
||||||
@ -188,27 +170,21 @@ Transform.prototype._read = function (n) {
|
|||||||
ts.needTransform = true;
|
ts.needTransform = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Transform.prototype._destroy = function (err, cb) {
|
Transform.prototype._destroy = function (err, cb) {
|
||||||
var _this2 = this;
|
|
||||||
|
|
||||||
Duplex.prototype._destroy.call(this, err, function (err2) {
|
Duplex.prototype._destroy.call(this, err, function (err2) {
|
||||||
cb(err2);
|
cb(err2);
|
||||||
_this2.emit('close');
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function done(stream, er, data) {
|
function done(stream, er, data) {
|
||||||
if (er) return stream.emit('error', er);
|
if (er) return stream.emit('error', er);
|
||||||
|
if (data != null)
|
||||||
if (data != null) // single equals check for both `null` and `undefined`
|
// single equals check for both `null` and `undefined`
|
||||||
stream.push(data);
|
stream.push(data);
|
||||||
|
|
||||||
|
// TODO(BridgeAR): Write a test for these two error cases
|
||||||
// if there's nothing in the write buffer, then that means
|
// if there's nothing in the write buffer, then that means
|
||||||
// that nothing more will ever be provided
|
// that nothing more will ever be provided
|
||||||
if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
|
if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0();
|
||||||
|
if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING();
|
||||||
if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
|
|
||||||
|
|
||||||
return stream.push(null);
|
return stream.push(null);
|
||||||
}
|
}
|
||||||
234
node_modules/readable-stream/lib/_stream_writable.js
generated
vendored
234
node_modules/readable-stream/lib/_stream_writable.js
generated
vendored
@ -25,11 +25,6 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/*<replacement>*/
|
|
||||||
|
|
||||||
var pna = require('process-nextick-args');
|
|
||||||
/*</replacement>*/
|
|
||||||
|
|
||||||
module.exports = Writable;
|
module.exports = Writable;
|
||||||
|
|
||||||
/* <replacement> */
|
/* <replacement> */
|
||||||
@ -44,7 +39,6 @@ function WriteReq(chunk, encoding, cb) {
|
|||||||
// there will be only 2 of these for each stream
|
// there will be only 2 of these for each stream
|
||||||
function CorkedRequest(state) {
|
function CorkedRequest(state) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
|
|
||||||
this.next = null;
|
this.next = null;
|
||||||
this.entry = null;
|
this.entry = null;
|
||||||
this.finish = function () {
|
this.finish = function () {
|
||||||
@ -53,21 +47,12 @@ function CorkedRequest(state) {
|
|||||||
}
|
}
|
||||||
/* </replacement> */
|
/* </replacement> */
|
||||||
|
|
||||||
/*<replacement>*/
|
|
||||||
var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
|
|
||||||
/*</replacement>*/
|
|
||||||
|
|
||||||
/*<replacement>*/
|
/*<replacement>*/
|
||||||
var Duplex;
|
var Duplex;
|
||||||
/*</replacement>*/
|
/*</replacement>*/
|
||||||
|
|
||||||
Writable.WritableState = WritableState;
|
Writable.WritableState = WritableState;
|
||||||
|
|
||||||
/*<replacement>*/
|
|
||||||
var util = Object.create(require('core-util-is'));
|
|
||||||
util.inherits = require('inherits');
|
|
||||||
/*</replacement>*/
|
|
||||||
|
|
||||||
/*<replacement>*/
|
/*<replacement>*/
|
||||||
var internalUtil = {
|
var internalUtil = {
|
||||||
deprecate: require('util-deprecate')
|
deprecate: require('util-deprecate')
|
||||||
@ -78,9 +63,7 @@ var internalUtil = {
|
|||||||
var Stream = require('./internal/streams/stream');
|
var Stream = require('./internal/streams/stream');
|
||||||
/*</replacement>*/
|
/*</replacement>*/
|
||||||
|
|
||||||
/*<replacement>*/
|
var Buffer = require('buffer').Buffer;
|
||||||
|
|
||||||
var Buffer = require('safe-buffer').Buffer;
|
|
||||||
var OurUint8Array = (typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {};
|
var OurUint8Array = (typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {};
|
||||||
function _uint8ArrayToBuffer(chunk) {
|
function _uint8ArrayToBuffer(chunk) {
|
||||||
return Buffer.from(chunk);
|
return Buffer.from(chunk);
|
||||||
@ -88,44 +71,41 @@ function _uint8ArrayToBuffer(chunk) {
|
|||||||
function _isUint8Array(obj) {
|
function _isUint8Array(obj) {
|
||||||
return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
|
return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*</replacement>*/
|
|
||||||
|
|
||||||
var destroyImpl = require('./internal/streams/destroy');
|
var destroyImpl = require('./internal/streams/destroy');
|
||||||
|
var _require = require('./internal/streams/state'),
|
||||||
util.inherits(Writable, Stream);
|
getHighWaterMark = _require.getHighWaterMark;
|
||||||
|
var _require$codes = require('../errors').codes,
|
||||||
|
ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
|
||||||
|
ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
|
||||||
|
ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
|
||||||
|
ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE,
|
||||||
|
ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED,
|
||||||
|
ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES,
|
||||||
|
ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END,
|
||||||
|
ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING;
|
||||||
|
var errorOrDestroy = destroyImpl.errorOrDestroy;
|
||||||
|
require('inherits')(Writable, Stream);
|
||||||
function nop() {}
|
function nop() {}
|
||||||
|
function WritableState(options, stream, isDuplex) {
|
||||||
function WritableState(options, stream) {
|
|
||||||
Duplex = Duplex || require('./_stream_duplex');
|
Duplex = Duplex || require('./_stream_duplex');
|
||||||
|
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
|
||||||
// Duplex streams are both readable and writable, but share
|
// Duplex streams are both readable and writable, but share
|
||||||
// the same options object.
|
// the same options object.
|
||||||
// However, some cases require setting options to different
|
// However, some cases require setting options to different
|
||||||
// values for the readable and the writable sides of the duplex stream.
|
// values for the readable and the writable sides of the duplex stream,
|
||||||
// These options can be provided separately as readableXXX and writableXXX.
|
// e.g. options.readableObjectMode vs. options.writableObjectMode, etc.
|
||||||
var isDuplex = stream instanceof Duplex;
|
if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex;
|
||||||
|
|
||||||
// object stream flag to indicate whether or not this stream
|
// object stream flag to indicate whether or not this stream
|
||||||
// contains buffers or objects.
|
// contains buffers or objects.
|
||||||
this.objectMode = !!options.objectMode;
|
this.objectMode = !!options.objectMode;
|
||||||
|
|
||||||
if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
|
if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
|
||||||
|
|
||||||
// the point at which write() starts returning false
|
// the point at which write() starts returning false
|
||||||
// Note: 0 is a valid value, means that we always return false if
|
// Note: 0 is a valid value, means that we always return false if
|
||||||
// the entire buffer is not flushed immediately on write()
|
// the entire buffer is not flushed immediately on write()
|
||||||
var hwm = options.highWaterMark;
|
this.highWaterMark = getHighWaterMark(this, options, 'writableHighWaterMark', isDuplex);
|
||||||
var writableHwm = options.writableHighWaterMark;
|
|
||||||
var defaultHwm = this.objectMode ? 16 : 16 * 1024;
|
|
||||||
|
|
||||||
if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
|
|
||||||
|
|
||||||
// cast to ints.
|
|
||||||
this.highWaterMark = Math.floor(this.highWaterMark);
|
|
||||||
|
|
||||||
// if _final has been called
|
// if _final has been called
|
||||||
this.finalCalled = false;
|
this.finalCalled = false;
|
||||||
@ -185,7 +165,6 @@ function WritableState(options, stream) {
|
|||||||
|
|
||||||
// the amount that is being written when _write is called.
|
// the amount that is being written when _write is called.
|
||||||
this.writelen = 0;
|
this.writelen = 0;
|
||||||
|
|
||||||
this.bufferedRequest = null;
|
this.bufferedRequest = null;
|
||||||
this.lastBufferedRequest = null;
|
this.lastBufferedRequest = null;
|
||||||
|
|
||||||
@ -200,6 +179,12 @@ function WritableState(options, stream) {
|
|||||||
// True if the error was already emitted and should not be thrown again
|
// True if the error was already emitted and should not be thrown again
|
||||||
this.errorEmitted = false;
|
this.errorEmitted = false;
|
||||||
|
|
||||||
|
// Should close be emitted on destroy. Defaults to true.
|
||||||
|
this.emitClose = options.emitClose !== false;
|
||||||
|
|
||||||
|
// Should .destroy() be called after 'finish' (and potentially 'end')
|
||||||
|
this.autoDestroy = !!options.autoDestroy;
|
||||||
|
|
||||||
// count buffered requests
|
// count buffered requests
|
||||||
this.bufferedRequestCount = 0;
|
this.bufferedRequestCount = 0;
|
||||||
|
|
||||||
@ -207,7 +192,6 @@ function WritableState(options, stream) {
|
|||||||
// one allocated and free to use, and we maintain at most two
|
// one allocated and free to use, and we maintain at most two
|
||||||
this.corkedRequestsFree = new CorkedRequest(this);
|
this.corkedRequestsFree = new CorkedRequest(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
WritableState.prototype.getBuffer = function getBuffer() {
|
WritableState.prototype.getBuffer = function getBuffer() {
|
||||||
var current = this.bufferedRequest;
|
var current = this.bufferedRequest;
|
||||||
var out = [];
|
var out = [];
|
||||||
@ -217,11 +201,10 @@ WritableState.prototype.getBuffer = function getBuffer() {
|
|||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
};
|
};
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
try {
|
try {
|
||||||
Object.defineProperty(WritableState.prototype, 'buffer', {
|
Object.defineProperty(WritableState.prototype, 'buffer', {
|
||||||
get: internalUtil.deprecate(function () {
|
get: internalUtil.deprecate(function writableStateBufferGetter() {
|
||||||
return this.getBuffer();
|
return this.getBuffer();
|
||||||
}, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
|
}, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
|
||||||
});
|
});
|
||||||
@ -234,19 +217,17 @@ var realHasInstance;
|
|||||||
if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
|
if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
|
||||||
realHasInstance = Function.prototype[Symbol.hasInstance];
|
realHasInstance = Function.prototype[Symbol.hasInstance];
|
||||||
Object.defineProperty(Writable, Symbol.hasInstance, {
|
Object.defineProperty(Writable, Symbol.hasInstance, {
|
||||||
value: function (object) {
|
value: function value(object) {
|
||||||
if (realHasInstance.call(this, object)) return true;
|
if (realHasInstance.call(this, object)) return true;
|
||||||
if (this !== Writable) return false;
|
if (this !== Writable) return false;
|
||||||
|
|
||||||
return object && object._writableState instanceof WritableState;
|
return object && object._writableState instanceof WritableState;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
realHasInstance = function (object) {
|
realHasInstance = function realHasInstance(object) {
|
||||||
return object instanceof this;
|
return object instanceof this;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function Writable(options) {
|
function Writable(options) {
|
||||||
Duplex = Duplex || require('./_stream_duplex');
|
Duplex = Duplex || require('./_stream_duplex');
|
||||||
|
|
||||||
@ -257,123 +238,109 @@ function Writable(options) {
|
|||||||
// Trying to use the custom `instanceof` for Writable here will also break the
|
// Trying to use the custom `instanceof` for Writable here will also break the
|
||||||
// Node.js LazyTransform implementation, which has a non-trivial getter for
|
// Node.js LazyTransform implementation, which has a non-trivial getter for
|
||||||
// `_writableState` that would lead to infinite recursion.
|
// `_writableState` that would lead to infinite recursion.
|
||||||
if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
|
|
||||||
return new Writable(options);
|
|
||||||
}
|
|
||||||
|
|
||||||
this._writableState = new WritableState(options, this);
|
// Checking for a Stream.Duplex instance is faster here instead of inside
|
||||||
|
// the WritableState constructor, at least with V8 6.5
|
||||||
|
var isDuplex = this instanceof Duplex;
|
||||||
|
if (!isDuplex && !realHasInstance.call(Writable, this)) return new Writable(options);
|
||||||
|
this._writableState = new WritableState(options, this, isDuplex);
|
||||||
|
|
||||||
// legacy.
|
// legacy.
|
||||||
this.writable = true;
|
this.writable = true;
|
||||||
|
|
||||||
if (options) {
|
if (options) {
|
||||||
if (typeof options.write === 'function') this._write = options.write;
|
if (typeof options.write === 'function') this._write = options.write;
|
||||||
|
|
||||||
if (typeof options.writev === 'function') this._writev = options.writev;
|
if (typeof options.writev === 'function') this._writev = options.writev;
|
||||||
|
|
||||||
if (typeof options.destroy === 'function') this._destroy = options.destroy;
|
if (typeof options.destroy === 'function') this._destroy = options.destroy;
|
||||||
|
|
||||||
if (typeof options.final === 'function') this._final = options.final;
|
if (typeof options.final === 'function') this._final = options.final;
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream.call(this);
|
Stream.call(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise people can pipe Writable streams, which is just wrong.
|
// Otherwise people can pipe Writable streams, which is just wrong.
|
||||||
Writable.prototype.pipe = function () {
|
Writable.prototype.pipe = function () {
|
||||||
this.emit('error', new Error('Cannot pipe, not readable'));
|
errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE());
|
||||||
};
|
};
|
||||||
|
|
||||||
function writeAfterEnd(stream, cb) {
|
function writeAfterEnd(stream, cb) {
|
||||||
var er = new Error('write after end');
|
var er = new ERR_STREAM_WRITE_AFTER_END();
|
||||||
// TODO: defer error events consistently everywhere, not just the cb
|
// TODO: defer error events consistently everywhere, not just the cb
|
||||||
stream.emit('error', er);
|
errorOrDestroy(stream, er);
|
||||||
pna.nextTick(cb, er);
|
process.nextTick(cb, er);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks that a user-supplied chunk is valid, especially for the particular
|
// Checks that a user-supplied chunk is valid, especially for the particular
|
||||||
// mode the stream is in. Currently this means that `null` is never accepted
|
// mode the stream is in. Currently this means that `null` is never accepted
|
||||||
// and undefined/non-string values are only allowed in object mode.
|
// and undefined/non-string values are only allowed in object mode.
|
||||||
function validChunk(stream, state, chunk, cb) {
|
function validChunk(stream, state, chunk, cb) {
|
||||||
var valid = true;
|
var er;
|
||||||
var er = false;
|
|
||||||
|
|
||||||
if (chunk === null) {
|
if (chunk === null) {
|
||||||
er = new TypeError('May not write null values to stream');
|
er = new ERR_STREAM_NULL_VALUES();
|
||||||
} else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
|
} else if (typeof chunk !== 'string' && !state.objectMode) {
|
||||||
er = new TypeError('Invalid non-string/buffer chunk');
|
er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer'], chunk);
|
||||||
}
|
}
|
||||||
if (er) {
|
if (er) {
|
||||||
stream.emit('error', er);
|
errorOrDestroy(stream, er);
|
||||||
pna.nextTick(cb, er);
|
process.nextTick(cb, er);
|
||||||
valid = false;
|
return false;
|
||||||
}
|
}
|
||||||
return valid;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Writable.prototype.write = function (chunk, encoding, cb) {
|
Writable.prototype.write = function (chunk, encoding, cb) {
|
||||||
var state = this._writableState;
|
var state = this._writableState;
|
||||||
var ret = false;
|
var ret = false;
|
||||||
var isBuf = !state.objectMode && _isUint8Array(chunk);
|
var isBuf = !state.objectMode && _isUint8Array(chunk);
|
||||||
|
|
||||||
if (isBuf && !Buffer.isBuffer(chunk)) {
|
if (isBuf && !Buffer.isBuffer(chunk)) {
|
||||||
chunk = _uint8ArrayToBuffer(chunk);
|
chunk = _uint8ArrayToBuffer(chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof encoding === 'function') {
|
if (typeof encoding === 'function') {
|
||||||
cb = encoding;
|
cb = encoding;
|
||||||
encoding = null;
|
encoding = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
|
if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
|
||||||
|
|
||||||
if (typeof cb !== 'function') cb = nop;
|
if (typeof cb !== 'function') cb = nop;
|
||||||
|
if (state.ending) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
|
||||||
if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
|
|
||||||
state.pendingcb++;
|
state.pendingcb++;
|
||||||
ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
|
ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
Writable.prototype.cork = function () {
|
Writable.prototype.cork = function () {
|
||||||
var state = this._writableState;
|
this._writableState.corked++;
|
||||||
|
|
||||||
state.corked++;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Writable.prototype.uncork = function () {
|
Writable.prototype.uncork = function () {
|
||||||
var state = this._writableState;
|
var state = this._writableState;
|
||||||
|
|
||||||
if (state.corked) {
|
if (state.corked) {
|
||||||
state.corked--;
|
state.corked--;
|
||||||
|
|
||||||
if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
|
if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
|
Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
|
||||||
// node::ParseEncoding() requires lower case.
|
// node::ParseEncoding() requires lower case.
|
||||||
if (typeof encoding === 'string') encoding = encoding.toLowerCase();
|
if (typeof encoding === 'string') encoding = encoding.toLowerCase();
|
||||||
if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
|
if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new ERR_UNKNOWN_ENCODING(encoding);
|
||||||
this._writableState.defaultEncoding = encoding;
|
this._writableState.defaultEncoding = encoding;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
Object.defineProperty(Writable.prototype, 'writableBuffer', {
|
||||||
|
// making it explicit this property is not enumerable
|
||||||
|
// because otherwise some prototype manipulation in
|
||||||
|
// userland will fail
|
||||||
|
enumerable: false,
|
||||||
|
get: function get() {
|
||||||
|
return this._writableState && this._writableState.getBuffer();
|
||||||
|
}
|
||||||
|
});
|
||||||
function decodeChunk(state, chunk, encoding) {
|
function decodeChunk(state, chunk, encoding) {
|
||||||
if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
|
if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
|
||||||
chunk = Buffer.from(chunk, encoding);
|
chunk = Buffer.from(chunk, encoding);
|
||||||
}
|
}
|
||||||
return chunk;
|
return chunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
|
Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
|
||||||
// making it explicit this property is not enumerable
|
// making it explicit this property is not enumerable
|
||||||
// because otherwise some prototype manipulation in
|
// because otherwise some prototype manipulation in
|
||||||
// userland will fail
|
// userland will fail
|
||||||
enumerable: false,
|
enumerable: false,
|
||||||
get: function () {
|
get: function get() {
|
||||||
return this._writableState.highWaterMark;
|
return this._writableState.highWaterMark;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -391,13 +358,10 @@ function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var len = state.objectMode ? 1 : chunk.length;
|
var len = state.objectMode ? 1 : chunk.length;
|
||||||
|
|
||||||
state.length += len;
|
state.length += len;
|
||||||
|
|
||||||
var ret = state.length < state.highWaterMark;
|
var ret = state.length < state.highWaterMark;
|
||||||
// we must ensure that previous needDrain will not be reset to false.
|
// we must ensure that previous needDrain will not be reset to false.
|
||||||
if (!ret) state.needDrain = true;
|
if (!ret) state.needDrain = true;
|
||||||
|
|
||||||
if (state.writing || state.corked) {
|
if (state.writing || state.corked) {
|
||||||
var last = state.lastBufferedRequest;
|
var last = state.lastBufferedRequest;
|
||||||
state.lastBufferedRequest = {
|
state.lastBufferedRequest = {
|
||||||
@ -416,75 +380,63 @@ function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
|
|||||||
} else {
|
} else {
|
||||||
doWrite(stream, state, false, len, chunk, encoding, cb);
|
doWrite(stream, state, false, len, chunk, encoding, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
function doWrite(stream, state, writev, len, chunk, encoding, cb) {
|
function doWrite(stream, state, writev, len, chunk, encoding, cb) {
|
||||||
state.writelen = len;
|
state.writelen = len;
|
||||||
state.writecb = cb;
|
state.writecb = cb;
|
||||||
state.writing = true;
|
state.writing = true;
|
||||||
state.sync = true;
|
state.sync = true;
|
||||||
if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
|
if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED('write'));else if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
|
||||||
state.sync = false;
|
state.sync = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onwriteError(stream, state, sync, er, cb) {
|
function onwriteError(stream, state, sync, er, cb) {
|
||||||
--state.pendingcb;
|
--state.pendingcb;
|
||||||
|
|
||||||
if (sync) {
|
if (sync) {
|
||||||
// defer the callback if we are being called synchronously
|
// defer the callback if we are being called synchronously
|
||||||
// to avoid piling up things on the stack
|
// to avoid piling up things on the stack
|
||||||
pna.nextTick(cb, er);
|
process.nextTick(cb, er);
|
||||||
// this can emit finish, and it will always happen
|
// this can emit finish, and it will always happen
|
||||||
// after error
|
// after error
|
||||||
pna.nextTick(finishMaybe, stream, state);
|
process.nextTick(finishMaybe, stream, state);
|
||||||
stream._writableState.errorEmitted = true;
|
stream._writableState.errorEmitted = true;
|
||||||
stream.emit('error', er);
|
errorOrDestroy(stream, er);
|
||||||
} else {
|
} else {
|
||||||
// the caller expect this to happen before if
|
// the caller expect this to happen before if
|
||||||
// it is async
|
// it is async
|
||||||
cb(er);
|
cb(er);
|
||||||
stream._writableState.errorEmitted = true;
|
stream._writableState.errorEmitted = true;
|
||||||
stream.emit('error', er);
|
errorOrDestroy(stream, er);
|
||||||
// this can emit finish, but finish must
|
// this can emit finish, but finish must
|
||||||
// always follow error
|
// always follow error
|
||||||
finishMaybe(stream, state);
|
finishMaybe(stream, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onwriteStateUpdate(state) {
|
function onwriteStateUpdate(state) {
|
||||||
state.writing = false;
|
state.writing = false;
|
||||||
state.writecb = null;
|
state.writecb = null;
|
||||||
state.length -= state.writelen;
|
state.length -= state.writelen;
|
||||||
state.writelen = 0;
|
state.writelen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onwrite(stream, er) {
|
function onwrite(stream, er) {
|
||||||
var state = stream._writableState;
|
var state = stream._writableState;
|
||||||
var sync = state.sync;
|
var sync = state.sync;
|
||||||
var cb = state.writecb;
|
var cb = state.writecb;
|
||||||
|
if (typeof cb !== 'function') throw new ERR_MULTIPLE_CALLBACK();
|
||||||
onwriteStateUpdate(state);
|
onwriteStateUpdate(state);
|
||||||
|
|
||||||
if (er) onwriteError(stream, state, sync, er, cb);else {
|
if (er) onwriteError(stream, state, sync, er, cb);else {
|
||||||
// Check if we're actually ready to finish, but don't emit yet
|
// Check if we're actually ready to finish, but don't emit yet
|
||||||
var finished = needFinish(state);
|
var finished = needFinish(state) || stream.destroyed;
|
||||||
|
|
||||||
if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
|
if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
|
||||||
clearBuffer(stream, state);
|
clearBuffer(stream, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sync) {
|
if (sync) {
|
||||||
/*<replacement>*/
|
process.nextTick(afterWrite, stream, state, finished, cb);
|
||||||
asyncWrite(afterWrite, stream, state, finished, cb);
|
|
||||||
/*</replacement>*/
|
|
||||||
} else {
|
} else {
|
||||||
afterWrite(stream, state, finished, cb);
|
afterWrite(stream, state, finished, cb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function afterWrite(stream, state, finished, cb) {
|
function afterWrite(stream, state, finished, cb) {
|
||||||
if (!finished) onwriteDrain(stream, state);
|
if (!finished) onwriteDrain(stream, state);
|
||||||
state.pendingcb--;
|
state.pendingcb--;
|
||||||
@ -506,14 +458,12 @@ function onwriteDrain(stream, state) {
|
|||||||
function clearBuffer(stream, state) {
|
function clearBuffer(stream, state) {
|
||||||
state.bufferProcessing = true;
|
state.bufferProcessing = true;
|
||||||
var entry = state.bufferedRequest;
|
var entry = state.bufferedRequest;
|
||||||
|
|
||||||
if (stream._writev && entry && entry.next) {
|
if (stream._writev && entry && entry.next) {
|
||||||
// Fast case, write everything using _writev()
|
// Fast case, write everything using _writev()
|
||||||
var l = state.bufferedRequestCount;
|
var l = state.bufferedRequestCount;
|
||||||
var buffer = new Array(l);
|
var buffer = new Array(l);
|
||||||
var holder = state.corkedRequestsFree;
|
var holder = state.corkedRequestsFree;
|
||||||
holder.entry = entry;
|
holder.entry = entry;
|
||||||
|
|
||||||
var count = 0;
|
var count = 0;
|
||||||
var allBuffers = true;
|
var allBuffers = true;
|
||||||
while (entry) {
|
while (entry) {
|
||||||
@ -523,7 +473,6 @@ function clearBuffer(stream, state) {
|
|||||||
count += 1;
|
count += 1;
|
||||||
}
|
}
|
||||||
buffer.allBuffers = allBuffers;
|
buffer.allBuffers = allBuffers;
|
||||||
|
|
||||||
doWrite(stream, state, true, state.length, buffer, '', holder.finish);
|
doWrite(stream, state, true, state.length, buffer, '', holder.finish);
|
||||||
|
|
||||||
// doWrite is almost always async, defer these to save a bit of time
|
// doWrite is almost always async, defer these to save a bit of time
|
||||||
@ -544,7 +493,6 @@ function clearBuffer(stream, state) {
|
|||||||
var encoding = entry.encoding;
|
var encoding = entry.encoding;
|
||||||
var cb = entry.callback;
|
var cb = entry.callback;
|
||||||
var len = state.objectMode ? 1 : chunk.length;
|
var len = state.objectMode ? 1 : chunk.length;
|
||||||
|
|
||||||
doWrite(stream, state, false, len, chunk, encoding, cb);
|
doWrite(stream, state, false, len, chunk, encoding, cb);
|
||||||
entry = entry.next;
|
entry = entry.next;
|
||||||
state.bufferedRequestCount--;
|
state.bufferedRequestCount--;
|
||||||
@ -556,23 +504,17 @@ function clearBuffer(stream, state) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry === null) state.lastBufferedRequest = null;
|
if (entry === null) state.lastBufferedRequest = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
state.bufferedRequest = entry;
|
state.bufferedRequest = entry;
|
||||||
state.bufferProcessing = false;
|
state.bufferProcessing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Writable.prototype._write = function (chunk, encoding, cb) {
|
Writable.prototype._write = function (chunk, encoding, cb) {
|
||||||
cb(new Error('_write() is not implemented'));
|
cb(new ERR_METHOD_NOT_IMPLEMENTED('_write()'));
|
||||||
};
|
};
|
||||||
|
|
||||||
Writable.prototype._writev = null;
|
Writable.prototype._writev = null;
|
||||||
|
|
||||||
Writable.prototype.end = function (chunk, encoding, cb) {
|
Writable.prototype.end = function (chunk, encoding, cb) {
|
||||||
var state = this._writableState;
|
var state = this._writableState;
|
||||||
|
|
||||||
if (typeof chunk === 'function') {
|
if (typeof chunk === 'function') {
|
||||||
cb = chunk;
|
cb = chunk;
|
||||||
chunk = null;
|
chunk = null;
|
||||||
@ -581,7 +523,6 @@ Writable.prototype.end = function (chunk, encoding, cb) {
|
|||||||
cb = encoding;
|
cb = encoding;
|
||||||
encoding = null;
|
encoding = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
|
if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
|
||||||
|
|
||||||
// .end() fully uncorks
|
// .end() fully uncorks
|
||||||
@ -592,8 +533,17 @@ Writable.prototype.end = function (chunk, encoding, cb) {
|
|||||||
|
|
||||||
// ignore unnecessary end() calls.
|
// ignore unnecessary end() calls.
|
||||||
if (!state.ending) endWritable(this, state, cb);
|
if (!state.ending) endWritable(this, state, cb);
|
||||||
|
return this;
|
||||||
};
|
};
|
||||||
|
Object.defineProperty(Writable.prototype, 'writableLength', {
|
||||||
|
// making it explicit this property is not enumerable
|
||||||
|
// because otherwise some prototype manipulation in
|
||||||
|
// userland will fail
|
||||||
|
enumerable: false,
|
||||||
|
get: function get() {
|
||||||
|
return this._writableState.length;
|
||||||
|
}
|
||||||
|
});
|
||||||
function needFinish(state) {
|
function needFinish(state) {
|
||||||
return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
|
return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
|
||||||
}
|
}
|
||||||
@ -601,7 +551,7 @@ function callFinal(stream, state) {
|
|||||||
stream._final(function (err) {
|
stream._final(function (err) {
|
||||||
state.pendingcb--;
|
state.pendingcb--;
|
||||||
if (err) {
|
if (err) {
|
||||||
stream.emit('error', err);
|
errorOrDestroy(stream, err);
|
||||||
}
|
}
|
||||||
state.prefinished = true;
|
state.prefinished = true;
|
||||||
stream.emit('prefinish');
|
stream.emit('prefinish');
|
||||||
@ -610,17 +560,16 @@ function callFinal(stream, state) {
|
|||||||
}
|
}
|
||||||
function prefinish(stream, state) {
|
function prefinish(stream, state) {
|
||||||
if (!state.prefinished && !state.finalCalled) {
|
if (!state.prefinished && !state.finalCalled) {
|
||||||
if (typeof stream._final === 'function') {
|
if (typeof stream._final === 'function' && !state.destroyed) {
|
||||||
state.pendingcb++;
|
state.pendingcb++;
|
||||||
state.finalCalled = true;
|
state.finalCalled = true;
|
||||||
pna.nextTick(callFinal, stream, state);
|
process.nextTick(callFinal, stream, state);
|
||||||
} else {
|
} else {
|
||||||
state.prefinished = true;
|
state.prefinished = true;
|
||||||
stream.emit('prefinish');
|
stream.emit('prefinish');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function finishMaybe(stream, state) {
|
function finishMaybe(stream, state) {
|
||||||
var need = needFinish(state);
|
var need = needFinish(state);
|
||||||
if (need) {
|
if (need) {
|
||||||
@ -628,21 +577,27 @@ function finishMaybe(stream, state) {
|
|||||||
if (state.pendingcb === 0) {
|
if (state.pendingcb === 0) {
|
||||||
state.finished = true;
|
state.finished = true;
|
||||||
stream.emit('finish');
|
stream.emit('finish');
|
||||||
|
if (state.autoDestroy) {
|
||||||
|
// In case of duplex streams we need a way to detect
|
||||||
|
// if the readable side is ready for autoDestroy as well
|
||||||
|
var rState = stream._readableState;
|
||||||
|
if (!rState || rState.autoDestroy && rState.endEmitted) {
|
||||||
|
stream.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return need;
|
return need;
|
||||||
}
|
}
|
||||||
|
|
||||||
function endWritable(stream, state, cb) {
|
function endWritable(stream, state, cb) {
|
||||||
state.ending = true;
|
state.ending = true;
|
||||||
finishMaybe(stream, state);
|
finishMaybe(stream, state);
|
||||||
if (cb) {
|
if (cb) {
|
||||||
if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
|
if (state.finished) process.nextTick(cb);else stream.once('finish', cb);
|
||||||
}
|
}
|
||||||
state.ended = true;
|
state.ended = true;
|
||||||
stream.writable = false;
|
stream.writable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onCorkedFinish(corkReq, state, err) {
|
function onCorkedFinish(corkReq, state, err) {
|
||||||
var entry = corkReq.entry;
|
var entry = corkReq.entry;
|
||||||
corkReq.entry = null;
|
corkReq.entry = null;
|
||||||
@ -656,15 +611,18 @@ function onCorkedFinish(corkReq, state, err) {
|
|||||||
// reuse the free corkReq.
|
// reuse the free corkReq.
|
||||||
state.corkedRequestsFree.next = corkReq;
|
state.corkedRequestsFree.next = corkReq;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.defineProperty(Writable.prototype, 'destroyed', {
|
Object.defineProperty(Writable.prototype, 'destroyed', {
|
||||||
get: function () {
|
// making it explicit this property is not enumerable
|
||||||
|
// because otherwise some prototype manipulation in
|
||||||
|
// userland will fail
|
||||||
|
enumerable: false,
|
||||||
|
get: function get() {
|
||||||
if (this._writableState === undefined) {
|
if (this._writableState === undefined) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return this._writableState.destroyed;
|
return this._writableState.destroyed;
|
||||||
},
|
},
|
||||||
set: function (value) {
|
set: function set(value) {
|
||||||
// we ignore the value if the stream
|
// we ignore the value if the stream
|
||||||
// has not been initialized yet
|
// has not been initialized yet
|
||||||
if (!this._writableState) {
|
if (!this._writableState) {
|
||||||
@ -676,10 +634,8 @@ Object.defineProperty(Writable.prototype, 'destroyed', {
|
|||||||
this._writableState.destroyed = value;
|
this._writableState.destroyed = value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Writable.prototype.destroy = destroyImpl.destroy;
|
Writable.prototype.destroy = destroyImpl.destroy;
|
||||||
Writable.prototype._undestroy = destroyImpl.undestroy;
|
Writable.prototype._undestroy = destroyImpl.undestroy;
|
||||||
Writable.prototype._destroy = function (err, cb) {
|
Writable.prototype._destroy = function (err, cb) {
|
||||||
this.end();
|
|
||||||
cb(err);
|
cb(err);
|
||||||
};
|
};
|
||||||
78
node_modules/readable-stream/lib/internal/streams/BufferList.js
generated
vendored
78
node_modules/readable-stream/lib/internal/streams/BufferList.js
generated
vendored
@ -1,78 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
||||||
|
|
||||||
var Buffer = require('safe-buffer').Buffer;
|
|
||||||
var util = require('util');
|
|
||||||
|
|
||||||
function copyBuffer(src, target, offset) {
|
|
||||||
src.copy(target, offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = function () {
|
|
||||||
function BufferList() {
|
|
||||||
_classCallCheck(this, BufferList);
|
|
||||||
|
|
||||||
this.head = null;
|
|
||||||
this.tail = null;
|
|
||||||
this.length = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
BufferList.prototype.push = function push(v) {
|
|
||||||
var entry = { data: v, next: null };
|
|
||||||
if (this.length > 0) this.tail.next = entry;else this.head = entry;
|
|
||||||
this.tail = entry;
|
|
||||||
++this.length;
|
|
||||||
};
|
|
||||||
|
|
||||||
BufferList.prototype.unshift = function unshift(v) {
|
|
||||||
var entry = { data: v, next: this.head };
|
|
||||||
if (this.length === 0) this.tail = entry;
|
|
||||||
this.head = entry;
|
|
||||||
++this.length;
|
|
||||||
};
|
|
||||||
|
|
||||||
BufferList.prototype.shift = function shift() {
|
|
||||||
if (this.length === 0) return;
|
|
||||||
var ret = this.head.data;
|
|
||||||
if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
|
|
||||||
--this.length;
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
BufferList.prototype.clear = function clear() {
|
|
||||||
this.head = this.tail = null;
|
|
||||||
this.length = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
BufferList.prototype.join = function join(s) {
|
|
||||||
if (this.length === 0) return '';
|
|
||||||
var p = this.head;
|
|
||||||
var ret = '' + p.data;
|
|
||||||
while (p = p.next) {
|
|
||||||
ret += s + p.data;
|
|
||||||
}return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
BufferList.prototype.concat = function concat(n) {
|
|
||||||
if (this.length === 0) return Buffer.alloc(0);
|
|
||||||
var ret = Buffer.allocUnsafe(n >>> 0);
|
|
||||||
var p = this.head;
|
|
||||||
var i = 0;
|
|
||||||
while (p) {
|
|
||||||
copyBuffer(p.data, ret, i);
|
|
||||||
i += p.data.length;
|
|
||||||
p = p.next;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
return BufferList;
|
|
||||||
}();
|
|
||||||
|
|
||||||
if (util && util.inspect && util.inspect.custom) {
|
|
||||||
module.exports.prototype[util.inspect.custom] = function () {
|
|
||||||
var obj = util.inspect({ length: this.length });
|
|
||||||
return this.constructor.name + ' ' + obj;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
48
node_modules/readable-stream/lib/internal/streams/destroy.js
generated
vendored
48
node_modules/readable-stream/lib/internal/streams/destroy.js
generated
vendored
@ -1,29 +1,21 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/*<replacement>*/
|
|
||||||
|
|
||||||
var pna = require('process-nextick-args');
|
|
||||||
/*</replacement>*/
|
|
||||||
|
|
||||||
// undocumented cb() API, needed for core, not for public API
|
// undocumented cb() API, needed for core, not for public API
|
||||||
function destroy(err, cb) {
|
function destroy(err, cb) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
|
|
||||||
var readableDestroyed = this._readableState && this._readableState.destroyed;
|
var readableDestroyed = this._readableState && this._readableState.destroyed;
|
||||||
var writableDestroyed = this._writableState && this._writableState.destroyed;
|
var writableDestroyed = this._writableState && this._writableState.destroyed;
|
||||||
|
|
||||||
if (readableDestroyed || writableDestroyed) {
|
if (readableDestroyed || writableDestroyed) {
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb(err);
|
cb(err);
|
||||||
} else if (err) {
|
} else if (err) {
|
||||||
if (!this._writableState) {
|
if (!this._writableState) {
|
||||||
pna.nextTick(emitErrorNT, this, err);
|
process.nextTick(emitErrorNT, this, err);
|
||||||
} else if (!this._writableState.errorEmitted) {
|
} else if (!this._writableState.errorEmitted) {
|
||||||
this._writableState.errorEmitted = true;
|
this._writableState.errorEmitted = true;
|
||||||
pna.nextTick(emitErrorNT, this, err);
|
process.nextTick(emitErrorNT, this, err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,23 +30,34 @@ function destroy(err, cb) {
|
|||||||
if (this._writableState) {
|
if (this._writableState) {
|
||||||
this._writableState.destroyed = true;
|
this._writableState.destroyed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._destroy(err || null, function (err) {
|
this._destroy(err || null, function (err) {
|
||||||
if (!cb && err) {
|
if (!cb && err) {
|
||||||
if (!_this._writableState) {
|
if (!_this._writableState) {
|
||||||
pna.nextTick(emitErrorNT, _this, err);
|
process.nextTick(emitErrorAndCloseNT, _this, err);
|
||||||
} else if (!_this._writableState.errorEmitted) {
|
} else if (!_this._writableState.errorEmitted) {
|
||||||
_this._writableState.errorEmitted = true;
|
_this._writableState.errorEmitted = true;
|
||||||
pna.nextTick(emitErrorNT, _this, err);
|
process.nextTick(emitErrorAndCloseNT, _this, err);
|
||||||
|
} else {
|
||||||
|
process.nextTick(emitCloseNT, _this);
|
||||||
}
|
}
|
||||||
} else if (cb) {
|
} else if (cb) {
|
||||||
|
process.nextTick(emitCloseNT, _this);
|
||||||
cb(err);
|
cb(err);
|
||||||
|
} else {
|
||||||
|
process.nextTick(emitCloseNT, _this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
function emitErrorAndCloseNT(self, err) {
|
||||||
|
emitErrorNT(self, err);
|
||||||
|
emitCloseNT(self);
|
||||||
|
}
|
||||||
|
function emitCloseNT(self) {
|
||||||
|
if (self._writableState && !self._writableState.emitClose) return;
|
||||||
|
if (self._readableState && !self._readableState.emitClose) return;
|
||||||
|
self.emit('close');
|
||||||
|
}
|
||||||
function undestroy() {
|
function undestroy() {
|
||||||
if (this._readableState) {
|
if (this._readableState) {
|
||||||
this._readableState.destroyed = false;
|
this._readableState.destroyed = false;
|
||||||
@ -62,7 +65,6 @@ function undestroy() {
|
|||||||
this._readableState.ended = false;
|
this._readableState.ended = false;
|
||||||
this._readableState.endEmitted = false;
|
this._readableState.endEmitted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._writableState) {
|
if (this._writableState) {
|
||||||
this._writableState.destroyed = false;
|
this._writableState.destroyed = false;
|
||||||
this._writableState.ended = false;
|
this._writableState.ended = false;
|
||||||
@ -73,12 +75,22 @@ function undestroy() {
|
|||||||
this._writableState.errorEmitted = false;
|
this._writableState.errorEmitted = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function emitErrorNT(self, err) {
|
function emitErrorNT(self, err) {
|
||||||
self.emit('error', err);
|
self.emit('error', err);
|
||||||
}
|
}
|
||||||
|
function errorOrDestroy(stream, err) {
|
||||||
|
// We have tests that rely on errors being emitted
|
||||||
|
// in the same tick, so changing this is semver major.
|
||||||
|
// For now when you opt-in to autoDestroy we allow
|
||||||
|
// the error to be emitted nextTick. In a future
|
||||||
|
// semver major update we should change the default to this.
|
||||||
|
|
||||||
|
var rState = stream._readableState;
|
||||||
|
var wState = stream._writableState;
|
||||||
|
if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);
|
||||||
|
}
|
||||||
module.exports = {
|
module.exports = {
|
||||||
destroy: destroy,
|
destroy: destroy,
|
||||||
undestroy: undestroy
|
undestroy: undestroy,
|
||||||
|
errorOrDestroy: errorOrDestroy
|
||||||
};
|
};
|
||||||
21
node_modules/readable-stream/node_modules/safe-buffer/LICENSE
generated
vendored
21
node_modules/readable-stream/node_modules/safe-buffer/LICENSE
generated
vendored
@ -1,21 +0,0 @@
|
|||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) Feross Aboukhadijeh
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
584
node_modules/readable-stream/node_modules/safe-buffer/README.md
generated
vendored
584
node_modules/readable-stream/node_modules/safe-buffer/README.md
generated
vendored
@ -1,584 +0,0 @@
|
|||||||
# safe-buffer [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
|
|
||||||
|
|
||||||
[travis-image]: https://img.shields.io/travis/feross/safe-buffer/master.svg
|
|
||||||
[travis-url]: https://travis-ci.org/feross/safe-buffer
|
|
||||||
[npm-image]: https://img.shields.io/npm/v/safe-buffer.svg
|
|
||||||
[npm-url]: https://npmjs.org/package/safe-buffer
|
|
||||||
[downloads-image]: https://img.shields.io/npm/dm/safe-buffer.svg
|
|
||||||
[downloads-url]: https://npmjs.org/package/safe-buffer
|
|
||||||
[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
|
|
||||||
[standard-url]: https://standardjs.com
|
|
||||||
|
|
||||||
#### Safer Node.js Buffer API
|
|
||||||
|
|
||||||
**Use the new Node.js Buffer APIs (`Buffer.from`, `Buffer.alloc`,
|
|
||||||
`Buffer.allocUnsafe`, `Buffer.allocUnsafeSlow`) in all versions of Node.js.**
|
|
||||||
|
|
||||||
**Uses the built-in implementation when available.**
|
|
||||||
|
|
||||||
## install
|
|
||||||
|
|
||||||
```
|
|
||||||
npm install safe-buffer
|
|
||||||
```
|
|
||||||
|
|
||||||
## usage
|
|
||||||
|
|
||||||
The goal of this package is to provide a safe replacement for the node.js `Buffer`.
|
|
||||||
|
|
||||||
It's a drop-in replacement for `Buffer`. You can use it by adding one `require` line to
|
|
||||||
the top of your node.js modules:
|
|
||||||
|
|
||||||
```js
|
|
||||||
var Buffer = require('safe-buffer').Buffer
|
|
||||||
|
|
||||||
// Existing buffer code will continue to work without issues:
|
|
||||||
|
|
||||||
new Buffer('hey', 'utf8')
|
|
||||||
new Buffer([1, 2, 3], 'utf8')
|
|
||||||
new Buffer(obj)
|
|
||||||
new Buffer(16) // create an uninitialized buffer (potentially unsafe)
|
|
||||||
|
|
||||||
// But you can use these new explicit APIs to make clear what you want:
|
|
||||||
|
|
||||||
Buffer.from('hey', 'utf8') // convert from many types to a Buffer
|
|
||||||
Buffer.alloc(16) // create a zero-filled buffer (safe)
|
|
||||||
Buffer.allocUnsafe(16) // create an uninitialized buffer (potentially unsafe)
|
|
||||||
```
|
|
||||||
|
|
||||||
## api
|
|
||||||
|
|
||||||
### Class Method: Buffer.from(array)
|
|
||||||
<!-- YAML
|
|
||||||
added: v3.0.0
|
|
||||||
-->
|
|
||||||
|
|
||||||
* `array` {Array}
|
|
||||||
|
|
||||||
Allocates a new `Buffer` using an `array` of octets.
|
|
||||||
|
|
||||||
```js
|
|
||||||
const buf = Buffer.from([0x62,0x75,0x66,0x66,0x65,0x72]);
|
|
||||||
// creates a new Buffer containing ASCII bytes
|
|
||||||
// ['b','u','f','f','e','r']
|
|
||||||
```
|
|
||||||
|
|
||||||
A `TypeError` will be thrown if `array` is not an `Array`.
|
|
||||||
|
|
||||||
### Class Method: Buffer.from(arrayBuffer[, byteOffset[, length]])
|
|
||||||
<!-- YAML
|
|
||||||
added: v5.10.0
|
|
||||||
-->
|
|
||||||
|
|
||||||
* `arrayBuffer` {ArrayBuffer} The `.buffer` property of a `TypedArray` or
|
|
||||||
a `new ArrayBuffer()`
|
|
||||||
* `byteOffset` {Number} Default: `0`
|
|
||||||
* `length` {Number} Default: `arrayBuffer.length - byteOffset`
|
|
||||||
|
|
||||||
When passed a reference to the `.buffer` property of a `TypedArray` instance,
|
|
||||||
the newly created `Buffer` will share the same allocated memory as the
|
|
||||||
TypedArray.
|
|
||||||
|
|
||||||
```js
|
|
||||||
const arr = new Uint16Array(2);
|
|
||||||
arr[0] = 5000;
|
|
||||||
arr[1] = 4000;
|
|
||||||
|
|
||||||
const buf = Buffer.from(arr.buffer); // shares the memory with arr;
|
|
||||||
|
|
||||||
console.log(buf);
|
|
||||||
// Prints: <Buffer 88 13 a0 0f>
|
|
||||||
|
|
||||||
// changing the TypedArray changes the Buffer also
|
|
||||||
arr[1] = 6000;
|
|
||||||
|
|
||||||
console.log(buf);
|
|
||||||
// Prints: <Buffer 88 13 70 17>
|
|
||||||
```
|
|
||||||
|
|
||||||
The optional `byteOffset` and `length` arguments specify a memory range within
|
|
||||||
the `arrayBuffer` that will be shared by the `Buffer`.
|
|
||||||
|
|
||||||
```js
|
|
||||||
const ab = new ArrayBuffer(10);
|
|
||||||
const buf = Buffer.from(ab, 0, 2);
|
|
||||||
console.log(buf.length);
|
|
||||||
// Prints: 2
|
|
||||||
```
|
|
||||||
|
|
||||||
A `TypeError` will be thrown if `arrayBuffer` is not an `ArrayBuffer`.
|
|
||||||
|
|
||||||
### Class Method: Buffer.from(buffer)
|
|
||||||
<!-- YAML
|
|
||||||
added: v3.0.0
|
|
||||||
-->
|
|
||||||
|
|
||||||
* `buffer` {Buffer}
|
|
||||||
|
|
||||||
Copies the passed `buffer` data onto a new `Buffer` instance.
|
|
||||||
|
|
||||||
```js
|
|
||||||
const buf1 = Buffer.from('buffer');
|
|
||||||
const buf2 = Buffer.from(buf1);
|
|
||||||
|
|
||||||
buf1[0] = 0x61;
|
|
||||||
console.log(buf1.toString());
|
|
||||||
// 'auffer'
|
|
||||||
console.log(buf2.toString());
|
|
||||||
// 'buffer' (copy is not changed)
|
|
||||||
```
|
|
||||||
|
|
||||||
A `TypeError` will be thrown if `buffer` is not a `Buffer`.
|
|
||||||
|
|
||||||
### Class Method: Buffer.from(str[, encoding])
|
|
||||||
<!-- YAML
|
|
||||||
added: v5.10.0
|
|
||||||
-->
|
|
||||||
|
|
||||||
* `str` {String} String to encode.
|
|
||||||
* `encoding` {String} Encoding to use, Default: `'utf8'`
|
|
||||||
|
|
||||||
Creates a new `Buffer` containing the given JavaScript string `str`. If
|
|
||||||
provided, the `encoding` parameter identifies the character encoding.
|
|
||||||
If not provided, `encoding` defaults to `'utf8'`.
|
|
||||||
|
|
||||||
```js
|
|
||||||
const buf1 = Buffer.from('this is a tést');
|
|
||||||
console.log(buf1.toString());
|
|
||||||
// prints: this is a tést
|
|
||||||
console.log(buf1.toString('ascii'));
|
|
||||||
// prints: this is a tC)st
|
|
||||||
|
|
||||||
const buf2 = Buffer.from('7468697320697320612074c3a97374', 'hex');
|
|
||||||
console.log(buf2.toString());
|
|
||||||
// prints: this is a tést
|
|
||||||
```
|
|
||||||
|
|
||||||
A `TypeError` will be thrown if `str` is not a string.
|
|
||||||
|
|
||||||
### Class Method: Buffer.alloc(size[, fill[, encoding]])
|
|
||||||
<!-- YAML
|
|
||||||
added: v5.10.0
|
|
||||||
-->
|
|
||||||
|
|
||||||
* `size` {Number}
|
|
||||||
* `fill` {Value} Default: `undefined`
|
|
||||||
* `encoding` {String} Default: `utf8`
|
|
||||||
|
|
||||||
Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the
|
|
||||||
`Buffer` will be *zero-filled*.
|
|
||||||
|
|
||||||
```js
|
|
||||||
const buf = Buffer.alloc(5);
|
|
||||||
console.log(buf);
|
|
||||||
// <Buffer 00 00 00 00 00>
|
|
||||||
```
|
|
||||||
|
|
||||||
The `size` must be less than or equal to the value of
|
|
||||||
`require('buffer').kMaxLength` (on 64-bit architectures, `kMaxLength` is
|
|
||||||
`(2^31)-1`). Otherwise, a [`RangeError`][] is thrown. A zero-length Buffer will
|
|
||||||
be created if a `size` less than or equal to 0 is specified.
|
|
||||||
|
|
||||||
If `fill` is specified, the allocated `Buffer` will be initialized by calling
|
|
||||||
`buf.fill(fill)`. See [`buf.fill()`][] for more information.
|
|
||||||
|
|
||||||
```js
|
|
||||||
const buf = Buffer.alloc(5, 'a');
|
|
||||||
console.log(buf);
|
|
||||||
// <Buffer 61 61 61 61 61>
|
|
||||||
```
|
|
||||||
|
|
||||||
If both `fill` and `encoding` are specified, the allocated `Buffer` will be
|
|
||||||
initialized by calling `buf.fill(fill, encoding)`. For example:
|
|
||||||
|
|
||||||
```js
|
|
||||||
const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64');
|
|
||||||
console.log(buf);
|
|
||||||
// <Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64>
|
|
||||||
```
|
|
||||||
|
|
||||||
Calling `Buffer.alloc(size)` can be significantly slower than the alternative
|
|
||||||
`Buffer.allocUnsafe(size)` but ensures that the newly created `Buffer` instance
|
|
||||||
contents will *never contain sensitive data*.
|
|
||||||
|
|
||||||
A `TypeError` will be thrown if `size` is not a number.
|
|
||||||
|
|
||||||
### Class Method: Buffer.allocUnsafe(size)
|
|
||||||
<!-- YAML
|
|
||||||
added: v5.10.0
|
|
||||||
-->
|
|
||||||
|
|
||||||
* `size` {Number}
|
|
||||||
|
|
||||||
Allocates a new *non-zero-filled* `Buffer` of `size` bytes. The `size` must
|
|
||||||
be less than or equal to the value of `require('buffer').kMaxLength` (on 64-bit
|
|
||||||
architectures, `kMaxLength` is `(2^31)-1`). Otherwise, a [`RangeError`][] is
|
|
||||||
thrown. A zero-length Buffer will be created if a `size` less than or equal to
|
|
||||||
0 is specified.
|
|
||||||
|
|
||||||
The underlying memory for `Buffer` instances created in this way is *not
|
|
||||||
initialized*. The contents of the newly created `Buffer` are unknown and
|
|
||||||
*may contain sensitive data*. Use [`buf.fill(0)`][] to initialize such
|
|
||||||
`Buffer` instances to zeroes.
|
|
||||||
|
|
||||||
```js
|
|
||||||
const buf = Buffer.allocUnsafe(5);
|
|
||||||
console.log(buf);
|
|
||||||
// <Buffer 78 e0 82 02 01>
|
|
||||||
// (octets will be different, every time)
|
|
||||||
buf.fill(0);
|
|
||||||
console.log(buf);
|
|
||||||
// <Buffer 00 00 00 00 00>
|
|
||||||
```
|
|
||||||
|
|
||||||
A `TypeError` will be thrown if `size` is not a number.
|
|
||||||
|
|
||||||
Note that the `Buffer` module pre-allocates an internal `Buffer` instance of
|
|
||||||
size `Buffer.poolSize` that is used as a pool for the fast allocation of new
|
|
||||||
`Buffer` instances created using `Buffer.allocUnsafe(size)` (and the deprecated
|
|
||||||
`new Buffer(size)` constructor) only when `size` is less than or equal to
|
|
||||||
`Buffer.poolSize >> 1` (floor of `Buffer.poolSize` divided by two). The default
|
|
||||||
value of `Buffer.poolSize` is `8192` but can be modified.
|
|
||||||
|
|
||||||
Use of this pre-allocated internal memory pool is a key difference between
|
|
||||||
calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`.
|
|
||||||
Specifically, `Buffer.alloc(size, fill)` will *never* use the internal Buffer
|
|
||||||
pool, while `Buffer.allocUnsafe(size).fill(fill)` *will* use the internal
|
|
||||||
Buffer pool if `size` is less than or equal to half `Buffer.poolSize`. The
|
|
||||||
difference is subtle but can be important when an application requires the
|
|
||||||
additional performance that `Buffer.allocUnsafe(size)` provides.
|
|
||||||
|
|
||||||
### Class Method: Buffer.allocUnsafeSlow(size)
|
|
||||||
<!-- YAML
|
|
||||||
added: v5.10.0
|
|
||||||
-->
|
|
||||||
|
|
||||||
* `size` {Number}
|
|
||||||
|
|
||||||
Allocates a new *non-zero-filled* and non-pooled `Buffer` of `size` bytes. The
|
|
||||||
`size` must be less than or equal to the value of
|
|
||||||
`require('buffer').kMaxLength` (on 64-bit architectures, `kMaxLength` is
|
|
||||||
`(2^31)-1`). Otherwise, a [`RangeError`][] is thrown. A zero-length Buffer will
|
|
||||||
be created if a `size` less than or equal to 0 is specified.
|
|
||||||
|
|
||||||
The underlying memory for `Buffer` instances created in this way is *not
|
|
||||||
initialized*. The contents of the newly created `Buffer` are unknown and
|
|
||||||
*may contain sensitive data*. Use [`buf.fill(0)`][] to initialize such
|
|
||||||
`Buffer` instances to zeroes.
|
|
||||||
|
|
||||||
When using `Buffer.allocUnsafe()` to allocate new `Buffer` instances,
|
|
||||||
allocations under 4KB are, by default, sliced from a single pre-allocated
|
|
||||||
`Buffer`. This allows applications to avoid the garbage collection overhead of
|
|
||||||
creating many individually allocated Buffers. This approach improves both
|
|
||||||
performance and memory usage by eliminating the need to track and cleanup as
|
|
||||||
many `Persistent` objects.
|
|
||||||
|
|
||||||
However, in the case where a developer may need to retain a small chunk of
|
|
||||||
memory from a pool for an indeterminate amount of time, it may be appropriate
|
|
||||||
to create an un-pooled Buffer instance using `Buffer.allocUnsafeSlow()` then
|
|
||||||
copy out the relevant bits.
|
|
||||||
|
|
||||||
```js
|
|
||||||
// need to keep around a few small chunks of memory
|
|
||||||
const store = [];
|
|
||||||
|
|
||||||
socket.on('readable', () => {
|
|
||||||
const data = socket.read();
|
|
||||||
// allocate for retained data
|
|
||||||
const sb = Buffer.allocUnsafeSlow(10);
|
|
||||||
// copy the data into the new allocation
|
|
||||||
data.copy(sb, 0, 0, 10);
|
|
||||||
store.push(sb);
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
Use of `Buffer.allocUnsafeSlow()` should be used only as a last resort *after*
|
|
||||||
a developer has observed undue memory retention in their applications.
|
|
||||||
|
|
||||||
A `TypeError` will be thrown if `size` is not a number.
|
|
||||||
|
|
||||||
### All the Rest
|
|
||||||
|
|
||||||
The rest of the `Buffer` API is exactly the same as in node.js.
|
|
||||||
[See the docs](https://nodejs.org/api/buffer.html).
|
|
||||||
|
|
||||||
|
|
||||||
## Related links
|
|
||||||
|
|
||||||
- [Node.js issue: Buffer(number) is unsafe](https://github.com/nodejs/node/issues/4660)
|
|
||||||
- [Node.js Enhancement Proposal: Buffer.from/Buffer.alloc/Buffer.zalloc/Buffer() soft-deprecate](https://github.com/nodejs/node-eps/pull/4)
|
|
||||||
|
|
||||||
## Why is `Buffer` unsafe?
|
|
||||||
|
|
||||||
Today, the node.js `Buffer` constructor is overloaded to handle many different argument
|
|
||||||
types like `String`, `Array`, `Object`, `TypedArrayView` (`Uint8Array`, etc.),
|
|
||||||
`ArrayBuffer`, and also `Number`.
|
|
||||||
|
|
||||||
The API is optimized for convenience: you can throw any type at it, and it will try to do
|
|
||||||
what you want.
|
|
||||||
|
|
||||||
Because the Buffer constructor is so powerful, you often see code like this:
|
|
||||||
|
|
||||||
```js
|
|
||||||
// Convert UTF-8 strings to hex
|
|
||||||
function toHex (str) {
|
|
||||||
return new Buffer(str).toString('hex')
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
***But what happens if `toHex` is called with a `Number` argument?***
|
|
||||||
|
|
||||||
### Remote Memory Disclosure
|
|
||||||
|
|
||||||
If an attacker can make your program call the `Buffer` constructor with a `Number`
|
|
||||||
argument, then they can make it allocate uninitialized memory from the node.js process.
|
|
||||||
This could potentially disclose TLS private keys, user data, or database passwords.
|
|
||||||
|
|
||||||
When the `Buffer` constructor is passed a `Number` argument, it returns an
|
|
||||||
**UNINITIALIZED** block of memory of the specified `size`. When you create a `Buffer` like
|
|
||||||
this, you **MUST** overwrite the contents before returning it to the user.
|
|
||||||
|
|
||||||
From the [node.js docs](https://nodejs.org/api/buffer.html#buffer_new_buffer_size):
|
|
||||||
|
|
||||||
> `new Buffer(size)`
|
|
||||||
>
|
|
||||||
> - `size` Number
|
|
||||||
>
|
|
||||||
> The underlying memory for `Buffer` instances created in this way is not initialized.
|
|
||||||
> **The contents of a newly created `Buffer` are unknown and could contain sensitive
|
|
||||||
> data.** Use `buf.fill(0)` to initialize a Buffer to zeroes.
|
|
||||||
|
|
||||||
(Emphasis our own.)
|
|
||||||
|
|
||||||
Whenever the programmer intended to create an uninitialized `Buffer` you often see code
|
|
||||||
like this:
|
|
||||||
|
|
||||||
```js
|
|
||||||
var buf = new Buffer(16)
|
|
||||||
|
|
||||||
// Immediately overwrite the uninitialized buffer with data from another buffer
|
|
||||||
for (var i = 0; i < buf.length; i++) {
|
|
||||||
buf[i] = otherBuf[i]
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
### Would this ever be a problem in real code?
|
|
||||||
|
|
||||||
Yes. It's surprisingly common to forget to check the type of your variables in a
|
|
||||||
dynamically-typed language like JavaScript.
|
|
||||||
|
|
||||||
Usually the consequences of assuming the wrong type is that your program crashes with an
|
|
||||||
uncaught exception. But the failure mode for forgetting to check the type of arguments to
|
|
||||||
the `Buffer` constructor is more catastrophic.
|
|
||||||
|
|
||||||
Here's an example of a vulnerable service that takes a JSON payload and converts it to
|
|
||||||
hex:
|
|
||||||
|
|
||||||
```js
|
|
||||||
// Take a JSON payload {str: "some string"} and convert it to hex
|
|
||||||
var server = http.createServer(function (req, res) {
|
|
||||||
var data = ''
|
|
||||||
req.setEncoding('utf8')
|
|
||||||
req.on('data', function (chunk) {
|
|
||||||
data += chunk
|
|
||||||
})
|
|
||||||
req.on('end', function () {
|
|
||||||
var body = JSON.parse(data)
|
|
||||||
res.end(new Buffer(body.str).toString('hex'))
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
server.listen(8080)
|
|
||||||
```
|
|
||||||
|
|
||||||
In this example, an http client just has to send:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"str": 1000
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
and it will get back 1,000 bytes of uninitialized memory from the server.
|
|
||||||
|
|
||||||
This is a very serious bug. It's similar in severity to the
|
|
||||||
[the Heartbleed bug](http://heartbleed.com/) that allowed disclosure of OpenSSL process
|
|
||||||
memory by remote attackers.
|
|
||||||
|
|
||||||
|
|
||||||
### Which real-world packages were vulnerable?
|
|
||||||
|
|
||||||
#### [`bittorrent-dht`](https://www.npmjs.com/package/bittorrent-dht)
|
|
||||||
|
|
||||||
[Mathias Buus](https://github.com/mafintosh) and I
|
|
||||||
([Feross Aboukhadijeh](http://feross.org/)) found this issue in one of our own packages,
|
|
||||||
[`bittorrent-dht`](https://www.npmjs.com/package/bittorrent-dht). The bug would allow
|
|
||||||
anyone on the internet to send a series of messages to a user of `bittorrent-dht` and get
|
|
||||||
them to reveal 20 bytes at a time of uninitialized memory from the node.js process.
|
|
||||||
|
|
||||||
Here's
|
|
||||||
[the commit](https://github.com/feross/bittorrent-dht/commit/6c7da04025d5633699800a99ec3fbadf70ad35b8)
|
|
||||||
that fixed it. We released a new fixed version, created a
|
|
||||||
[Node Security Project disclosure](https://nodesecurity.io/advisories/68), and deprecated all
|
|
||||||
vulnerable versions on npm so users will get a warning to upgrade to a newer version.
|
|
||||||
|
|
||||||
#### [`ws`](https://www.npmjs.com/package/ws)
|
|
||||||
|
|
||||||
That got us wondering if there were other vulnerable packages. Sure enough, within a short
|
|
||||||
period of time, we found the same issue in [`ws`](https://www.npmjs.com/package/ws), the
|
|
||||||
most popular WebSocket implementation in node.js.
|
|
||||||
|
|
||||||
If certain APIs were called with `Number` parameters instead of `String` or `Buffer` as
|
|
||||||
expected, then uninitialized server memory would be disclosed to the remote peer.
|
|
||||||
|
|
||||||
These were the vulnerable methods:
|
|
||||||
|
|
||||||
```js
|
|
||||||
socket.send(number)
|
|
||||||
socket.ping(number)
|
|
||||||
socket.pong(number)
|
|
||||||
```
|
|
||||||
|
|
||||||
Here's a vulnerable socket server with some echo functionality:
|
|
||||||
|
|
||||||
```js
|
|
||||||
server.on('connection', function (socket) {
|
|
||||||
socket.on('message', function (message) {
|
|
||||||
message = JSON.parse(message)
|
|
||||||
if (message.type === 'echo') {
|
|
||||||
socket.send(message.data) // send back the user's message
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
`socket.send(number)` called on the server, will disclose server memory.
|
|
||||||
|
|
||||||
Here's [the release](https://github.com/websockets/ws/releases/tag/1.0.1) where the issue
|
|
||||||
was fixed, with a more detailed explanation. Props to
|
|
||||||
[Arnout Kazemier](https://github.com/3rd-Eden) for the quick fix. Here's the
|
|
||||||
[Node Security Project disclosure](https://nodesecurity.io/advisories/67).
|
|
||||||
|
|
||||||
|
|
||||||
### What's the solution?
|
|
||||||
|
|
||||||
It's important that node.js offers a fast way to get memory otherwise performance-critical
|
|
||||||
applications would needlessly get a lot slower.
|
|
||||||
|
|
||||||
But we need a better way to *signal our intent* as programmers. **When we want
|
|
||||||
uninitialized memory, we should request it explicitly.**
|
|
||||||
|
|
||||||
Sensitive functionality should not be packed into a developer-friendly API that loosely
|
|
||||||
accepts many different types. This type of API encourages the lazy practice of passing
|
|
||||||
variables in without checking the type very carefully.
|
|
||||||
|
|
||||||
#### A new API: `Buffer.allocUnsafe(number)`
|
|
||||||
|
|
||||||
The functionality of creating buffers with uninitialized memory should be part of another
|
|
||||||
API. We propose `Buffer.allocUnsafe(number)`. This way, it's not part of an API that
|
|
||||||
frequently gets user input of all sorts of different types passed into it.
|
|
||||||
|
|
||||||
```js
|
|
||||||
var buf = Buffer.allocUnsafe(16) // careful, uninitialized memory!
|
|
||||||
|
|
||||||
// Immediately overwrite the uninitialized buffer with data from another buffer
|
|
||||||
for (var i = 0; i < buf.length; i++) {
|
|
||||||
buf[i] = otherBuf[i]
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
### How do we fix node.js core?
|
|
||||||
|
|
||||||
We sent [a PR to node.js core](https://github.com/nodejs/node/pull/4514) (merged as
|
|
||||||
`semver-major`) which defends against one case:
|
|
||||||
|
|
||||||
```js
|
|
||||||
var str = 16
|
|
||||||
new Buffer(str, 'utf8')
|
|
||||||
```
|
|
||||||
|
|
||||||
In this situation, it's implied that the programmer intended the first argument to be a
|
|
||||||
string, since they passed an encoding as a second argument. Today, node.js will allocate
|
|
||||||
uninitialized memory in the case of `new Buffer(number, encoding)`, which is probably not
|
|
||||||
what the programmer intended.
|
|
||||||
|
|
||||||
But this is only a partial solution, since if the programmer does `new Buffer(variable)`
|
|
||||||
(without an `encoding` parameter) there's no way to know what they intended. If `variable`
|
|
||||||
is sometimes a number, then uninitialized memory will sometimes be returned.
|
|
||||||
|
|
||||||
### What's the real long-term fix?
|
|
||||||
|
|
||||||
We could deprecate and remove `new Buffer(number)` and use `Buffer.allocUnsafe(number)` when
|
|
||||||
we need uninitialized memory. But that would break 1000s of packages.
|
|
||||||
|
|
||||||
~~We believe the best solution is to:~~
|
|
||||||
|
|
||||||
~~1. Change `new Buffer(number)` to return safe, zeroed-out memory~~
|
|
||||||
|
|
||||||
~~2. Create a new API for creating uninitialized Buffers. We propose: `Buffer.allocUnsafe(number)`~~
|
|
||||||
|
|
||||||
#### Update
|
|
||||||
|
|
||||||
We now support adding three new APIs:
|
|
||||||
|
|
||||||
- `Buffer.from(value)` - convert from any type to a buffer
|
|
||||||
- `Buffer.alloc(size)` - create a zero-filled buffer
|
|
||||||
- `Buffer.allocUnsafe(size)` - create an uninitialized buffer with given size
|
|
||||||
|
|
||||||
This solves the core problem that affected `ws` and `bittorrent-dht` which is
|
|
||||||
`Buffer(variable)` getting tricked into taking a number argument.
|
|
||||||
|
|
||||||
This way, existing code continues working and the impact on the npm ecosystem will be
|
|
||||||
minimal. Over time, npm maintainers can migrate performance-critical code to use
|
|
||||||
`Buffer.allocUnsafe(number)` instead of `new Buffer(number)`.
|
|
||||||
|
|
||||||
|
|
||||||
### Conclusion
|
|
||||||
|
|
||||||
We think there's a serious design issue with the `Buffer` API as it exists today. It
|
|
||||||
promotes insecure software by putting high-risk functionality into a convenient API
|
|
||||||
with friendly "developer ergonomics".
|
|
||||||
|
|
||||||
This wasn't merely a theoretical exercise because we found the issue in some of the
|
|
||||||
most popular npm packages.
|
|
||||||
|
|
||||||
Fortunately, there's an easy fix that can be applied today. Use `safe-buffer` in place of
|
|
||||||
`buffer`.
|
|
||||||
|
|
||||||
```js
|
|
||||||
var Buffer = require('safe-buffer').Buffer
|
|
||||||
```
|
|
||||||
|
|
||||||
Eventually, we hope that node.js core can switch to this new, safer behavior. We believe
|
|
||||||
the impact on the ecosystem would be minimal since it's not a breaking change.
|
|
||||||
Well-maintained, popular packages would be updated to use `Buffer.alloc` quickly, while
|
|
||||||
older, insecure packages would magically become safe from this attack vector.
|
|
||||||
|
|
||||||
|
|
||||||
## links
|
|
||||||
|
|
||||||
- [Node.js PR: buffer: throw if both length and enc are passed](https://github.com/nodejs/node/pull/4514)
|
|
||||||
- [Node Security Project disclosure for `ws`](https://nodesecurity.io/advisories/67)
|
|
||||||
- [Node Security Project disclosure for`bittorrent-dht`](https://nodesecurity.io/advisories/68)
|
|
||||||
|
|
||||||
|
|
||||||
## credit
|
|
||||||
|
|
||||||
The original issues in `bittorrent-dht`
|
|
||||||
([disclosure](https://nodesecurity.io/advisories/68)) and
|
|
||||||
`ws` ([disclosure](https://nodesecurity.io/advisories/67)) were discovered by
|
|
||||||
[Mathias Buus](https://github.com/mafintosh) and
|
|
||||||
[Feross Aboukhadijeh](http://feross.org/).
|
|
||||||
|
|
||||||
Thanks to [Adam Baldwin](https://github.com/evilpacket) for helping disclose these issues
|
|
||||||
and for his work running the [Node Security Project](https://nodesecurity.io/).
|
|
||||||
|
|
||||||
Thanks to [John Hiesey](https://github.com/jhiesey) for proofreading this README and
|
|
||||||
auditing the code.
|
|
||||||
|
|
||||||
|
|
||||||
## license
|
|
||||||
|
|
||||||
MIT. Copyright (C) [Feross Aboukhadijeh](http://feross.org)
|
|
||||||
187
node_modules/readable-stream/node_modules/safe-buffer/index.d.ts
generated
vendored
187
node_modules/readable-stream/node_modules/safe-buffer/index.d.ts
generated
vendored
@ -1,187 +0,0 @@
|
|||||||
declare module "safe-buffer" {
|
|
||||||
export class Buffer {
|
|
||||||
length: number
|
|
||||||
write(string: string, offset?: number, length?: number, encoding?: string): number;
|
|
||||||
toString(encoding?: string, start?: number, end?: number): string;
|
|
||||||
toJSON(): { type: 'Buffer', data: any[] };
|
|
||||||
equals(otherBuffer: Buffer): boolean;
|
|
||||||
compare(otherBuffer: Buffer, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number;
|
|
||||||
copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
|
|
||||||
slice(start?: number, end?: number): Buffer;
|
|
||||||
writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
|
|
||||||
writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
|
|
||||||
writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
|
|
||||||
writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
|
|
||||||
readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
|
|
||||||
readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
|
|
||||||
readIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
|
|
||||||
readIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
|
|
||||||
readUInt8(offset: number, noAssert?: boolean): number;
|
|
||||||
readUInt16LE(offset: number, noAssert?: boolean): number;
|
|
||||||
readUInt16BE(offset: number, noAssert?: boolean): number;
|
|
||||||
readUInt32LE(offset: number, noAssert?: boolean): number;
|
|
||||||
readUInt32BE(offset: number, noAssert?: boolean): number;
|
|
||||||
readInt8(offset: number, noAssert?: boolean): number;
|
|
||||||
readInt16LE(offset: number, noAssert?: boolean): number;
|
|
||||||
readInt16BE(offset: number, noAssert?: boolean): number;
|
|
||||||
readInt32LE(offset: number, noAssert?: boolean): number;
|
|
||||||
readInt32BE(offset: number, noAssert?: boolean): number;
|
|
||||||
readFloatLE(offset: number, noAssert?: boolean): number;
|
|
||||||
readFloatBE(offset: number, noAssert?: boolean): number;
|
|
||||||
readDoubleLE(offset: number, noAssert?: boolean): number;
|
|
||||||
readDoubleBE(offset: number, noAssert?: boolean): number;
|
|
||||||
swap16(): Buffer;
|
|
||||||
swap32(): Buffer;
|
|
||||||
swap64(): Buffer;
|
|
||||||
writeUInt8(value: number, offset: number, noAssert?: boolean): number;
|
|
||||||
writeUInt16LE(value: number, offset: number, noAssert?: boolean): number;
|
|
||||||
writeUInt16BE(value: number, offset: number, noAssert?: boolean): number;
|
|
||||||
writeUInt32LE(value: number, offset: number, noAssert?: boolean): number;
|
|
||||||
writeUInt32BE(value: number, offset: number, noAssert?: boolean): number;
|
|
||||||
writeInt8(value: number, offset: number, noAssert?: boolean): number;
|
|
||||||
writeInt16LE(value: number, offset: number, noAssert?: boolean): number;
|
|
||||||
writeInt16BE(value: number, offset: number, noAssert?: boolean): number;
|
|
||||||
writeInt32LE(value: number, offset: number, noAssert?: boolean): number;
|
|
||||||
writeInt32BE(value: number, offset: number, noAssert?: boolean): number;
|
|
||||||
writeFloatLE(value: number, offset: number, noAssert?: boolean): number;
|
|
||||||
writeFloatBE(value: number, offset: number, noAssert?: boolean): number;
|
|
||||||
writeDoubleLE(value: number, offset: number, noAssert?: boolean): number;
|
|
||||||
writeDoubleBE(value: number, offset: number, noAssert?: boolean): number;
|
|
||||||
fill(value: any, offset?: number, end?: number): this;
|
|
||||||
indexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number;
|
|
||||||
lastIndexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number;
|
|
||||||
includes(value: string | number | Buffer, byteOffset?: number, encoding?: string): boolean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allocates a new buffer containing the given {str}.
|
|
||||||
*
|
|
||||||
* @param str String to store in buffer.
|
|
||||||
* @param encoding encoding to use, optional. Default is 'utf8'
|
|
||||||
*/
|
|
||||||
constructor (str: string, encoding?: string);
|
|
||||||
/**
|
|
||||||
* Allocates a new buffer of {size} octets.
|
|
||||||
*
|
|
||||||
* @param size count of octets to allocate.
|
|
||||||
*/
|
|
||||||
constructor (size: number);
|
|
||||||
/**
|
|
||||||
* Allocates a new buffer containing the given {array} of octets.
|
|
||||||
*
|
|
||||||
* @param array The octets to store.
|
|
||||||
*/
|
|
||||||
constructor (array: Uint8Array);
|
|
||||||
/**
|
|
||||||
* Produces a Buffer backed by the same allocated memory as
|
|
||||||
* the given {ArrayBuffer}.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param arrayBuffer The ArrayBuffer with which to share memory.
|
|
||||||
*/
|
|
||||||
constructor (arrayBuffer: ArrayBuffer);
|
|
||||||
/**
|
|
||||||
* Allocates a new buffer containing the given {array} of octets.
|
|
||||||
*
|
|
||||||
* @param array The octets to store.
|
|
||||||
*/
|
|
||||||
constructor (array: any[]);
|
|
||||||
/**
|
|
||||||
* Copies the passed {buffer} data onto a new {Buffer} instance.
|
|
||||||
*
|
|
||||||
* @param buffer The buffer to copy.
|
|
||||||
*/
|
|
||||||
constructor (buffer: Buffer);
|
|
||||||
prototype: Buffer;
|
|
||||||
/**
|
|
||||||
* Allocates a new Buffer using an {array} of octets.
|
|
||||||
*
|
|
||||||
* @param array
|
|
||||||
*/
|
|
||||||
static from(array: any[]): Buffer;
|
|
||||||
/**
|
|
||||||
* When passed a reference to the .buffer property of a TypedArray instance,
|
|
||||||
* the newly created Buffer will share the same allocated memory as the TypedArray.
|
|
||||||
* The optional {byteOffset} and {length} arguments specify a memory range
|
|
||||||
* within the {arrayBuffer} that will be shared by the Buffer.
|
|
||||||
*
|
|
||||||
* @param arrayBuffer The .buffer property of a TypedArray or a new ArrayBuffer()
|
|
||||||
* @param byteOffset
|
|
||||||
* @param length
|
|
||||||
*/
|
|
||||||
static from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer;
|
|
||||||
/**
|
|
||||||
* Copies the passed {buffer} data onto a new Buffer instance.
|
|
||||||
*
|
|
||||||
* @param buffer
|
|
||||||
*/
|
|
||||||
static from(buffer: Buffer): Buffer;
|
|
||||||
/**
|
|
||||||
* Creates a new Buffer containing the given JavaScript string {str}.
|
|
||||||
* If provided, the {encoding} parameter identifies the character encoding.
|
|
||||||
* If not provided, {encoding} defaults to 'utf8'.
|
|
||||||
*
|
|
||||||
* @param str
|
|
||||||
*/
|
|
||||||
static from(str: string, encoding?: string): Buffer;
|
|
||||||
/**
|
|
||||||
* Returns true if {obj} is a Buffer
|
|
||||||
*
|
|
||||||
* @param obj object to test.
|
|
||||||
*/
|
|
||||||
static isBuffer(obj: any): obj is Buffer;
|
|
||||||
/**
|
|
||||||
* Returns true if {encoding} is a valid encoding argument.
|
|
||||||
* Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
|
|
||||||
*
|
|
||||||
* @param encoding string to test.
|
|
||||||
*/
|
|
||||||
static isEncoding(encoding: string): boolean;
|
|
||||||
/**
|
|
||||||
* Gives the actual byte length of a string. encoding defaults to 'utf8'.
|
|
||||||
* This is not the same as String.prototype.length since that returns the number of characters in a string.
|
|
||||||
*
|
|
||||||
* @param string string to test.
|
|
||||||
* @param encoding encoding used to evaluate (defaults to 'utf8')
|
|
||||||
*/
|
|
||||||
static byteLength(string: string, encoding?: string): number;
|
|
||||||
/**
|
|
||||||
* Returns a buffer which is the result of concatenating all the buffers in the list together.
|
|
||||||
*
|
|
||||||
* If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer.
|
|
||||||
* If the list has exactly one item, then the first item of the list is returned.
|
|
||||||
* If the list has more than one item, then a new Buffer is created.
|
|
||||||
*
|
|
||||||
* @param list An array of Buffer objects to concatenate
|
|
||||||
* @param totalLength Total length of the buffers when concatenated.
|
|
||||||
* If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly.
|
|
||||||
*/
|
|
||||||
static concat(list: Buffer[], totalLength?: number): Buffer;
|
|
||||||
/**
|
|
||||||
* The same as buf1.compare(buf2).
|
|
||||||
*/
|
|
||||||
static compare(buf1: Buffer, buf2: Buffer): number;
|
|
||||||
/**
|
|
||||||
* Allocates a new buffer of {size} octets.
|
|
||||||
*
|
|
||||||
* @param size count of octets to allocate.
|
|
||||||
* @param fill if specified, buffer will be initialized by calling buf.fill(fill).
|
|
||||||
* If parameter is omitted, buffer will be filled with zeros.
|
|
||||||
* @param encoding encoding used for call to buf.fill while initalizing
|
|
||||||
*/
|
|
||||||
static alloc(size: number, fill?: string | Buffer | number, encoding?: string): Buffer;
|
|
||||||
/**
|
|
||||||
* Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents
|
|
||||||
* of the newly created Buffer are unknown and may contain sensitive data.
|
|
||||||
*
|
|
||||||
* @param size count of octets to allocate
|
|
||||||
*/
|
|
||||||
static allocUnsafe(size: number): Buffer;
|
|
||||||
/**
|
|
||||||
* Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents
|
|
||||||
* of the newly created Buffer are unknown and may contain sensitive data.
|
|
||||||
*
|
|
||||||
* @param size count of octets to allocate
|
|
||||||
*/
|
|
||||||
static allocUnsafeSlow(size: number): Buffer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
62
node_modules/readable-stream/node_modules/safe-buffer/index.js
generated
vendored
62
node_modules/readable-stream/node_modules/safe-buffer/index.js
generated
vendored
@ -1,62 +0,0 @@
|
|||||||
/* eslint-disable node/no-deprecated-api */
|
|
||||||
var buffer = require('buffer')
|
|
||||||
var Buffer = buffer.Buffer
|
|
||||||
|
|
||||||
// alternative to using Object.keys for old browsers
|
|
||||||
function copyProps (src, dst) {
|
|
||||||
for (var key in src) {
|
|
||||||
dst[key] = src[key]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
|
|
||||||
module.exports = buffer
|
|
||||||
} else {
|
|
||||||
// Copy properties from require('buffer')
|
|
||||||
copyProps(buffer, exports)
|
|
||||||
exports.Buffer = SafeBuffer
|
|
||||||
}
|
|
||||||
|
|
||||||
function SafeBuffer (arg, encodingOrOffset, length) {
|
|
||||||
return Buffer(arg, encodingOrOffset, length)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy static methods from Buffer
|
|
||||||
copyProps(Buffer, SafeBuffer)
|
|
||||||
|
|
||||||
SafeBuffer.from = function (arg, encodingOrOffset, length) {
|
|
||||||
if (typeof arg === 'number') {
|
|
||||||
throw new TypeError('Argument must not be a number')
|
|
||||||
}
|
|
||||||
return Buffer(arg, encodingOrOffset, length)
|
|
||||||
}
|
|
||||||
|
|
||||||
SafeBuffer.alloc = function (size, fill, encoding) {
|
|
||||||
if (typeof size !== 'number') {
|
|
||||||
throw new TypeError('Argument must be a number')
|
|
||||||
}
|
|
||||||
var buf = Buffer(size)
|
|
||||||
if (fill !== undefined) {
|
|
||||||
if (typeof encoding === 'string') {
|
|
||||||
buf.fill(fill, encoding)
|
|
||||||
} else {
|
|
||||||
buf.fill(fill)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
buf.fill(0)
|
|
||||||
}
|
|
||||||
return buf
|
|
||||||
}
|
|
||||||
|
|
||||||
SafeBuffer.allocUnsafe = function (size) {
|
|
||||||
if (typeof size !== 'number') {
|
|
||||||
throw new TypeError('Argument must be a number')
|
|
||||||
}
|
|
||||||
return Buffer(size)
|
|
||||||
}
|
|
||||||
|
|
||||||
SafeBuffer.allocUnsafeSlow = function (size) {
|
|
||||||
if (typeof size !== 'number') {
|
|
||||||
throw new TypeError('Argument must be a number')
|
|
||||||
}
|
|
||||||
return buffer.SlowBuffer(size)
|
|
||||||
}
|
|
||||||
37
node_modules/readable-stream/node_modules/safe-buffer/package.json
generated
vendored
37
node_modules/readable-stream/node_modules/safe-buffer/package.json
generated
vendored
@ -1,37 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "safe-buffer",
|
|
||||||
"description": "Safer Node.js Buffer API",
|
|
||||||
"version": "5.1.2",
|
|
||||||
"author": {
|
|
||||||
"name": "Feross Aboukhadijeh",
|
|
||||||
"email": "feross@feross.org",
|
|
||||||
"url": "http://feross.org"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/feross/safe-buffer/issues"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"standard": "*",
|
|
||||||
"tape": "^4.0.0"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/feross/safe-buffer",
|
|
||||||
"keywords": [
|
|
||||||
"buffer",
|
|
||||||
"buffer allocate",
|
|
||||||
"node security",
|
|
||||||
"safe",
|
|
||||||
"safe-buffer",
|
|
||||||
"security",
|
|
||||||
"uninitialized"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"main": "index.js",
|
|
||||||
"types": "index.d.ts",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git://github.com/feross/safe-buffer.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"test": "standard && tape test/*.js"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
54
node_modules/readable-stream/package.json
generated
vendored
54
node_modules/readable-stream/package.json
generated
vendored
@ -1,31 +1,46 @@
|
|||||||
{
|
{
|
||||||
"name": "readable-stream",
|
"name": "readable-stream",
|
||||||
"version": "2.3.8",
|
"version": "3.6.2",
|
||||||
"description": "Streams3, a user-land copy of the stream library from Node.js",
|
"description": "Streams3, a user-land copy of the stream library from Node.js",
|
||||||
"main": "readable.js",
|
"main": "readable.js",
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 6"
|
||||||
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core-util-is": "~1.0.0",
|
"inherits": "^2.0.3",
|
||||||
"inherits": "~2.0.3",
|
"string_decoder": "^1.1.1",
|
||||||
"isarray": "~1.0.0",
|
"util-deprecate": "^1.0.1"
|
||||||
"process-nextick-args": "~2.0.0",
|
|
||||||
"safe-buffer": "~5.1.1",
|
|
||||||
"string_decoder": "~1.1.1",
|
|
||||||
"util-deprecate": "~1.0.1"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@babel/cli": "^7.2.0",
|
||||||
|
"@babel/core": "^7.2.0",
|
||||||
|
"@babel/polyfill": "^7.0.0",
|
||||||
|
"@babel/preset-env": "^7.2.0",
|
||||||
|
"airtap": "0.0.9",
|
||||||
"assert": "^1.4.0",
|
"assert": "^1.4.0",
|
||||||
"babel-polyfill": "^6.9.1",
|
"bl": "^2.0.0",
|
||||||
"buffer": "^4.9.0",
|
"deep-strict-equal": "^0.2.0",
|
||||||
"lolex": "^2.3.2",
|
"events.once": "^2.0.2",
|
||||||
"nyc": "^6.4.0",
|
"glob": "^7.1.2",
|
||||||
"tap": "^0.7.0",
|
"gunzip-maybe": "^1.4.1",
|
||||||
"tape": "^4.8.0"
|
"hyperquest": "^2.1.3",
|
||||||
|
"lolex": "^2.6.0",
|
||||||
|
"nyc": "^11.0.0",
|
||||||
|
"pump": "^3.0.0",
|
||||||
|
"rimraf": "^2.6.2",
|
||||||
|
"tap": "^12.0.0",
|
||||||
|
"tape": "^4.9.0",
|
||||||
|
"tar-fs": "^1.16.2",
|
||||||
|
"util-promisify": "^2.1.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "tap test/parallel/*.js test/ours/*.js && node test/verify-dependencies.js",
|
"test": "tap -J --no-esm test/parallel/*.js test/ours/*.js",
|
||||||
"ci": "tap test/parallel/*.js test/ours/*.js --tap | tee test.tap && node test/verify-dependencies.js",
|
"ci": "TAP=1 tap --no-esm test/parallel/*.js test/ours/*.js | tee test.tap",
|
||||||
|
"test-browsers": "airtap --sauce-connect --loopback airtap.local -- test/browser.js",
|
||||||
|
"test-browser-local": "airtap --open --local -- test/browser.js",
|
||||||
"cover": "nyc npm test",
|
"cover": "nyc npm test",
|
||||||
"report": "nyc report --reporter=lcov"
|
"report": "nyc report --reporter=lcov",
|
||||||
|
"update-browser-errors": "babel -o errors-browser.js errors.js"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -38,9 +53,10 @@
|
|||||||
],
|
],
|
||||||
"browser": {
|
"browser": {
|
||||||
"util": false,
|
"util": false,
|
||||||
|
"worker_threads": false,
|
||||||
|
"./errors": "./errors-browser.js",
|
||||||
"./readable.js": "./readable-browser.js",
|
"./readable.js": "./readable-browser.js",
|
||||||
"./writable.js": "./writable-browser.js",
|
"./lib/internal/streams/from.js": "./lib/internal/streams/from-browser.js",
|
||||||
"./duplex.js": "./duplex-browser.js",
|
|
||||||
"./lib/internal/streams/stream.js": "./lib/internal/streams/stream-browser.js"
|
"./lib/internal/streams/stream.js": "./lib/internal/streams/stream-browser.js"
|
||||||
},
|
},
|
||||||
"nyc": {
|
"nyc": {
|
||||||
|
|||||||
1
node_modules/readable-stream/passthrough.js
generated
vendored
1
node_modules/readable-stream/passthrough.js
generated
vendored
@ -1 +0,0 @@
|
|||||||
module.exports = require('./readable').PassThrough
|
|
||||||
2
node_modules/readable-stream/readable-browser.js
generated
vendored
2
node_modules/readable-stream/readable-browser.js
generated
vendored
@ -5,3 +5,5 @@ exports.Writable = require('./lib/_stream_writable.js');
|
|||||||
exports.Duplex = require('./lib/_stream_duplex.js');
|
exports.Duplex = require('./lib/_stream_duplex.js');
|
||||||
exports.Transform = require('./lib/_stream_transform.js');
|
exports.Transform = require('./lib/_stream_transform.js');
|
||||||
exports.PassThrough = require('./lib/_stream_passthrough.js');
|
exports.PassThrough = require('./lib/_stream_passthrough.js');
|
||||||
|
exports.finished = require('./lib/internal/streams/end-of-stream.js');
|
||||||
|
exports.pipeline = require('./lib/internal/streams/pipeline.js');
|
||||||
|
|||||||
13
node_modules/readable-stream/readable.js
generated
vendored
13
node_modules/readable-stream/readable.js
generated
vendored
@ -1,13 +1,8 @@
|
|||||||
var Stream = require('stream');
|
var Stream = require('stream');
|
||||||
if (process.env.READABLE_STREAM === 'disable' && Stream) {
|
if (process.env.READABLE_STREAM === 'disable' && Stream) {
|
||||||
module.exports = Stream;
|
module.exports = Stream.Readable;
|
||||||
exports = module.exports = Stream.Readable;
|
Object.assign(module.exports, Stream);
|
||||||
exports.Readable = Stream.Readable;
|
module.exports.Stream = Stream;
|
||||||
exports.Writable = Stream.Writable;
|
|
||||||
exports.Duplex = Stream.Duplex;
|
|
||||||
exports.Transform = Stream.Transform;
|
|
||||||
exports.PassThrough = Stream.PassThrough;
|
|
||||||
exports.Stream = Stream;
|
|
||||||
} else {
|
} else {
|
||||||
exports = module.exports = require('./lib/_stream_readable.js');
|
exports = module.exports = require('./lib/_stream_readable.js');
|
||||||
exports.Stream = Stream || exports;
|
exports.Stream = Stream || exports;
|
||||||
@ -16,4 +11,6 @@ if (process.env.READABLE_STREAM === 'disable' && Stream) {
|
|||||||
exports.Duplex = require('./lib/_stream_duplex.js');
|
exports.Duplex = require('./lib/_stream_duplex.js');
|
||||||
exports.Transform = require('./lib/_stream_transform.js');
|
exports.Transform = require('./lib/_stream_transform.js');
|
||||||
exports.PassThrough = require('./lib/_stream_passthrough.js');
|
exports.PassThrough = require('./lib/_stream_passthrough.js');
|
||||||
|
exports.finished = require('./lib/internal/streams/end-of-stream.js');
|
||||||
|
exports.pipeline = require('./lib/internal/streams/pipeline.js');
|
||||||
}
|
}
|
||||||
|
|||||||
1
node_modules/readable-stream/transform.js
generated
vendored
1
node_modules/readable-stream/transform.js
generated
vendored
@ -1 +0,0 @@
|
|||||||
module.exports = require('./readable').Transform
|
|
||||||
1
node_modules/readable-stream/writable-browser.js
generated
vendored
1
node_modules/readable-stream/writable-browser.js
generated
vendored
@ -1 +0,0 @@
|
|||||||
module.exports = require('./lib/_stream_writable.js');
|
|
||||||
8
node_modules/readable-stream/writable.js
generated
vendored
8
node_modules/readable-stream/writable.js
generated
vendored
@ -1,8 +0,0 @@
|
|||||||
var Stream = require("stream")
|
|
||||||
var Writable = require("./lib/_stream_writable.js")
|
|
||||||
|
|
||||||
if (process.env.READABLE_STREAM === 'disable') {
|
|
||||||
module.exports = Stream && Stream.Writable || Writable
|
|
||||||
} else {
|
|
||||||
module.exports = Writable
|
|
||||||
}
|
|
||||||
106
node_modules/simple-update-notifier/build/index.js
generated
vendored
106
node_modules/simple-update-notifier/build/index.js
generated
vendored
@ -7,59 +7,59 @@ var path = require('path');
|
|||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var https = require('https');
|
var https = require('https');
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
Copyright (c) Microsoft Corporation.
|
Copyright (c) Microsoft Corporation.
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted.
|
purpose with or without fee is hereby granted.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
PERFORMANCE OF THIS SOFTWARE.
|
PERFORMANCE OF THIS SOFTWARE.
|
||||||
***************************************************************************** */
|
***************************************************************************** */
|
||||||
/* global Reflect, Promise */
|
/* global Reflect, Promise */
|
||||||
|
|
||||||
|
|
||||||
function __awaiter(thisArg, _arguments, P, generator) {
|
function __awaiter(thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
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 rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function __generator(thisArg, body) {
|
function __generator(thisArg, body) {
|
||||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||||
function step(op) {
|
function step(op) {
|
||||||
if (f) throw new TypeError("Generator is already executing.");
|
if (f) throw new TypeError("Generator is already executing.");
|
||||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||||
switch (op[0]) {
|
switch (op[0]) {
|
||||||
case 0: case 1: t = op; break;
|
case 0: case 1: t = op; break;
|
||||||
case 4: _.label++; return { value: op[1], done: false };
|
case 4: _.label++; return { value: op[1], done: false };
|
||||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||||
default:
|
default:
|
||||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||||
if (t[2]) _.ops.pop();
|
if (t[2]) _.ops.pop();
|
||||||
_.trys.pop(); continue;
|
_.trys.pop(); continue;
|
||||||
}
|
}
|
||||||
op = body.call(thisArg, _);
|
op = body.call(thisArg, _);
|
||||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var packageJson = process$1.env.npm_package_json;
|
var packageJson = process$1.env.npm_package_json;
|
||||||
|
|||||||
36
node_modules/streamsearch/LICENSE
generated
vendored
36
node_modules/streamsearch/LICENSE
generated
vendored
@ -1,19 +1,19 @@
|
|||||||
Copyright Brian White. All rights reserved.
|
Copyright Brian White. All rights reserved.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to
|
of this software and associated documentation files (the "Software"), to
|
||||||
deal in the Software without restriction, including without limitation the
|
deal in the Software without restriction, including without limitation the
|
||||||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||||
sell copies of the Software, and to permit persons to whom the Software is
|
sell copies of the Software, and to permit persons to whom the Software is
|
||||||
furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
The above copyright notice and this permission notice shall be included in
|
||||||
all copies or substantial portions of the Software.
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
IN THE SOFTWARE.
|
IN THE SOFTWARE.
|
||||||
132
package-lock.json
generated
132
package-lock.json
generated
@ -17,12 +17,10 @@
|
|||||||
"fs": "^0.0.1-security",
|
"fs": "^0.0.1-security",
|
||||||
"https": "^1.0.0",
|
"https": "^1.0.0",
|
||||||
"jsonwebtoken": "^9.0.2",
|
"jsonwebtoken": "^9.0.2",
|
||||||
"multer": "^2.0.0",
|
"multer": "^2.0.1",
|
||||||
<<<<<<< HEAD
|
|
||||||
"mysql": "^2.18.1",
|
"mysql": "^2.18.1",
|
||||||
"mysql2": "^3.14.1",
|
"mysql2": "^3.14.1",
|
||||||
=======
|
"nodemailer": "^7.0.3",
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
"ws": "^8.18.2"
|
"ws": "^8.18.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@ -160,7 +158,8 @@
|
|||||||
"node_modules/buffer-from": {
|
"node_modules/buffer-from": {
|
||||||
"version": "1.1.2",
|
"version": "1.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
|
||||||
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ=="
|
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
|
||||||
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/busboy": {
|
"node_modules/busboy": {
|
||||||
"version": "1.6.0",
|
"version": "1.6.0",
|
||||||
@ -250,16 +249,17 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/concat-stream": {
|
"node_modules/concat-stream": {
|
||||||
"version": "1.6.2",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
|
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz",
|
||||||
"integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==",
|
"integrity": "sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==",
|
||||||
"engines": [
|
"engines": [
|
||||||
"node >= 0.8"
|
"node >= 6.0"
|
||||||
],
|
],
|
||||||
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"buffer-from": "^1.0.0",
|
"buffer-from": "^1.0.0",
|
||||||
"inherits": "^2.0.3",
|
"inherits": "^2.0.3",
|
||||||
"readable-stream": "^2.2.2",
|
"readable-stream": "^3.0.2",
|
||||||
"typedarray": "^0.0.6"
|
"typedarray": "^0.0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -933,7 +933,6 @@
|
|||||||
"integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==",
|
"integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
<<<<<<< HEAD
|
|
||||||
"node_modules/long": {
|
"node_modules/long": {
|
||||||
"version": "5.3.2",
|
"version": "5.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/long/-/long-5.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/long/-/long-5.3.2.tgz",
|
||||||
@ -964,8 +963,6 @@
|
|||||||
"url": "https://github.com/sponsors/wellwelwel"
|
"url": "https://github.com/sponsors/wellwelwel"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
=======
|
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
"node_modules/math-intrinsics": {
|
"node_modules/math-intrinsics": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
|
||||||
@ -1049,17 +1046,18 @@
|
|||||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
|
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
|
||||||
},
|
},
|
||||||
"node_modules/multer": {
|
"node_modules/multer": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/multer/-/multer-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/multer/-/multer-2.0.1.tgz",
|
||||||
"integrity": "sha512-bS8rPZurbAuHGAnApbM9d4h1wSoYqrOqkE+6a64KLMK9yWU7gJXBDDVklKQ3TPi9DRb85cRs6yXaC0+cjxRtRg==",
|
"integrity": "sha512-Ug8bXeTIUlxurg8xLTEskKShvcKDZALo1THEX5E41pYCD2sCVub5/kIRIGqWNoqV6szyLyQKV6mD4QUrWE5GCQ==",
|
||||||
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"append-field": "^1.0.0",
|
"append-field": "^1.0.0",
|
||||||
"busboy": "^1.0.0",
|
"busboy": "^1.6.0",
|
||||||
"concat-stream": "^1.5.2",
|
"concat-stream": "^2.0.0",
|
||||||
"mkdirp": "^0.5.4",
|
"mkdirp": "^0.5.6",
|
||||||
"object-assign": "^4.1.1",
|
"object-assign": "^4.1.1",
|
||||||
"type-is": "^1.6.4",
|
"type-is": "^1.6.18",
|
||||||
"xtend": "^4.0.0"
|
"xtend": "^4.0.2"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 10.16.0"
|
"node": ">= 10.16.0"
|
||||||
@ -1189,6 +1187,15 @@
|
|||||||
"node": ">= 0.6"
|
"node": ">= 0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/nodemailer": {
|
||||||
|
"version": "7.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-7.0.3.tgz",
|
||||||
|
"integrity": "sha512-Ajq6Sz1x7cIK3pN6KesGTah+1gnwMnx5gKl3piQlQQE/PwyJ4Mbc8is2psWYxK3RJTVeqsDaCv8ZzXLCDHMTZw==",
|
||||||
|
"license": "MIT-0",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/nodemon": {
|
"node_modules/nodemon": {
|
||||||
"version": "3.1.10",
|
"version": "3.1.10",
|
||||||
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.10.tgz",
|
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.10.tgz",
|
||||||
@ -1357,24 +1364,19 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/readable-stream": {
|
"node_modules/readable-stream": {
|
||||||
"version": "2.3.8",
|
"version": "3.6.2",
|
||||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz",
|
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz",
|
||||||
"integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==",
|
"integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==",
|
||||||
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core-util-is": "~1.0.0",
|
"inherits": "^2.0.3",
|
||||||
"inherits": "~2.0.3",
|
"string_decoder": "^1.1.1",
|
||||||
"isarray": "~1.0.0",
|
"util-deprecate": "^1.0.1"
|
||||||
"process-nextick-args": "~2.0.0",
|
},
|
||||||
"safe-buffer": "~5.1.1",
|
"engines": {
|
||||||
"string_decoder": "~1.1.1",
|
"node": ">= 6"
|
||||||
"util-deprecate": "~1.0.1"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/readable-stream/node_modules/safe-buffer": {
|
|
||||||
"version": "5.1.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
|
||||||
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
|
|
||||||
},
|
|
||||||
"node_modules/readdirp": {
|
"node_modules/readdirp": {
|
||||||
"version": "3.6.0",
|
"version": "3.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz",
|
||||||
@ -1657,7 +1659,8 @@
|
|||||||
"node_modules/typedarray": {
|
"node_modules/typedarray": {
|
||||||
"version": "0.0.6",
|
"version": "0.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
|
||||||
"integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA=="
|
"integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==",
|
||||||
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/undefsafe": {
|
"node_modules/undefsafe": {
|
||||||
"version": "2.0.5",
|
"version": "2.0.5",
|
||||||
@ -1890,13 +1893,13 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"concat-stream": {
|
"concat-stream": {
|
||||||
"version": "1.6.2",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
|
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz",
|
||||||
"integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==",
|
"integrity": "sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"buffer-from": "^1.0.0",
|
"buffer-from": "^1.0.0",
|
||||||
"inherits": "^2.0.3",
|
"inherits": "^2.0.3",
|
||||||
"readable-stream": "^2.2.2",
|
"readable-stream": "^3.0.2",
|
||||||
"typedarray": "^0.0.6"
|
"typedarray": "^0.0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -2383,7 +2386,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz",
|
||||||
"integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg=="
|
"integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg=="
|
||||||
},
|
},
|
||||||
<<<<<<< HEAD
|
|
||||||
"long": {
|
"long": {
|
||||||
"version": "5.3.2",
|
"version": "5.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/long/-/long-5.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/long/-/long-5.3.2.tgz",
|
||||||
@ -2399,8 +2401,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/lru.min/-/lru.min-1.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/lru.min/-/lru.min-1.1.2.tgz",
|
||||||
"integrity": "sha512-Nv9KddBcQSlQopmBHXSsZVY5xsdlZkdH/Iey0BlcBYggMd4two7cZnKOK9vmy3nY0O5RGH99z1PCeTpPqszUYg=="
|
"integrity": "sha512-Nv9KddBcQSlQopmBHXSsZVY5xsdlZkdH/Iey0BlcBYggMd4two7cZnKOK9vmy3nY0O5RGH99z1PCeTpPqszUYg=="
|
||||||
},
|
},
|
||||||
=======
|
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
"math-intrinsics": {
|
"math-intrinsics": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
|
||||||
@ -2457,17 +2457,17 @@
|
|||||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
|
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
|
||||||
},
|
},
|
||||||
"multer": {
|
"multer": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/multer/-/multer-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/multer/-/multer-2.0.1.tgz",
|
||||||
"integrity": "sha512-bS8rPZurbAuHGAnApbM9d4h1wSoYqrOqkE+6a64KLMK9yWU7gJXBDDVklKQ3TPi9DRb85cRs6yXaC0+cjxRtRg==",
|
"integrity": "sha512-Ug8bXeTIUlxurg8xLTEskKShvcKDZALo1THEX5E41pYCD2sCVub5/kIRIGqWNoqV6szyLyQKV6mD4QUrWE5GCQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"append-field": "^1.0.0",
|
"append-field": "^1.0.0",
|
||||||
"busboy": "^1.0.0",
|
"busboy": "^1.6.0",
|
||||||
"concat-stream": "^1.5.2",
|
"concat-stream": "^2.0.0",
|
||||||
"mkdirp": "^0.5.4",
|
"mkdirp": "^0.5.6",
|
||||||
"object-assign": "^4.1.1",
|
"object-assign": "^4.1.1",
|
||||||
"type-is": "^1.6.4",
|
"type-is": "^1.6.18",
|
||||||
"xtend": "^4.0.0"
|
"xtend": "^4.0.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"media-typer": {
|
"media-typer": {
|
||||||
@ -2567,6 +2567,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz",
|
||||||
"integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg=="
|
"integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg=="
|
||||||
},
|
},
|
||||||
|
"nodemailer": {
|
||||||
|
"version": "7.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-7.0.3.tgz",
|
||||||
|
"integrity": "sha512-Ajq6Sz1x7cIK3pN6KesGTah+1gnwMnx5gKl3piQlQQE/PwyJ4Mbc8is2psWYxK3RJTVeqsDaCv8ZzXLCDHMTZw=="
|
||||||
|
},
|
||||||
"nodemon": {
|
"nodemon": {
|
||||||
"version": "3.1.10",
|
"version": "3.1.10",
|
||||||
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.10.tgz",
|
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.10.tgz",
|
||||||
@ -2683,24 +2688,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"readable-stream": {
|
"readable-stream": {
|
||||||
"version": "2.3.8",
|
"version": "3.6.2",
|
||||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz",
|
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz",
|
||||||
"integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==",
|
"integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"core-util-is": "~1.0.0",
|
"inherits": "^2.0.3",
|
||||||
"inherits": "~2.0.3",
|
"string_decoder": "^1.1.1",
|
||||||
"isarray": "~1.0.0",
|
"util-deprecate": "^1.0.1"
|
||||||
"process-nextick-args": "~2.0.0",
|
|
||||||
"safe-buffer": "~5.1.1",
|
|
||||||
"string_decoder": "~1.1.1",
|
|
||||||
"util-deprecate": "~1.0.1"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"safe-buffer": {
|
|
||||||
"version": "5.1.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
|
||||||
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"readdirp": {
|
"readdirp": {
|
||||||
|
|||||||
@ -20,12 +20,10 @@
|
|||||||
"fs": "^0.0.1-security",
|
"fs": "^0.0.1-security",
|
||||||
"https": "^1.0.0",
|
"https": "^1.0.0",
|
||||||
"jsonwebtoken": "^9.0.2",
|
"jsonwebtoken": "^9.0.2",
|
||||||
"multer": "^2.0.0",
|
"multer": "^2.0.1",
|
||||||
<<<<<<< HEAD
|
|
||||||
"mysql": "^2.18.1",
|
"mysql": "^2.18.1",
|
||||||
"mysql2": "^3.14.1",
|
"mysql2": "^3.14.1",
|
||||||
=======
|
"nodemailer": "^7.0.3",
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
"ws": "^8.18.2"
|
"ws": "^8.18.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
const express = require('express');
|
const express = require('express');
|
||||||
const { getContacts, getCallList } = require('../controllers/apiController');
|
const { getContacts, getCallList } = require('../controllers/apiController');
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
const multer = require('multer');
|
const multer = require('multer');
|
||||||
const upload = multer();
|
const upload = multer();
|
||||||
|
|
||||||
router.get('/contacts', getContacts);
|
router.get('/contacts', getContacts);
|
||||||
router.post('/calls',upload.none(), getCallList);
|
router.post('/calls',upload.none(), getCallList);
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
12
routes/authRoutes.js
Normal file
12
routes/authRoutes.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
const express = require('express');
|
||||||
|
const router = express.Router();
|
||||||
|
const multer = require('multer');
|
||||||
|
const { signupUserRequest } = require('../controllers/authController');
|
||||||
|
|
||||||
|
// Init multer memory storage (or just for form parsing)
|
||||||
|
const upload = multer();
|
||||||
|
|
||||||
|
// POST /signup - with multipart/form-data, no files
|
||||||
|
router.post('/signup', upload.none(), signupUserRequest);
|
||||||
|
|
||||||
|
module.exports = router;
|
||||||
@ -1,20 +1,13 @@
|
|||||||
const express = require('express');
|
const express = require('express');
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
<<<<<<< HEAD
|
const { getUserData, getNotifications,updateAlerts} = require('../controllers/userController');
|
||||||
const { getUserData, getNotifications,updateAlerts} = require('../controllers/userController');
|
const multer = require('multer');
|
||||||
=======
|
const upload = multer(); // No disk storage, just for parsing fields
|
||||||
const { getUserData, getNotifications} = require('../controllers/userController');
|
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
const multer = require('multer');
|
router.post('/data', upload.none(), getUserData);
|
||||||
const upload = multer(); // No disk storage, just for parsing fields
|
router.post('/notifications',upload.none(),getNotifications)
|
||||||
|
router.post('/acknowledge',upload.none(),updateAlerts)
|
||||||
|
|
||||||
router.post('/data', upload.none(), getUserData);
|
|
||||||
router.post('/notifications',upload.none(),getNotifications)
|
module.exports = router;
|
||||||
<<<<<<< HEAD
|
|
||||||
router.post('/acknowledge',upload.none(),updateAlerts)
|
|
||||||
|
|
||||||
=======
|
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
|
|
||||||
module.exports = router;
|
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
// Run this as a one-time utility
|
// Run this as a one-time utility
|
||||||
const { encrypt } = require('../services/encryptionService');
|
const { encrypt } = require('../services/encryptionService');
|
||||||
console.log(encrypt('actual api key'));
|
console.log(encrypt('actual api key'));
|
||||||
|
|||||||
@ -1,66 +1,66 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const config = require('../config/config.json');
|
const config = require('../config/config.json');
|
||||||
const { decrypt } = require('./encryptionService');
|
const { decrypt } = require('./encryptionService');
|
||||||
const db = require('../config/database'); // import this at the top of your file
|
const db = require('../config/database'); // import this at the top of your file
|
||||||
|
|
||||||
async function fetchContacts() {
|
async function fetchContacts() {
|
||||||
try {
|
try {
|
||||||
const decryptedApiKey = decrypt(config.encryptedApiKey);
|
const decryptedApiKey = decrypt(config.encryptedApiKey);
|
||||||
const response = await axios.get('https://rest.gohighlevel.com/v1/contacts/', {
|
const response = await axios.get('https://rest.gohighlevel.com/v1/contacts/', {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${decryptedApiKey}`
|
Authorization: `Bearer ${decryptedApiKey}`
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(`API Error: ${error.message}`);
|
throw new Error(`API Error: ${error.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchCallList({ assignedTo, call_id }) {
|
async function fetchCallList({ assignedTo, call_id }) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!assignedTo && !call_id) {
|
if (!assignedTo && !call_id) {
|
||||||
throw new Error('Either assignedTo or call_id must be provided.');
|
throw new Error('Either assignedTo or call_id must be provided.');
|
||||||
}
|
}
|
||||||
|
|
||||||
const decryptedApiKey = decrypt(config.encryptedApiKey_callList);
|
const decryptedApiKey = decrypt(config.encryptedApiKey_callList);
|
||||||
|
|
||||||
const axiosConfig = {
|
const axiosConfig = {
|
||||||
method: 'post',
|
method: 'post',
|
||||||
maxBodyLength: Infinity,
|
maxBodyLength: Infinity,
|
||||||
url: 'https://api.retellai.com/v2/list-calls',
|
url: 'https://api.retellai.com/v2/list-calls',
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': `Bearer ${decryptedApiKey}`,
|
'Authorization': `Bearer ${decryptedApiKey}`,
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
data: {} // Include any required data here
|
data: {} // Include any required data here
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await axios.request(axiosConfig);
|
const response = await axios.request(axiosConfig);
|
||||||
|
|
||||||
// Adjust the path to the data based on the actual response structure
|
// Adjust the path to the data based on the actual response structure
|
||||||
const calls = response.data.calls || response.data; // Replace 'calls' with the correct property if different
|
const calls = response.data.calls || response.data; // Replace 'calls' with the correct property if different
|
||||||
|
|
||||||
let filteredCalls = [];
|
let filteredCalls = [];
|
||||||
|
|
||||||
if (assignedTo) {
|
if (assignedTo) {
|
||||||
filteredCalls = calls.filter(call =>
|
filteredCalls = calls.filter(call =>
|
||||||
String(call.retell_llm_dynamic_variables?.assignedTo) === String(assignedTo)
|
String(call.retell_llm_dynamic_variables?.assignedTo) === String(assignedTo)
|
||||||
);
|
);
|
||||||
} else if (call_id) {
|
} else if (call_id) {
|
||||||
filteredCalls = calls.filter(call =>
|
filteredCalls = calls.filter(call =>
|
||||||
String(call.call_id) === String(call_id)
|
String(call.call_id) === String(call_id)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return filteredCalls;
|
return filteredCalls;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(`API Error: ${error.message}`);
|
throw new Error(`API Error: ${error.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = { fetchContacts, fetchCallList };
|
module.exports = { fetchContacts, fetchCallList };
|
||||||
|
|||||||
@ -1,24 +1,24 @@
|
|||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
|
|
||||||
const algorithm = 'aes-256-cbc';
|
const algorithm = 'aes-256-cbc';
|
||||||
const key = crypto.createHash('sha256').update(process.env.ENCRYPTION_SECRET).digest();
|
const key = crypto.createHash('sha256').update(process.env.ENCRYPTION_SECRET).digest();
|
||||||
const ivLength = 16;
|
const ivLength = 16;
|
||||||
|
|
||||||
function encrypt(text) {
|
function encrypt(text) {
|
||||||
const iv = crypto.randomBytes(ivLength);
|
const iv = crypto.randomBytes(ivLength);
|
||||||
const cipher = crypto.createCipheriv(algorithm, key, iv);
|
const cipher = crypto.createCipheriv(algorithm, key, iv);
|
||||||
const encrypted = Buffer.concat([cipher.update(text, 'utf8'), cipher.final()]);
|
const encrypted = Buffer.concat([cipher.update(text, 'utf8'), cipher.final()]);
|
||||||
return `${iv.toString('hex')}:${encrypted.toString('hex')}`;
|
return `${iv.toString('hex')}:${encrypted.toString('hex')}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function decrypt(encryptedText) {
|
function decrypt(encryptedText) {
|
||||||
const [ivHex, encryptedHex] = encryptedText.split(':');
|
const [ivHex, encryptedHex] = encryptedText.split(':');
|
||||||
const iv = Buffer.from(ivHex, 'hex');
|
const iv = Buffer.from(ivHex, 'hex');
|
||||||
const encrypted = Buffer.from(encryptedHex, 'hex');
|
const encrypted = Buffer.from(encryptedHex, 'hex');
|
||||||
const decipher = crypto.createDecipheriv(algorithm, key, iv);
|
const decipher = crypto.createDecipheriv(algorithm, key, iv);
|
||||||
const decrypted = Buffer.concat([decipher.update(encrypted), decipher.final()]);
|
const decrypted = Buffer.concat([decipher.update(encrypted), decipher.final()]);
|
||||||
return decrypted.toString('utf8');
|
return decrypted.toString('utf8');
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { encrypt, decrypt };
|
module.exports = { encrypt, decrypt };
|
||||||
@ -1,4 +1,3 @@
|
|||||||
<<<<<<< HEAD
|
|
||||||
// const WebSocket = require('ws');
|
// const WebSocket = require('ws');
|
||||||
// const jwt = require('jsonwebtoken');
|
// const jwt = require('jsonwebtoken');
|
||||||
// const db = require('../config/database');
|
// const db = require('../config/database');
|
||||||
@ -239,36 +238,15 @@ async function sendUserAlertHistory(ws, userId) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the WebSocket server.
|
* Initializes the WebSocket server.
|
||||||
=======
|
|
||||||
const WebSocket = require('ws');
|
|
||||||
const jwt = require('jsonwebtoken');
|
|
||||||
|
|
||||||
// user_id -> websocket mapping
|
|
||||||
const userSocketMap = new Map();
|
|
||||||
|
|
||||||
// Keep track of connection attempts to prevent rapid reconnection loops
|
|
||||||
const connectionAttempts = new WeakMap();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the WebSocket server.
|
|
||||||
* @param {https.Server} server - The HTTP/HTTPS server instance from Express.
|
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
*/
|
*/
|
||||||
function initWebSocket(server) {
|
function initWebSocket(server) {
|
||||||
const wss = new WebSocket.Server({
|
const wss = new WebSocket.Server({
|
||||||
server,
|
server,
|
||||||
clientTracking: true,
|
clientTracking: true,
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
// Consider adding ping/pong for connection health
|
|
||||||
// clientTracking: true,
|
|
||||||
// maxPayload: 100 * 1024 * 1024, // 100MB
|
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('WebSocket server initialized');
|
console.log('WebSocket server initialized');
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
wss.on('connection', (ws, req) => {
|
wss.on('connection', (ws, req) => {
|
||||||
const location = url.parse(req.url, true);
|
const location = url.parse(req.url, true);
|
||||||
const token = location.query?.token;
|
const token = location.query?.token;
|
||||||
@ -323,39 +301,10 @@ function initWebSocket(server) {
|
|||||||
}, 30000);
|
}, 30000);
|
||||||
|
|
||||||
ws.on('pong', () => { ws.isAlive = true; });
|
ws.on('pong', () => { ws.isAlive = true; });
|
||||||
=======
|
|
||||||
// Handle new connections
|
|
||||||
wss.on('connection', (ws, req) => {
|
|
||||||
const clientIp = req.socket.remoteAddress;
|
|
||||||
// console.log(`New WebSocket connection from ${clientIp}`);
|
|
||||||
|
|
||||||
// Set up ping/pong to detect dead connections
|
|
||||||
let isAlive = true;
|
|
||||||
ws.isAlive = true;
|
|
||||||
|
|
||||||
const pingInterval = setInterval(() => {
|
|
||||||
if (!isAlive) {
|
|
||||||
console.log('Terminating dead connection');
|
|
||||||
return ws.terminate();
|
|
||||||
}
|
|
||||||
|
|
||||||
isAlive = false;
|
|
||||||
try {
|
|
||||||
ws.ping(() => {});
|
|
||||||
} catch (e) {
|
|
||||||
console.error('Error sending ping:', e);
|
|
||||||
}
|
|
||||||
}, 30000);
|
|
||||||
|
|
||||||
ws.on('pong', () => {
|
|
||||||
isAlive = true;
|
|
||||||
});
|
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
|
|
||||||
ws.on('message', (message) => {
|
ws.on('message', (message) => {
|
||||||
try {
|
try {
|
||||||
const data = JSON.parse(message);
|
const data = JSON.parse(message);
|
||||||
<<<<<<< HEAD
|
|
||||||
if (data.type === 'MESSAGE') {
|
if (data.type === 'MESSAGE') {
|
||||||
ws.send(JSON.stringify({
|
ws.send(JSON.stringify({
|
||||||
type: 'MESSAGE_RECEIVED',
|
type: 'MESSAGE_RECEIVED',
|
||||||
@ -382,98 +331,10 @@ function initWebSocket(server) {
|
|||||||
console.error('WebSocket error:', error);
|
console.error('WebSocket error:', error);
|
||||||
if (ws.readyState === WebSocket.OPEN) {
|
if (ws.readyState === WebSocket.OPEN) {
|
||||||
ws.close(1011, 'Internal server error');
|
ws.close(1011, 'Internal server error');
|
||||||
=======
|
|
||||||
|
|
||||||
// Handle different message types
|
|
||||||
if (data.type === 'MESSAGE') {
|
|
||||||
console.log(`Received message: ${data.content}`);
|
|
||||||
ws.send(JSON.stringify({
|
|
||||||
type: 'MESSAGE_RECEIVED',
|
|
||||||
content: data.content,
|
|
||||||
timestamp: new Date().toISOString()
|
|
||||||
}));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle authentication with token
|
|
||||||
const { token } = data;
|
|
||||||
|
|
||||||
if (!token) {
|
|
||||||
ws.send(JSON.stringify({
|
|
||||||
type: 'ERROR',
|
|
||||||
error: 'No token provided',
|
|
||||||
timestamp: new Date().toISOString()
|
|
||||||
}));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const decoded = jwt.decode(token); // Use jwt.verify() in production
|
|
||||||
const userId = decoded?.claims?.user_id;
|
|
||||||
|
|
||||||
if (!userId) {
|
|
||||||
ws.send(JSON.stringify({
|
|
||||||
type: 'ERROR',
|
|
||||||
error: 'Invalid token or missing user_id in claims',
|
|
||||||
timestamp: new Date().toISOString()
|
|
||||||
}));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`Authenticated user: ${userId}`);
|
|
||||||
|
|
||||||
// Store the WebSocket connection with the user ID
|
|
||||||
userSocketMap.set(userId, ws);
|
|
||||||
|
|
||||||
// Store user ID in the WebSocket object for cleanup
|
|
||||||
ws.userId = userId;
|
|
||||||
|
|
||||||
ws.send(JSON.stringify({
|
|
||||||
type: 'CONNECTED',
|
|
||||||
message: `Connected as ${userId}`,
|
|
||||||
timestamp: new Date().toISOString()
|
|
||||||
}));
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
console.error('WebSocket message error:', err);
|
|
||||||
try {
|
|
||||||
ws.send(JSON.stringify({
|
|
||||||
type: 'ERROR',
|
|
||||||
error: 'Invalid message format or processing error',
|
|
||||||
timestamp: new Date().toISOString()
|
|
||||||
}));
|
|
||||||
} catch (sendErr) {
|
|
||||||
console.error('Failed to send error message:', sendErr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Handle connection close
|
|
||||||
ws.on('close', () => {
|
|
||||||
// console.log(`WebSocket closed for ${ws.userId || 'unknown user'}`);
|
|
||||||
if (ws.userId) {
|
|
||||||
userSocketMap.delete(ws.userId);
|
|
||||||
}
|
|
||||||
clearInterval(pingInterval);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Handle errors
|
|
||||||
ws.on('error', (error) => {
|
|
||||||
console.error('WebSocket error:', error);
|
|
||||||
if (ws.readyState === WebSocket.OPEN) {
|
|
||||||
try {
|
|
||||||
ws.close(1011, 'Internal server error');
|
|
||||||
} catch (e) {
|
|
||||||
// Ignore errors during close
|
|
||||||
}
|
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
// Handle server errors
|
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
wss.on('error', (error) => {
|
wss.on('error', (error) => {
|
||||||
console.error('WebSocket server error:', error);
|
console.error('WebSocket server error:', error);
|
||||||
});
|
});
|
||||||
@ -482,7 +343,6 @@ function initWebSocket(server) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
<<<<<<< HEAD
|
|
||||||
* Send a real-time alert to a specific user via WebSocket.
|
* Send a real-time alert to a specific user via WebSocket.
|
||||||
*/
|
*/
|
||||||
async function sendAlertToUser(userId, alert) {
|
async function sendAlertToUser(userId, alert) {
|
||||||
@ -507,15 +367,6 @@ async function sendAlertToUser(userId, alert) {
|
|||||||
console.error("Database operation failed:", err);
|
console.error("Database operation failed:", err);
|
||||||
}
|
}
|
||||||
|
|
||||||
=======
|
|
||||||
* Sends an alert to a user via WebSocket.
|
|
||||||
* @param {string} userId - The target user ID.
|
|
||||||
* @param {string|object} alert - The alert message or payload.
|
|
||||||
* @returns {boolean} - Success/failure.
|
|
||||||
*/
|
|
||||||
function sendAlertToUser(userId, alert) {
|
|
||||||
console.log("socket -- invoked---")
|
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
const ws = userSocketMap.get(userId);
|
const ws = userSocketMap.get(userId);
|
||||||
if (ws && ws.readyState === WebSocket.OPEN) {
|
if (ws && ws.readyState === WebSocket.OPEN) {
|
||||||
ws.send(JSON.stringify({ type: 'ALERT', payload: alert }));
|
ws.send(JSON.stringify({ type: 'ALERT', payload: alert }));
|
||||||
|
|||||||
150
utils/mailer.js
Normal file
150
utils/mailer.js
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
const nodemailer = require('nodemailer');
|
||||||
|
|
||||||
|
// Configure Gmail transporter
|
||||||
|
const transporter = nodemailer.createTransport({
|
||||||
|
service: 'gmail',
|
||||||
|
auth: {
|
||||||
|
user: process.env.GMAIL_USER, // your Gmail
|
||||||
|
pass: process.env.GMAIL_PASS // Gmail App Password
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// In-memory rate limit tracker: email → [timestamps]
|
||||||
|
const emailSendLog = new Map();
|
||||||
|
|
||||||
|
// Helper: Can we send this email?
|
||||||
|
function canSendEmail(email) {
|
||||||
|
const now = Date.now();
|
||||||
|
const windowTime = 24 * 60 * 60 * 1000; // 24 hours in ms
|
||||||
|
const limit = 2;
|
||||||
|
|
||||||
|
const timestamps = emailSendLog.get(email) || [];
|
||||||
|
const recent = timestamps.filter(ts => now - ts < windowTime);
|
||||||
|
|
||||||
|
if (recent.length >= limit) return false;
|
||||||
|
|
||||||
|
recent.push(now);
|
||||||
|
emailSendLog.set(email, recent);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send acknowledgment email to the user
|
||||||
|
async function sendAcknowledgementEmail(firstName, email) {
|
||||||
|
console.log('Sending acknowledgement email to user:', firstName, email);
|
||||||
|
|
||||||
|
const mailOptions = {
|
||||||
|
from: `"GuardianCall.ai" <${process.env.GMAIL_USER}>`,
|
||||||
|
to: email,
|
||||||
|
subject: 'Welcome to GuardianCall.ai!',
|
||||||
|
html: `<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<title>Welcome to GuardianCall.ai</title>
|
||||||
|
</head>
|
||||||
|
<body style="font-family: Arial, sans-serif; background-color: #f9f9f9;">
|
||||||
|
<table width="100%" cellspacing="0" cellpadding="0">
|
||||||
|
<tr>
|
||||||
|
<td align="center">
|
||||||
|
<table width="600" style="background-color: #ffffff; margin-top: 30px; border-radius: 10px;">
|
||||||
|
<tr>
|
||||||
|
<td align="center" style="padding: 30px;">
|
||||||
|
<img src="https://s3.blr.cloudtopiaa.com:6780/swift/v1/AUTH_02a111ba8aca4efcbc139b77a7b37f30/gaurdian-ui/GuardianCallAi-Logo.png" alt="GuardianCall.ai Logo" style="max-width: 250px;" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="padding: 30px 40px;">
|
||||||
|
<h2 style="color: #333;">Welcome, ${firstName}!</h2>
|
||||||
|
<p style="color: #555; font-size: 16px;">
|
||||||
|
Thank you for signing up with <strong>GuardianCall.ai</strong>. Your account registration request has been received and is currently under review.
|
||||||
|
</p>
|
||||||
|
<p style="color: #555; font-size: 16px;">
|
||||||
|
Once your account is approved, you'll receive a confirmation email with next steps and login instructions.
|
||||||
|
</p>
|
||||||
|
<p style="color: #555; font-size: 16px;">
|
||||||
|
In the meantime, feel free to explore more about what GuardianCall.ai can do for you.
|
||||||
|
</p>
|
||||||
|
<p style="color: #555; font-size: 16px;">Warm regards,<br/>The GuardianCall.ai Team</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="background-color: #f0f0f0; text-align: center; padding: 20px;">
|
||||||
|
<p style="font-size: 12px; color: #999;">© 2025 GuardianCall.ai. All rights reserved.</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>`
|
||||||
|
};
|
||||||
|
|
||||||
|
return transporter.sendMail(mailOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send signup request to admin + acknowledgment to user
|
||||||
|
async function sendSignupEmail(email, firstName, lastName, password) {
|
||||||
|
if (!canSendEmail(email)) {
|
||||||
|
const error = new Error(`Rate limit exceeded for ${email}. Please try again later.`);
|
||||||
|
error.status = 429; // Too Many Requests
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
const mailOptions = {
|
||||||
|
from: `"GuardianCall.ai" <${process.env.GMAIL_USER}>`,
|
||||||
|
to: process.env.gmail_admin,
|
||||||
|
subject: 'Signup request',
|
||||||
|
html: `<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<title>New Signup Request - GuardianCall</title>
|
||||||
|
</head>
|
||||||
|
<body style="font-family: Arial, sans-serif; background-color: #f9f9f9;">
|
||||||
|
<table width="100%" cellspacing="0" cellpadding="0">
|
||||||
|
<tr>
|
||||||
|
<td align="center">
|
||||||
|
<table width="600" style="background-color: #ffffff; margin-top: 30px; border-radius: 10px;">
|
||||||
|
<tr>
|
||||||
|
<td align="center" style="padding: 30px;">
|
||||||
|
<img src="https://s3.blr.cloudtopiaa.com:6780/swift/v1/AUTH_02a111ba8aca4efcbc139b77a7b37f30/gaurdian-ui/GuardianCallAi-Logo.png" alt="GuardianCall.ai Logo" style="max-width: 250px;" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="padding: 30px 40px;">
|
||||||
|
<h2 style="color: #333;">New Signup Request Received</h2>
|
||||||
|
<p style="color: #555; font-size: 16px;">Hi Admin,</p>
|
||||||
|
<p style="color: #555; font-size: 16px;">A new user has requested signup on GuardianCall.ai.</p>
|
||||||
|
<h3 style="color: #333;">User Details:</h3>
|
||||||
|
<ul style="color: #555; font-size: 16px; list-style: none; padding-left: 0;">
|
||||||
|
<li><strong>First Name:</strong> ${firstName}</li>
|
||||||
|
<li><strong>Last Name:</strong> ${lastName}</li>
|
||||||
|
<li><strong>Email:</strong> ${email}</li>
|
||||||
|
<li><strong>Suggested Password:</strong> ${password}</li>
|
||||||
|
</ul>
|
||||||
|
<p style="color: #555; font-size: 16px;">Please verify the information and take appropriate action.</p>
|
||||||
|
<p style="color: #555; font-size: 16px;">Cheers,<br/>The GuardianCall.ai Team</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="background-color: #f0f0f0; text-align: center; padding: 20px;">
|
||||||
|
<p style="font-size: 12px; color: #999;">© 2025 GuardianCall.ai. All rights reserved.</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>`
|
||||||
|
};
|
||||||
|
|
||||||
|
// Send both emails
|
||||||
|
await sendAcknowledgementEmail(firstName, email);
|
||||||
|
return transporter.sendMail(mailOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = { sendSignupEmail };
|
||||||
Loading…
Reference in New Issue
Block a user