Integrate 0.9.3 SLP/IP, SQLite identities and complete token fix; build release 0.9.3-1
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import net from 'node:net';
|
||||
import {randomBytes} from 'node:crypto';
|
||||
export const defaults = Object.freeze({enabled:false,bind:'127.0.0.1',port:8790,engine:'chromium',maxSessions:2,width:800,height:600,fps:8,quality:65,codec:'jpeg',audio:false,audioRate:22050,audioChannels:1,audioCodec:'pcm16',token:'',idleSeconds:600,allowPrivate:false,autoUpdate:false});
|
||||
export function validate(c){
|
||||
if(!c||Object.getPrototypeOf(c)!==Object.prototype)throw Error('Konfiguration fehlt');
|
||||
@@ -12,3 +13,14 @@ export function validate(c){
|
||||
if(typeof c.token!=='string'||(c.token!==''&&!/^[a-f0-9]{64}$/.test(c.token))||(c.enabled&&!c.token))throw Error('64-stelliger Hex-Token erforderlich');
|
||||
return c;
|
||||
}
|
||||
|
||||
// Only administrative saves may create/rotate a token. Ordinary validation stays strict.
|
||||
export function prepareSave(input, current, rotate=false){
|
||||
if(!input||Object.getPrototypeOf(input)!==Object.prototype)throw Error('Konfiguration fehlt');
|
||||
const next={...input};
|
||||
if(rotate)next.token=randomBytes(32).toString('hex');
|
||||
else if(!Object.hasOwn(next,'token')||next.token===''){
|
||||
next.token=current.token||(next.enabled===true?randomBytes(32).toString('hex'):'');
|
||||
}
|
||||
return validate(next);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user