diff --git a/website/package-lock.json b/website/package-lock.json index bfb5f68..2fb3c53 100644 --- a/website/package-lock.json +++ b/website/package-lock.json @@ -41,7 +41,7 @@ }, "..": { "name": "@webosbrew/caniroot", - "version": "1.0.5", + "version": "1.1.1", "license": "MIT", "devDependencies": { "lodash-es": "^4.17.21", diff --git a/website/src/app.ts b/website/src/app.ts index 1d32be0..0dd898e 100644 --- a/website/src/app.ts +++ b/website/src/app.ts @@ -1,5 +1,5 @@ import {Component, html, render} from 'htm/preact'; -import {DeviceExploitAvailabilities, DeviceModel, DeviceModelName} from "@webosbrew/caniroot"; +import {DeviceExploitAvailabilities, DeviceExploitType, DeviceModel, DeviceModelName} from "@webosbrew/caniroot"; import debounce from 'lodash-es/debounce'; import {RenderableProps} from "preact"; import {ExploitCard} from "./exploit"; @@ -13,6 +13,7 @@ interface AppProps { interface AppState { term?: SearchTerm; model?: DeviceModel; + similar?: boolean; availability?: DeviceExploitAvailabilities; } @@ -32,7 +33,7 @@ function parseSearchTerm(q?: string): SearchTerm | undefined { export declare interface ExploitMethod { name: string; - key: keyof DeviceExploitAvailabilities; + key: DeviceExploitType; url: string; expert?: boolean; } @@ -40,19 +41,36 @@ export declare interface ExploitMethod { class App extends Component { readonly exploits: ExploitMethod[] = [ - {name: 'DejaVuln', key: 'dejavuln', url: 'https://github.com/throwaway96/dejavuln-autoroot'}, - {name: 'ASM', key: 'asm', url: 'https://github.com/illixion/root-my-webos-tv'}, - {name: 'crashd', key: 'crashd', url: 'https://gist.github.com/throwaway96/e811b0f7cc2a705a5a476a8dfa45e09f'}, - {name: 'WTA', key: 'wta', url: 'https://gist.github.com/throwaway96/b171240ef59d7f5fd6fb48fc6dfd2941'}, - {name: 'RootMy.TV', key: 'rootmytv', url: 'https://rootmy.tv/'}, + { + name: 'DejaVuln', + key: DeviceExploitType.DejaVuln, + url: 'https://github.com/throwaway96/dejavuln-autoroot' + }, + { + name: 'ASM', + key: DeviceExploitType.ASM, + url: 'https://github.com/illixion/root-my-webos-tv' + }, + { + name: 'crashd', + key: DeviceExploitType.crashd, + url: 'https://gist.github.com/throwaway96/e811b0f7cc2a705a5a476a8dfa45e09f' + }, + { + name: 'WTA', + key: DeviceExploitType.WTA, + url: 'https://gist.github.com/throwaway96/b171240ef59d7f5fd6fb48fc6dfd2941' + }, + { + name: 'RootMy.TV', + key: DeviceExploitType.RootMyTV, + url: 'https://rootmy.tv/' + }, ]; constructor(props: AppProps) { super(props); - const term = parseSearchTerm(props.q); - let model = term?.model && DeviceModel.find(term.model.series + (term.model.tdd || '')); - let availability = model && DeviceExploitAvailabilities.byOTAID(model.otaId); - this.state = {term, model, availability}; + this.state = this.createState(props.q) } /** @@ -97,10 +115,17 @@ class App extends Component { onInput=${(e: Event) => this.searchChanged((e.currentTarget as HTMLInputElement).value)}/> ${SearchHint(state.term, model)} + ${state.similar && html` +
+ + We found a similar model (${state.availability?.otaId}) but not an exact match + (${model?.otaId}). +
+ `} ${this.exploits.map(exploit => { const avail = state.availability?.[exploit.key]; - return avail && ExploitCard(exploit, avail, state.term?.firmware ?? avail.patched?.version); + return avail && ExploitCard(exploit, avail, state.term?.firmware); })} ${unrootable && html` @@ -148,10 +173,18 @@ class App extends Component { } private searchImmediate(q: string): void { + this.setState(this.createState(q)); + } + + private createState(q?: string): AppState { const term = parseSearchTerm(q); let model = term?.model && DeviceModel.find(term.model.series + (term.model.tdd || '')); let availability = model && DeviceExploitAvailabilities.byOTAID(model.otaId); - this.setState({term, model, availability}); + let similar = false; + if (model && availability && availability.otaId !== model.otaId) { + similar = true; + } + return {term, model, similar, availability}; } } diff --git a/website/src/exploit.ts b/website/src/exploit.ts index b373ce5..13996fb 100644 --- a/website/src/exploit.ts +++ b/website/src/exploit.ts @@ -3,18 +3,18 @@ import {ExploitMethod} from "./app"; import {ExploitAvailability} from "../../src/library"; export function ExploitCard(exploit: ExploitMethod, avail: ExploitAvailability, firmware?: string) { - const patched = (avail.patched && firmware && firmware >= avail.patched.version) || false; - const mayPatched = !patched && (avail.latest && firmware && firmware > avail.latest.version) || false; + const patched = (avail.patched && (!firmware || firmware >= avail.patched.version)) || false; + const mayPatched = !patched && (!avail.latest || firmware && firmware > avail.latest.version) || false; const bgClass = patched ? 'bg-secondary-subtle opacity-75' : mayPatched ? 'bg-warning-subtle' : 'bg-primary-subtle'; const iconClass = patched ? 'bi-exclamation-octagon-fill' : mayPatched ? 'bi-question-octagon-fill' : 'bi-hand-thumbs-up-fill'; - return (html` + return html`

${exploit.name} - ${patched && html` (Patched)`} + ${patched ? html` (Patched)`: mayPatched && html` (Possibly patched)`}

${avail.latest && html`
@@ -33,6 +33,5 @@ export function ExploitCard(exploit: ExploitMethod, avail: ExploitAvailability,
`}
- ` - ); + `; } \ No newline at end of file diff --git a/website/src/hint.ts b/website/src/hint.ts index f98150d..4c741b2 100644 --- a/website/src/hint.ts +++ b/website/src/hint.ts @@ -34,7 +34,8 @@ export function SearchHint(term?: SearchTerm, model?: DeviceModel) { } if (model) { return html` -