xhook | Easily intercept and modify XHR request and response | REST library

 by   jpillora HTML Version: 1.6.2 License: MIT

kandi X-RAY | xhook Summary

kandi X-RAY | xhook Summary

xhook is a HTML library typically used in Web Services, REST applications. xhook has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.

Easily intercept and modify XHR request and response
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              xhook has a medium active ecosystem.
              It has 833 star(s) with 152 fork(s). There are 30 watchers for this library.
              There were 3 major release(s) in the last 12 months.
              There are 37 open issues and 62 have been closed. On average issues are closed in 132 days. There are 7 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of xhook is 1.6.2

            kandi-Quality Quality

              xhook has 0 bugs and 0 code smells.

            kandi-Security Security

              xhook has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              xhook code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              xhook is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              xhook releases are available to install and integrate.
              Installation instructions, examples and code snippets are available.
              xhook saves you 514 person hours of effort in developing the same functionality from scratch.
              It has 1207 lines of code, 0 functions and 51 files.
              It has low code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of xhook
            Get all kandi verified functions for this library.

            xhook Key Features

            No Key Features are available at this moment for xhook.

            xhook Examples and Code Snippets

            No Code Snippets are available at this moment for xhook.

            Community Discussions

            QUESTION

            How to set headers on native browser requests, or otherwise provide authorization headers while using Video.js to play video from Microsoft Azure?
            Asked 2021-Apr-27 at 09:38

            I am trying to load some video content from Microsoft Azure, using Video.js, and I need to add some headers for SharedKey authorization. I have been trying various methods and doing research for several days, but I am hitting brick walls and could really use some assistance.

            Important to note that this is for a mobile app written using Angular / Cordova.

            This is how Azure suggests that we do it:

            https://docs.microsoft.com/en-us/azure/media-services/latest/player-how-to-video-js-player

            Basically, by attaching a function to videojs.Hls.xhr.beforeRequest.

            Unfortunately, there are several problems with this approach. Here is a ticket in the videojs issue tracker trying to look for a solution to these issues:

            https://github.com/videojs/video.js/issues/7207

            In summary:

            1- We are not using HLS/DASH. We are loading mp4 files from blob storage. And videojs "hands that off directly to the browser, and it handles all loading of things while not providing this extra set of functionality."

            2- Even if we were to convert the media and use HLS, "this method won't be available because native playback is used for Safari with HLS.". (So do we need to use DASH? Or does that not work on Safari either?)

            3- There is still no way to add headers for Subtitle tracks, whether we use native subtitles, or add them through videojs.players.video.addRemoteTextTrack.

            I have also tried other alternative methods like

            1- Trying to use xhook to intercept it.

            2- Trying to use @angular/common/http/HttpInterceptor.

            Neither method worked.

            So, my questions would be:

            1- Is there a method I'm overlooking that would allow me to add / inject headers to requests being made natively by the browser?

            2- Could it perhaps be done with an authorization cookie? I have seen this mentioned in some other questions, but I couldn't find any concrete examples, and I'm not sure how it would work with Azure.

            3- If all else fails, is there another video player I could use that does provide better support in regards to authorization options?

            Any other suggestions would be also be appreciated. Thank you.

            ...

            ANSWER

            Answered 2021-Apr-27 at 09:38

            Considering you're serving a video file stored as a blob in Azure Storage directly, you can make use of Shared Access Signature (SAS). A SAS provides a time-limited, permission-bound access to a blob.

            The way it would work is when a user requests a video to be played, you will need to send a request to your backend service. Your backend service will create a SAS token for the blob with Read permission (only this permission is required to play the video) and some expiry date (depending on the length of the video). Your backend service will return the SAS URL for the blob (which would be something like blob-url?sas-token) which will be used by the video player to play the video.

            You can find more information about Shared Access Signature here: https://docs.microsoft.com/en-us/rest/api/storageservices/delegate-access-with-shared-access-signature. You will need to create a Service SAS for your blob.

            Source https://stackoverflow.com/questions/67277533

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install xhook

            :warning: It's important to include XHook first as other libraries may store a reference to XMLHttpRequest before XHook can patch it.
            Development xhook.js 14KB
            Production xhook.min.js 6KB
            CDN (Use latest or lock to one of the available versions) <script src="//unpkg.com/xhook@latest/dist/xhook.min.js"></script>

            Support

            Tested in IE8+, Chrome, Firefox, Safari.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
          • npm

            npm i xhook

          • CLONE
          • HTTPS

            https://github.com/jpillora/xhook.git

          • CLI

            gh repo clone jpillora/xhook

          • sshUrl

            git@github.com:jpillora/xhook.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular REST Libraries

            public-apis

            by public-apis

            json-server

            by typicode

            iptv

            by iptv-org

            fastapi

            by tiangolo

            beego

            by beego

            Try Top Libraries by jpillora

            chisel

            by jpilloraGo

            cloud-torrent

            by jpilloraGo

            xdomain

            by jpilloraJavaScript

            overseer

            by jpilloraGo

            notifyjs

            by jpilloraJavaScript