Fallback to default client configuration if `requestConfigFromFrame` configuration is invalid

Aperta
#5,508 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
javascript
Ambito
frontend

Direzione di ricerca

Segui il percorso di avvio del client che legge requestConfigFromFrame e verifica come vengono convalidati i livelli degli antenati. Riproduci l'avvio diretto di H-VS con un ancestorLevel fuori intervallo, quindi verifica che la configurazione non valida venga ignorata con un avviso nella console, mentre la configurazione avviata tramite LMS continui a funzionare.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

scoping

The Hypothesis white-label VitalSource book reader at https://hypothesis.vitalsource.com is configured for use inside the Hypothesis LMS app. To enable the Hypothesis client to talk to our LMS app, the book reader frame that loads the client sets the requestConfigFromFrame key:

// `window.hypothesisConfig` function in the iframe where the client is loaded
function () {return {requestConfigFromFrame: {origin: "https://lms.hypothes.is",ancestorLevel: 3},openSidebar: true};} = $1

If you try to access a book at https://hypothesis.vitalsource.com directly, the client fails to load due to this configuration. It logs this error on startup:

Client config error

The preferred solution here would be that https://hypothesis.vitalsource.com changes the Hypothesis client configuration depending on whether it was launched by our LMS app or not:

  1. When launched by our LMS app, the H-VS book reader should use the above configuration
  2. Otherwise, the H-VS reader should omit the requestConfigFromFrame key

As a fallback we can implement purely on our side, ignore the requestConfigFromFrame configuration with a console warning if it is invalid (eg. specifies that the configuration should be retrieved from the ancestor N levels up the frame tree, and N is greater than the number of ancestors). The console warning is important in case the code path ever ends up getting executed when it shouldn't be.

Lingua principale
Mustache
Stelle
743
Fork
227
Merge medio
6m
PR unite (30g)
1

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di hypothesis/client

Tutte le issue di hypothesis/client

Issue simili

Altre issue su Web Dev

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.