mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-16 21:56:25 -05:00
download packages using https
Or, in general, the same protocol as the registry; this is what npm seem to be doing. See issue #166 for details.
This commit is contained in:
parent
09318d1943
commit
ed3eb37c4f
3 changed files with 26 additions and 9 deletions
|
@ -152,10 +152,24 @@ Storage.prototype.update_versions = function(name, newdata, callback) {
|
|||
var filename = URL.parse(verdata.dist.tarball).pathname.replace(/^.*\//, '')
|
||||
// we do NOT overwrite any existing records
|
||||
if (data._distfiles[filename] == null) {
|
||||
data._distfiles[filename] = {
|
||||
var hash = data._distfiles[filename] = {
|
||||
url: verdata.dist.tarball,
|
||||
sha: verdata.dist.shasum,
|
||||
}
|
||||
|
||||
if (verdata._sinopia_uplink) {
|
||||
// if we got this information from a known registry,
|
||||
// use the same protocol for the tarball
|
||||
//
|
||||
// see https://github.com/rlidwka/sinopia/issues/166
|
||||
var tarball_url = URL.parse(hash.url)
|
||||
var uplink_url = URL.parse(self.config.uplinks[verdata._sinopia_uplink].url)
|
||||
if (uplink_url.host === tarball_url.host) {
|
||||
tarball_url.protocol = uplink_url.protocol
|
||||
hash.registry = verdata._sinopia_uplink
|
||||
hash.url = URL.format(tarball_url)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -493,6 +493,17 @@ Storage.prototype._sync_package_with_uplinks = function(name, pkginfo, options,
|
|||
fetched: Date.now()
|
||||
}
|
||||
|
||||
for (var i in up_res.versions) {
|
||||
// this won't be serialized to json,
|
||||
// kinda like an ES6 Symbol
|
||||
Object.defineProperty(up_res.versions[i], '_sinopia_uplink', {
|
||||
value : up.upname,
|
||||
enumerable : false,
|
||||
configurable : false,
|
||||
writable : true,
|
||||
})
|
||||
}
|
||||
|
||||
try {
|
||||
Storage._merge_versions(pkginfo, up_res, self.config)
|
||||
} catch(err) {
|
||||
|
|
|
@ -25,14 +25,6 @@ function Storage(config, mainconfig) {
|
|||
self.server_id = mainconfig.server_id
|
||||
|
||||
self.url = URL.parse(self.config.url)
|
||||
if (self.url.hostname === 'registry.npmjs.org') {
|
||||
// npm registry is too slow working with ssl :(
|
||||
/*if (self.config._autogenerated) {
|
||||
// encrypt all the things!
|
||||
self.url.protocol = 'https'
|
||||
self.config.url = URL.format(self.url)
|
||||
}*/
|
||||
}
|
||||
|
||||
_setupProxy.call(self, self.url.hostname, config, mainconfig, self.url.protocol === 'https:')
|
||||
|
||||
|
|
Loading…
Reference in a new issue