okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
a4f797532
main
1/** The API key is optional (owner decision, 0.2.2): removing it while sharing or the Cloudflare tunnel runs is allowed, and the key stays removed. */ 2import test from 'node:test' ; 3import assert from 'node:assert/strict' ; 4import { mkdtempSync , rmSync } from 'node:fs' ; 5import { tmpdir } from 'node:os' ; 6import { join } from 'node:path' ; 7 8const home = mkdtempSync ( join ( tmpdir (), 'strata-serving-key-' )); 9process . env . STRATA_HOME = home ; 10const serving = await import ( '../server/serving.mjs' ); 11 12test ( 'removing the API key while local sharing and the tunnel run is allowed' , () => { 13serving . init ({ send () {} }, { port :8080 , host :'127.0.0.1' }); 14serving . patch ({ generateKey :true }); 15assert . equal ( serving . state (). access . apiKeySet , true ); 16serving . setSharing ({ active :true , url :'http://192.168.1.5:8792/v1' }); 17serving . setTunnel ({ status :'connected' , mode :'quick' , url :'https://example.trycloudflare.com' , error :null , installed :true , originUrl :null }); 18assert . equal ( serving . state (). access . otherDevices , true ); 19const after = serving . patch ({ apiKey :null }); 20assert . equal ( after . access . apiKeySet , false ); 21assert . equal ( serving . authorized ({ headers :{} }), true ); 22}); 23test . after (() => { try { rmSync ( home , { recursive :true , force :true }); } catch { /* temp folder */ } });