signup request,validation, email ack,config
This commit is contained in:
parent
6441027b89
commit
bc607d8017
12
.env
12
.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
|
||||||
=======
|
|
||||||
MYSQL_HOST =
|
GMAIL_PASS = coye ochr karf twdx
|
||||||
MYSQL_USER =
|
GMAIL_USER = jassimsoopimohammed@gmail.com
|
||||||
MYSQL_PASSWORD =
|
gmail_admin = rohit.giri@tech4biz.org
|
||||||
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
|
||||||
23
app.js
23
app.js
@ -3,17 +3,14 @@ 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 authRoutes = require('./routes/authRoutes');
|
||||||
const https = require('https');
|
const https = require('https');
|
||||||
const fs = require("fs")
|
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 {initWebSocket} = require('./services/webSocket')
|
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
const app = express();
|
const app = express();
|
||||||
const sslOptions = {
|
const sslOptions = {
|
||||||
// key: fs.readFileSync('./certificates/fullchain.pem'),
|
// key: fs.readFileSync('./certificates/fullchain.pem'),
|
||||||
@ -22,18 +19,12 @@ const sslOptions = {
|
|||||||
// Create HTTP server (use HTTP for now to avoid SSL issues, in production use HTTPS with valid certificates)
|
// Create HTTP server (use HTTP for now to avoid SSL issues, in production use HTTPS with valid certificates)
|
||||||
const server = require('http').createServer(app);
|
const server = require('http').createServer(app);
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
|
|
||||||
// Initialize WebSocket server
|
// Initialize WebSocket server
|
||||||
initWebSocket(server);
|
initWebSocket(server);
|
||||||
console.log('WebSocket server initialized');
|
console.log('WebSocket server initialized');
|
||||||
|
|
||||||
connectDB()
|
connectDB()
|
||||||
=======
|
|
||||||
// Initialize WebSocket server
|
|
||||||
initWebSocket(server);
|
|
||||||
console.log('WebSocket server initialized');
|
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
// Middleware to parse JSON bodies
|
// Middleware to parse JSON bodies
|
||||||
app.use(express.json()); // 👈 Add this line
|
app.use(express.json()); // 👈 Add this line
|
||||||
|
|
||||||
@ -41,11 +32,7 @@ app.use(express.json()); // 👈 Add this line
|
|||||||
app.use(express.static('public'));
|
app.use(express.static('public'));
|
||||||
|
|
||||||
// CORS Configuration
|
// CORS Configuration
|
||||||
<<<<<<< HEAD
|
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
|
||||||
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
|
|
||||||
=======
|
|
||||||
const allowedOrigins = ['https://guardiancalls.tech4bizsolutions.com','http://localhost:5174', 'https://yourfrontend.com','http://localhost:5173', 'http://192.168.1.35:5173']; // Replace as needed
|
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
|
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
// Check if the request is for the WebSocket test page
|
// Check if the request is for the WebSocket test page
|
||||||
@ -81,6 +68,8 @@ app.use(cors({
|
|||||||
// Routes
|
// Routes
|
||||||
app.use('/api/user', userRoutes);
|
app.use('/api/user', userRoutes);
|
||||||
app.use('/api/call-list', apiRoutes);
|
app.use('/api/call-list', apiRoutes);
|
||||||
|
app.use('/api/auth', authRoutes);
|
||||||
|
|
||||||
|
|
||||||
app.get('/', (req, res) => {
|
app.get('/', (req, res) => {
|
||||||
res.send("Backend is working!");
|
res.send("Backend is working!");
|
||||||
@ -96,8 +85,4 @@ const PORT = process.env.PORT || 3000;
|
|||||||
server.listen(PORT, () => {
|
server.listen(PORT, () => {
|
||||||
console.log(`HTTP server running on port ${PORT}`);
|
console.log(`HTTP server running on port ${PORT}`);
|
||||||
console.log(`WebSocket server available at ws://localhost:${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-----
|
|
||||||
@ -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
|
|
||||||
|
|||||||
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,11 +1,7 @@
|
|||||||
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 { sendAlertToUser } = require("../services/webSocket")
|
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
|
|
||||||
const fieldTitleMap = {
|
const fieldTitleMap = {
|
||||||
Hq5fePgYMo1lfrJeSXkr: "call_frequency",
|
Hq5fePgYMo1lfrJeSXkr: "call_frequency",
|
||||||
@ -86,7 +82,6 @@ async function getNotifications(req,res){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
async function updateAlerts(req, res) {
|
async function updateAlerts(req, res) {
|
||||||
|
|
||||||
let id = req.body.id
|
let id = req.body.id
|
||||||
@ -138,6 +133,3 @@ async function updateAlerts(req, res) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
module.exports = { getUserData ,getNotifications,updateAlerts};
|
module.exports = { getUserData ,getNotifications,updateAlerts};
|
||||||
=======
|
|
||||||
module.exports = { getUserData ,getNotifications};
|
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
|
|||||||
0
node_modules/.bin/mkdirp.cmd
generated
vendored
Normal file → Executable file
0
node_modules/.bin/mkdirp.cmd
generated
vendored
Normal file → Executable file
0
node_modules/.bin/nodemon.cmd
generated
vendored
Normal file → Executable file
0
node_modules/.bin/nodemon.cmd
generated
vendored
Normal file → Executable file
0
node_modules/.bin/nodetouch.cmd
generated
vendored
Normal file → Executable file
0
node_modules/.bin/nodetouch.cmd
generated
vendored
Normal file → Executable file
0
node_modules/.bin/semver.cmd
generated
vendored
Normal file → Executable file
0
node_modules/.bin/semver.cmd
generated
vendored
Normal file → Executable file
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,23 +1327,18 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"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",
|
|
||||||
"string_decoder": "~1.1.1",
|
|
||||||
"util-deprecate": "~1.0.1"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"node_modules/readable-stream/node_modules/safe-buffer": {
|
"engines": {
|
||||||
"version": "5.1.2",
|
"node": ">= 6"
|
||||||
"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",
|
||||||
@ -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
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": {
|
||||||
|
|||||||
45
node_modules/multer/README.md
generated
vendored
45
node_modules/multer/README.md
generated
vendored
@ -1,4 +1,4 @@
|
|||||||
# 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.
|
||||||
@ -9,17 +9,22 @@ on top of [busboy](https://github.com/mscdex/busboy) for maximum efficiency.
|
|||||||
|
|
||||||
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,7 +83,7 @@ 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">
|
||||||
@ -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
|
|
||||||
83
node_modules/readable-stream/lib/_stream_duplex.js
generated
vendored
83
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;
|
||||||
|
if (options.writable === false) this.writable = false;
|
||||||
|
if (options.allowHalfOpen === false) {
|
||||||
|
this.allowHalfOpen = false;
|
||||||
this.once('end', onend);
|
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) {
|
||||||
@ -122,10 +124,3 @@ Object.defineProperty(Duplex.prototype, 'destroyed', {
|
|||||||
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);
|
||||||
};
|
};
|
||||||
526
node_modules/readable-stream/lib/_stream_readable.js
generated
vendored
526
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
|
|
||||||
}
|
|
||||||
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,23 +1364,18 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"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",
|
|
||||||
"string_decoder": "~1.1.1",
|
|
||||||
"util-deprecate": "~1.0.1"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"node_modules/readable-stream/node_modules/safe-buffer": {
|
"engines": {
|
||||||
"version": "5.1.2",
|
"node": ">= 6"
|
||||||
"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",
|
||||||
@ -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": {
|
||||||
|
|||||||
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 { getUserData, getNotifications} = require('../controllers/userController');
|
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
const multer = require('multer');
|
const multer = require('multer');
|
||||||
const upload = multer(); // No disk storage, just for parsing fields
|
const upload = multer(); // No disk storage, just for parsing fields
|
||||||
|
|
||||||
|
|
||||||
router.post('/data', upload.none(), getUserData);
|
router.post('/data', upload.none(), getUserData);
|
||||||
router.post('/notifications',upload.none(),getNotifications)
|
router.post('/notifications',upload.none(),getNotifications)
|
||||||
<<<<<<< HEAD
|
|
||||||
router.post('/acknowledge',upload.none(),updateAlerts)
|
router.post('/acknowledge',upload.none(),updateAlerts)
|
||||||
|
|
||||||
=======
|
|
||||||
>>>>>>> 3d47f2d539024e036b3db88eb1e020180e656065
|
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
@ -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