• Robert Knight's avatar
    Check annotator-sidebar version consistency and sidebar origin on startup · 7b38d746
    Robert Knight authored
    When deploying the new inter-frame communication code we saw errors [1]
    setting up communication between the sidebar and host frames caused by:
    
     - Mismatches between the version of the client used in the annotator
       and the sidebar
     - The sidebar being served from an unexpected origin (eg. due to use of
       a web proxy) or an opaque origin (eg. due to the host being loaded in a
       sandboxed iframe).
    
    In some cases these issues are beyond our control and we can't reasonably
    guarantee that the client will work.
    
    This commit adds checks for these issues when the sidebar launches. If the
    checks fail client startup is allowed to continue, but we log a warning in the
    browser console and disable Sentry error reporting to reduce noise.
    
     - Add `origin` parameter to `#config` fragment in sidebar and notebook
       app launch URLs, which contains the expected origin of the app
    
     - Check the `version` and `origin` parameters from the config fragment
       on app startup. If they don't match what is expected, log a warning
       and disable error reporting, but try and continue to minimize user
       inconvenience if it does work.
    
    [1] See https://github.com/hypothesis/client/issues/3986#issuecomment-989685057
        for more details.
    7b38d746
NotebookModal.js 3.53 KB