feat(security,ui): self-host React deps, Tailwind, fonts; strict CSP; local QR; better selection state
Replace CDN React/ReactDOM/Babel with local libs; remove Babel and inline scripts Build Tailwind locally, add safelist; switch to assets/tailwind.css Self-host Font Awesome and Inter (CSS + woff2); remove external font CDNs Implement strict CSP (no unsafe-inline/eval; scripts/styles/fonts from self) Extract inline handlers; move PWA scripts to external files Add local QR code generation (qrcode lib) and remove api.qrserver.com Improve SessionTypeSelector visual selection (highlighted background and ring) Keep PWA working with service worker and offline assets Refs: CSP hardening, offline-first, no external dependencies
This commit is contained in:
63
node_modules/qrcode/lib/core/utils.js
generated
vendored
Normal file
63
node_modules/qrcode/lib/core/utils.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
let toSJISFunction
|
||||
const CODEWORDS_COUNT = [
|
||||
0, // Not used
|
||||
26, 44, 70, 100, 134, 172, 196, 242, 292, 346,
|
||||
404, 466, 532, 581, 655, 733, 815, 901, 991, 1085,
|
||||
1156, 1258, 1364, 1474, 1588, 1706, 1828, 1921, 2051, 2185,
|
||||
2323, 2465, 2611, 2761, 2876, 3034, 3196, 3362, 3532, 3706
|
||||
]
|
||||
|
||||
/**
|
||||
* Returns the QR Code size for the specified version
|
||||
*
|
||||
* @param {Number} version QR Code version
|
||||
* @return {Number} size of QR code
|
||||
*/
|
||||
exports.getSymbolSize = function getSymbolSize (version) {
|
||||
if (!version) throw new Error('"version" cannot be null or undefined')
|
||||
if (version < 1 || version > 40) throw new Error('"version" should be in range from 1 to 40')
|
||||
return version * 4 + 17
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total number of codewords used to store data and EC information.
|
||||
*
|
||||
* @param {Number} version QR Code version
|
||||
* @return {Number} Data length in bits
|
||||
*/
|
||||
exports.getSymbolTotalCodewords = function getSymbolTotalCodewords (version) {
|
||||
return CODEWORDS_COUNT[version]
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode data with Bose-Chaudhuri-Hocquenghem
|
||||
*
|
||||
* @param {Number} data Value to encode
|
||||
* @return {Number} Encoded value
|
||||
*/
|
||||
exports.getBCHDigit = function (data) {
|
||||
let digit = 0
|
||||
|
||||
while (data !== 0) {
|
||||
digit++
|
||||
data >>>= 1
|
||||
}
|
||||
|
||||
return digit
|
||||
}
|
||||
|
||||
exports.setToSJISFunction = function setToSJISFunction (f) {
|
||||
if (typeof f !== 'function') {
|
||||
throw new Error('"toSJISFunc" is not a valid function.')
|
||||
}
|
||||
|
||||
toSJISFunction = f
|
||||
}
|
||||
|
||||
exports.isKanjiModeEnabled = function () {
|
||||
return typeof toSJISFunction !== 'undefined'
|
||||
}
|
||||
|
||||
exports.toSJIS = function toSJIS (kanji) {
|
||||
return toSJISFunction(kanji)
|
||||
}
|
||||
Reference in New Issue
Block a user