Skip to content

Commit

Permalink
fix(electron-updater): use "NSAllowsLocalNetworking": true for macOS X
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Nov 7, 2018
1 parent 76fdd42 commit 10dd145
Show file tree
Hide file tree
Showing 8 changed files with 217 additions and 6 deletions.
6 changes: 5 additions & 1 deletion packages/app-builder-lib/src/electron/electronMac.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,19 +187,23 @@ function configureLocalhostAts(appPlist: any) {
appPlist.NSAppTransportSecurity = ats
}

ats.NSAllowsLocalNetworking = true

let exceptionDomains = ats.NSExceptionDomains
if (exceptionDomains == null) {
exceptionDomains = {}
ats.NSExceptionDomains = exceptionDomains
}

if (exceptionDomains.localhost == null) {
exceptionDomains.localhost = {
const allowHttp = {
NSTemporaryExceptionAllowsInsecureHTTPSLoads: false,
NSIncludesSubdomains: false,
NSTemporaryExceptionAllowsInsecureHTTPLoads: true,
NSTemporaryExceptionMinimumTLSVersion: "1.0",
NSTemporaryExceptionRequiresForwardSecrecy: false
}
exceptionDomains.localhost = allowHttp
exceptionDomains["127.0.0.1"] = allowHttp
}
}
5 changes: 2 additions & 3 deletions packages/electron-updater/src/MacUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class MacUpdater extends AppUpdater {

function getServerUrl() {
const address = server.address() as AddressInfo
return `http://localhost:${address.port}`
return `http://127.0.0.1:${address.port}`
}

return await this.executeDownload({
Expand Down Expand Up @@ -113,8 +113,7 @@ export class MacUpdater extends AppUpdater {
})
readStream.pipe(response)
})
// must be localhost, added to NSExceptionDomains
server.listen(0, "localhost", () => {
server.listen(0, "127.0.0.1", () => {
this.nativeUpdater.setFeedURL({
url: getServerUrl(),
headers: {"Cache-Control": "no-cache"},
Expand Down
24 changes: 24 additions & 0 deletions test/out/__snapshots__/PublishManagerTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,15 @@ Object {
"LSApplicationCategoryType": "your.app.category.type",
"LSMinimumSystemVersion": "10.9.0",
"NSAppTransportSecurity": Object {
"NSAllowsLocalNetworking": true,
"NSExceptionDomains": Object {
"127.0.0.1": Object {
"NSIncludesSubdomains": false,
"NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
"NSTemporaryExceptionAllowsInsecureHTTPSLoads": false,
"NSTemporaryExceptionMinimumTLSVersion": "1.0",
"NSTemporaryExceptionRequiresForwardSecrecy": false,
},
"localhost": Object {
"NSIncludesSubdomains": false,
"NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
Expand Down Expand Up @@ -268,7 +276,15 @@ Object {
"LSApplicationCategoryType": "your.app.category.type",
"LSMinimumSystemVersion": "10.9.0",
"NSAppTransportSecurity": Object {
"NSAllowsLocalNetworking": true,
"NSExceptionDomains": Object {
"127.0.0.1": Object {
"NSIncludesSubdomains": false,
"NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
"NSTemporaryExceptionAllowsInsecureHTTPSLoads": false,
"NSTemporaryExceptionMinimumTLSVersion": "1.0",
"NSTemporaryExceptionRequiresForwardSecrecy": false,
},
"localhost": Object {
"NSIncludesSubdomains": false,
"NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
Expand Down Expand Up @@ -338,7 +354,15 @@ Object {
"LSApplicationCategoryType": "your.app.category.type",
"LSMinimumSystemVersion": "10.9.0",
"NSAppTransportSecurity": Object {
"NSAllowsLocalNetworking": true,
"NSExceptionDomains": Object {
"127.0.0.1": Object {
"NSIncludesSubdomains": false,
"NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
"NSTemporaryExceptionAllowsInsecureHTTPSLoads": false,
"NSTemporaryExceptionMinimumTLSVersion": "1.0",
"NSTemporaryExceptionRequiresForwardSecrecy": false,
},
"localhost": Object {
"NSIncludesSubdomains": false,
"NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
Expand Down
104 changes: 104 additions & 0 deletions test/out/mac/__snapshots__/dmgTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,15 @@ Object {
"LSApplicationCategoryType": "your.app.category.type",
"LSMinimumSystemVersion": "10.9.0",
"NSAppTransportSecurity": Object {
"NSAllowsLocalNetworking": true,
"NSExceptionDomains": Object {
"127.0.0.1": Object {
"NSIncludesSubdomains": false,
"NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
"NSTemporaryExceptionAllowsInsecureHTTPSLoads": false,
"NSTemporaryExceptionMinimumTLSVersion": "1.0",
"NSTemporaryExceptionRequiresForwardSecrecy": false,
},
"localhost": Object {
"NSIncludesSubdomains": false,
"NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
Expand Down Expand Up @@ -82,7 +90,15 @@ Object {
"LSApplicationCategoryType": "your.app.category.type",
"LSMinimumSystemVersion": "10.9.0",
"NSAppTransportSecurity": Object {
"NSAllowsLocalNetworking": true,
"NSExceptionDomains": Object {
"127.0.0.1": Object {
"NSIncludesSubdomains": false,
"NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
"NSTemporaryExceptionAllowsInsecureHTTPSLoads": false,
"NSTemporaryExceptionMinimumTLSVersion": "1.0",
"NSTemporaryExceptionRequiresForwardSecrecy": false,
},
"localhost": Object {
"NSIncludesSubdomains": false,
"NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
Expand Down Expand Up @@ -129,7 +145,15 @@ Object {
"LSApplicationCategoryType": "your.app.category.type",
"LSMinimumSystemVersion": "10.9.0",
"NSAppTransportSecurity": Object {
"NSAllowsLocalNetworking": true,
"NSExceptionDomains": Object {
"127.0.0.1": Object {
"NSIncludesSubdomains": false,
"NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
"NSTemporaryExceptionAllowsInsecureHTTPSLoads": false,
"NSTemporaryExceptionMinimumTLSVersion": "1.0",
"NSTemporaryExceptionRequiresForwardSecrecy": false,
},
"localhost": Object {
"NSIncludesSubdomains": false,
"NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
Expand Down Expand Up @@ -2245,7 +2269,15 @@ Object {
"LSApplicationCategoryType": "your.app.category.type",
"LSMinimumSystemVersion": "10.9.0",
"NSAppTransportSecurity": Object {
"NSAllowsLocalNetworking": true,
"NSExceptionDomains": Object {
"127.0.0.1": Object {
"NSIncludesSubdomains": false,
"NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
"NSTemporaryExceptionAllowsInsecureHTTPSLoads": false,
"NSTemporaryExceptionMinimumTLSVersion": "1.0",
"NSTemporaryExceptionRequiresForwardSecrecy": false,
},
"localhost": Object {
"NSIncludesSubdomains": false,
"NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
Expand Down Expand Up @@ -2299,7 +2331,15 @@ Object {
"LSApplicationCategoryType": "your.app.category.type",
"LSMinimumSystemVersion": "10.9.0",
"NSAppTransportSecurity": Object {
"NSAllowsLocalNetworking": true,
"NSExceptionDomains": Object {
"127.0.0.1": Object {
"NSIncludesSubdomains": false,
"NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
"NSTemporaryExceptionAllowsInsecureHTTPSLoads": false,
"NSTemporaryExceptionMinimumTLSVersion": "1.0",
"NSTemporaryExceptionRequiresForwardSecrecy": false,
},
"localhost": Object {
"NSIncludesSubdomains": false,
"NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
Expand Down Expand Up @@ -2353,7 +2393,15 @@ Object {
"LSApplicationCategoryType": "your.app.category.type",
"LSMinimumSystemVersion": "10.9.0",
"NSAppTransportSecurity": Object {
"NSAllowsLocalNetworking": true,
"NSExceptionDomains": Object {
"127.0.0.1": Object {
"NSIncludesSubdomains": false,
"NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
"NSTemporaryExceptionAllowsInsecureHTTPSLoads": false,
"NSTemporaryExceptionMinimumTLSVersion": "1.0",
"NSTemporaryExceptionRequiresForwardSecrecy": false,
},
"localhost": Object {
"NSIncludesSubdomains": false,
"NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
Expand Down Expand Up @@ -2407,7 +2455,15 @@ Object {
"LSApplicationCategoryType": "your.app.category.type",
"LSMinimumSystemVersion": "10.9.0",
"NSAppTransportSecurity": Object {
"NSAllowsLocalNetworking": true,
"NSExceptionDomains": Object {
"127.0.0.1": Object {
"NSIncludesSubdomains": false,
"NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
"NSTemporaryExceptionAllowsInsecureHTTPSLoads": false,
"NSTemporaryExceptionMinimumTLSVersion": "1.0",
"NSTemporaryExceptionRequiresForwardSecrecy": false,
},
"localhost": Object {
"NSIncludesSubdomains": false,
"NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
Expand Down Expand Up @@ -2461,7 +2517,15 @@ Object {
"LSApplicationCategoryType": "your.app.category.type",
"LSMinimumSystemVersion": "10.9.0",
"NSAppTransportSecurity": Object {
"NSAllowsLocalNetworking": true,
"NSExceptionDomains": Object {
"127.0.0.1": Object {
"NSIncludesSubdomains": false,
"NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
"NSTemporaryExceptionAllowsInsecureHTTPSLoads": false,
"NSTemporaryExceptionMinimumTLSVersion": "1.0",
"NSTemporaryExceptionRequiresForwardSecrecy": false,
},
"localhost": Object {
"NSIncludesSubdomains": false,
"NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
Expand Down Expand Up @@ -2537,7 +2601,15 @@ Object {
"LSApplicationCategoryType": "your.app.category.type",
"LSMinimumSystemVersion": "10.9.0",
"NSAppTransportSecurity": Object {
"NSAllowsLocalNetworking": true,
"NSExceptionDomains": Object {
"127.0.0.1": Object {
"NSIncludesSubdomains": false,
"NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
"NSTemporaryExceptionAllowsInsecureHTTPSLoads": false,
"NSTemporaryExceptionMinimumTLSVersion": "1.0",
"NSTemporaryExceptionRequiresForwardSecrecy": false,
},
"localhost": Object {
"NSIncludesSubdomains": false,
"NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
Expand Down Expand Up @@ -2589,7 +2661,15 @@ Object {
"LSApplicationCategoryType": "your.app.category.type",
"LSMinimumSystemVersion": "10.9.0",
"NSAppTransportSecurity": Object {
"NSAllowsLocalNetworking": true,
"NSExceptionDomains": Object {
"127.0.0.1": Object {
"NSIncludesSubdomains": false,
"NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
"NSTemporaryExceptionAllowsInsecureHTTPSLoads": false,
"NSTemporaryExceptionMinimumTLSVersion": "1.0",
"NSTemporaryExceptionRequiresForwardSecrecy": false,
},
"localhost": Object {
"NSIncludesSubdomains": false,
"NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
Expand Down Expand Up @@ -2656,7 +2736,15 @@ Object {
"LSApplicationCategoryType": "your.app.category.type",
"LSMinimumSystemVersion": "10.9.0",
"NSAppTransportSecurity": Object {
"NSAllowsLocalNetworking": true,
"NSExceptionDomains": Object {
"127.0.0.1": Object {
"NSIncludesSubdomains": false,
"NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
"NSTemporaryExceptionAllowsInsecureHTTPSLoads": false,
"NSTemporaryExceptionMinimumTLSVersion": "1.0",
"NSTemporaryExceptionRequiresForwardSecrecy": false,
},
"localhost": Object {
"NSIncludesSubdomains": false,
"NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
Expand Down Expand Up @@ -2703,7 +2791,15 @@ Object {
"LSApplicationCategoryType": "your.app.category.type",
"LSMinimumSystemVersion": "10.9.0",
"NSAppTransportSecurity": Object {
"NSAllowsLocalNetworking": true,
"NSExceptionDomains": Object {
"127.0.0.1": Object {
"NSIncludesSubdomains": false,
"NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
"NSTemporaryExceptionAllowsInsecureHTTPSLoads": false,
"NSTemporaryExceptionMinimumTLSVersion": "1.0",
"NSTemporaryExceptionRequiresForwardSecrecy": false,
},
"localhost": Object {
"NSIncludesSubdomains": false,
"NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
Expand Down Expand Up @@ -2757,7 +2853,15 @@ Object {
"LSApplicationCategoryType": "your.app.category.type",
"LSMinimumSystemVersion": "10.9.0",
"NSAppTransportSecurity": Object {
"NSAllowsLocalNetworking": true,
"NSExceptionDomains": Object {
"127.0.0.1": Object {
"NSIncludesSubdomains": false,
"NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
"NSTemporaryExceptionAllowsInsecureHTTPSLoads": false,
"NSTemporaryExceptionMinimumTLSVersion": "1.0",
"NSTemporaryExceptionRequiresForwardSecrecy": false,
},
"localhost": Object {
"NSIncludesSubdomains": false,
"NSTemporaryExceptionAllowsInsecureHTTPLoads": true,
Expand Down
Loading

0 comments on commit 10dd145

Please sign in to comment.