-
-
Notifications
You must be signed in to change notification settings - Fork 709
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request from GHSA-4w9v-7h8h-rv8x
* migration to custom protocol * Update prompt.js * re-enable pretty URL display * allow cross origin access from browser UI * enable file protocol fuse * enable fuses in dev environment * don't use file protocol for NTP background * migrations from file to internal protocol * Fix update checks failing The redirect to the new domain was causing the origin header to be dropped, which was causing the request to be treated as cross-origin and failing * Update package.json * Update minInternalProtocol.js
- Loading branch information
Showing
20 changed files
with
172 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
const { pathToFileURL } = require('url') | ||
|
||
protocol.registerSchemesAsPrivileged([ | ||
{ | ||
scheme: 'min', | ||
privileges: { | ||
standard: true, | ||
secure: true, | ||
supportFetchAPI: true, | ||
} | ||
} | ||
]) | ||
|
||
function registerBundleProtocol (ses) { | ||
ses.protocol.handle('min', (req) => { | ||
let { host, pathname } = new URL(req.url) | ||
|
||
if (pathname.charAt(0) === '/') { | ||
pathname = pathname.substring(1) | ||
} | ||
|
||
if (host !== 'app') { | ||
return new Response('bad', { | ||
status: 400, | ||
headers: { 'content-type': 'text/html' } | ||
}) | ||
} | ||
|
||
// NB, this checks for paths that escape the bundle, e.g. | ||
// app://bundle/../../secret_file.txt | ||
const pathToServe = path.resolve(__dirname, pathname) | ||
const relativePath = path.relative(__dirname, pathToServe) | ||
const isSafe = relativePath && !relativePath.startsWith('..') && !path.isAbsolute(relativePath) | ||
|
||
if (!isSafe) { | ||
return new Response('bad', { | ||
status: 400, | ||
headers: { 'content-type': 'text/html' } | ||
}) | ||
} | ||
|
||
return net.fetch(pathToFileURL(pathToServe).toString()) | ||
}) | ||
} | ||
|
||
app.on('session-created', (ses) => { | ||
if (ses !== session.defaultSession) { | ||
registerBundleProtocol(ses) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.