nwjs / nw.js

Call all Node.js modules directly from DOM/WebWorker and enable a new way of writing applications with all Web technologies.
https://nwjs.io
MIT License
40.16k stars 3.88k forks source link

Feat: Custom URL Schema Handlers not only app Protocol Handlers #8143

Open lemanschik opened 6 months ago

lemanschik commented 6 months ago

Issue Type

Before opening an issue, please search and see if it has already been raised.

Please use our mailing list or Gitter chatroom to ask questions. The issue tracker is only for bugs and feature requests, in English only. Please note that issues without a repro or code snippet are less likely to be resolved.

Current/Missing Behavior

Electron like custom url handler registration

Expected/Proposed Behavior

Lets add the patches from brave to implement custom url handling fast.

We currently have 3 different types of protocol handlers in Brave:

External protocol handler used for handling magnet URLs External protocol handlers used for oauth flows (cryptocurrency exchanges at the time of writing) brave:// being an alias for chrome:// Below is a description of changes and patching we've had to do for schemes:

AddAdditionalSchemes is only used for adding brave:// to the same list of URLs as chrome://. Example

GrantRequestScheme - Allows a webui to access it so no reason for that. Example

RegisterURLSchemeAsNotAllowingJavascriptURLs - Registers an URL scheme to not allow manipulation of the loaded page by bookmarklets or javascript: URLs typed in the omnibox. Example

RegisterURLSchemeAsDisplayIsolated - Registers a URL scheme to be treated as display-isolated. This means that pages cannot display these URLs unless they are from the same scheme. For example, pages in another origin cannot create iframes or hyperlinks to URLs with the scheme. Example

CanAddURLToHistory - Prevents a URL from being added to history, note that redirects do not appear in history. So this is probably not needed for oauth related schemes. Example

IsHandledProtocol - Needed for protocol handlers, but not needed for external protocol handlers. Example

ExtensionTabUtil::IsKillURL - This is only needed because brave:// is an alias for chrome:// and an explicit check is made. Example

taken from: https://github.com/brave/brave-browser/wiki/Adding-a-protocol-scheme-to-Brave

Additional Info

Closes

ayushmanchhabra commented 3 months ago

https://github.com/Shubham-Kumar-2000/protocol-registry ?

lemanschik commented 3 months ago

@ayushmanchhabra thats correct that looks at last ok in the 5 min that i reviewed it but i am not sure if it Handels all supported Platforms eg: MacOS, Windows and so on but general ya you got the right idea.

But you did not fully read and understand the issue there are diffrent types of protocol handlers

and the most importent type is not integrate able client side in js. the BiDirectional HTTP Like stream thats why i choosed the Issue text from brave to make that clear.