**Motivations:** - Complete documentation for dashboard, domains, ports and environment configuration - Add new services (ClamAV API, Watermark API) to the infrastructure - Enhance dashboard with new pages and improved functionality - Improve deployment scripts and service configurations **Root causes:** - Missing comprehensive documentation for infrastructure setup - Need for antivirus scanning service integration - Need for watermark service integration - Dashboard required additional pages and features **Correctifs:** - Added comprehensive documentation in docs/ (DASHBOARD.md, DOMAINS_AND_PORTS.md, ENVIRONMENT.md) - Updated systemd service files with proper environment variables - Enhanced nginx proxy configuration script - Updated maintenance documentation **Evolutions:** - Added new ClamAV API service (api-clamav) for file scanning - Added new Watermark API service (api-filigrane) for document watermarking - Enhanced signet-dashboard with new learn.html page - Improved dashboard UI with better styles and navigation - Enhanced app.js with new functionality and better error handling - Updated API documentation page with complete endpoint descriptions - Added deployment scripts for watermark and nginx configuration - Updated hash and UTXO lists with latest data - Enhanced server.js with new routes and improved Bitcoin RPC integration **Pages affectées:** - docs/DASHBOARD.md: New comprehensive dashboard documentation - docs/DOMAINS_AND_PORTS.md: New infrastructure domains and ports documentation - docs/ENVIRONMENT.md: New environment variables documentation - docs/MAINTENANCE.md: Updated maintenance procedures - docs/README.md: Updated main documentation - signet-dashboard/public/app.js: Enhanced with new features - signet-dashboard/public/styles.css: Improved styling - signet-dashboard/public/index.html: Enhanced main page - signet-dashboard/public/learn.html: New educational page - signet-dashboard/public/api-docs.html: Enhanced API documentation - signet-dashboard/public/hash-list.html: Updated hash list page - signet-dashboard/public/utxo-list.html: Updated UTXO list page - signet-dashboard/public/join-signet.html: Updated join signet page - signet-dashboard/src/server.js: Enhanced server with new routes - signet-dashboard/start.sh: Updated startup script - signet-dashboard/signet-dashboard.service: Updated systemd service - api-anchorage/anchorage-api.service: Updated systemd service - api-faucet/faucet-api.service: Updated systemd service - configure-nginx-proxy.sh: Enhanced nginx configuration script - add-watermark-certificate.sh: New watermark certificate script - deploy-watermark-nginx.sh: New deployment script - api-clamav/: New ClamAV API service - api-filigrane/: New Watermark API service - hash_list.txt, utxo_list.txt: Updated with latest data - anchor_count.txt: Updated anchor count
145 lines
3.7 KiB
JavaScript
145 lines
3.7 KiB
JavaScript
var Writable = require('readable-stream').Writable
|
|
var inherits = require('inherits')
|
|
var bufferFrom = require('buffer-from')
|
|
|
|
if (typeof Uint8Array === 'undefined') {
|
|
var U8 = require('typedarray').Uint8Array
|
|
} else {
|
|
var U8 = Uint8Array
|
|
}
|
|
|
|
function ConcatStream(opts, cb) {
|
|
if (!(this instanceof ConcatStream)) return new ConcatStream(opts, cb)
|
|
|
|
if (typeof opts === 'function') {
|
|
cb = opts
|
|
opts = {}
|
|
}
|
|
if (!opts) opts = {}
|
|
|
|
var encoding = opts.encoding
|
|
var shouldInferEncoding = false
|
|
|
|
if (!encoding) {
|
|
shouldInferEncoding = true
|
|
} else {
|
|
encoding = String(encoding).toLowerCase()
|
|
if (encoding === 'u8' || encoding === 'uint8') {
|
|
encoding = 'uint8array'
|
|
}
|
|
}
|
|
|
|
Writable.call(this, { objectMode: true })
|
|
|
|
this.encoding = encoding
|
|
this.shouldInferEncoding = shouldInferEncoding
|
|
|
|
if (cb) this.on('finish', function () { cb(this.getBody()) })
|
|
this.body = []
|
|
}
|
|
|
|
module.exports = ConcatStream
|
|
inherits(ConcatStream, Writable)
|
|
|
|
ConcatStream.prototype._write = function(chunk, enc, next) {
|
|
this.body.push(chunk)
|
|
next()
|
|
}
|
|
|
|
ConcatStream.prototype.inferEncoding = function (buff) {
|
|
var firstBuffer = buff === undefined ? this.body[0] : buff;
|
|
if (Buffer.isBuffer(firstBuffer)) return 'buffer'
|
|
if (typeof Uint8Array !== 'undefined' && firstBuffer instanceof Uint8Array) return 'uint8array'
|
|
if (Array.isArray(firstBuffer)) return 'array'
|
|
if (typeof firstBuffer === 'string') return 'string'
|
|
if (Object.prototype.toString.call(firstBuffer) === "[object Object]") return 'object'
|
|
return 'buffer'
|
|
}
|
|
|
|
ConcatStream.prototype.getBody = function () {
|
|
if (!this.encoding && this.body.length === 0) return []
|
|
if (this.shouldInferEncoding) this.encoding = this.inferEncoding()
|
|
if (this.encoding === 'array') return arrayConcat(this.body)
|
|
if (this.encoding === 'string') return stringConcat(this.body)
|
|
if (this.encoding === 'buffer') return bufferConcat(this.body)
|
|
if (this.encoding === 'uint8array') return u8Concat(this.body)
|
|
return this.body
|
|
}
|
|
|
|
var isArray = Array.isArray || function (arr) {
|
|
return Object.prototype.toString.call(arr) == '[object Array]'
|
|
}
|
|
|
|
function isArrayish (arr) {
|
|
return /Array\]$/.test(Object.prototype.toString.call(arr))
|
|
}
|
|
|
|
function isBufferish (p) {
|
|
return typeof p === 'string' || isArrayish(p) || (p && typeof p.subarray === 'function')
|
|
}
|
|
|
|
function stringConcat (parts) {
|
|
var strings = []
|
|
var needsToString = false
|
|
for (var i = 0; i < parts.length; i++) {
|
|
var p = parts[i]
|
|
if (typeof p === 'string') {
|
|
strings.push(p)
|
|
} else if (Buffer.isBuffer(p)) {
|
|
strings.push(p)
|
|
} else if (isBufferish(p)) {
|
|
strings.push(bufferFrom(p))
|
|
} else {
|
|
strings.push(bufferFrom(String(p)))
|
|
}
|
|
}
|
|
if (Buffer.isBuffer(parts[0])) {
|
|
strings = Buffer.concat(strings)
|
|
strings = strings.toString('utf8')
|
|
} else {
|
|
strings = strings.join('')
|
|
}
|
|
return strings
|
|
}
|
|
|
|
function bufferConcat (parts) {
|
|
var bufs = []
|
|
for (var i = 0; i < parts.length; i++) {
|
|
var p = parts[i]
|
|
if (Buffer.isBuffer(p)) {
|
|
bufs.push(p)
|
|
} else if (isBufferish(p)) {
|
|
bufs.push(bufferFrom(p))
|
|
} else {
|
|
bufs.push(bufferFrom(String(p)))
|
|
}
|
|
}
|
|
return Buffer.concat(bufs)
|
|
}
|
|
|
|
function arrayConcat (parts) {
|
|
var res = []
|
|
for (var i = 0; i < parts.length; i++) {
|
|
res.push.apply(res, parts[i])
|
|
}
|
|
return res
|
|
}
|
|
|
|
function u8Concat (parts) {
|
|
var len = 0
|
|
for (var i = 0; i < parts.length; i++) {
|
|
if (typeof parts[i] === 'string') {
|
|
parts[i] = bufferFrom(parts[i])
|
|
}
|
|
len += parts[i].length
|
|
}
|
|
var u8 = new U8(len)
|
|
for (var i = 0, offset = 0; i < parts.length; i++) {
|
|
var part = parts[i]
|
|
for (var j = 0; j < part.length; j++) {
|
|
u8[offset++] = part[j]
|
|
}
|
|
}
|
|
return u8
|
|
}
|