On macOS 10 however, the process is a little more involved. A method will be appended to navigator.duckduckgo
that allows the response to be delivered there instead. It's not exactly this, but you can visualize the flow
as being something along the lines of:
// add the callback method to navigator.duckduckgo navigator.duckduckgo["_0123456"] = (response) => { // decrypt `response` and deliver the result to the caller here // then remove the temporary method deletenavigator.duckduckgo['_0123456'] };
// later in swift, the following JavaScript snippet will be executed (() => { navigator.duckduckgo['_0123456']({ ciphertext: [12, 13, 4], tag: [3, 5, 67, 56] }) })()
Example
On macOS 11+, this will just call through to
window.webkit.messageHandlers.x.postMessageEg: for a
foomessage defined in Swift that accepted the payload{"bar": "baz"}, the following would occur:Example
On macOS 10 however, the process is a little more involved. A method will be appended to
navigator.duckduckgothat allows the response to be delivered there instead. It's not exactly this, but you can visualize the flow as being something along the lines of: