Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/fetchers/tarball-fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,18 @@ export default class TarballFetcher extends BaseFetcher {
fetchFromExternal(): Promise<FetchedOverride> {
const {reference: ref} = this;

const headers: Object = {
'Accept-Encoding': 'gzip',
'Accept': 'application/octet-stream',
};

if (this.remote.auth && this.remote.auth.token) {
headers.authorization = `Bearer ${this.remote.auth.token}`;
}

return this.config.requestManager.request({
url: ref,
headers: {
'Accept-Encoding': 'gzip',
'Accept': 'application/octet-stream',
},
headers,
buffer: true,
process: (req, resolve, reject) => {
// should we save this to the offline cache?
Expand Down
4 changes: 4 additions & 0 deletions src/registries/npm-registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ export default class NpmRegistry extends Registry {
await fs.mkdirp(mirrorLoc);
}

if (config['_auth']) {
this.token = config['_auth'];
}

defaults(this.config, config);
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/resolvers/registries/npm-resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ export default class NpmResolver extends RegistryResolver {
reference: dist.tarball,
hash: dist.shasum,
registry: 'npm',
auth: {
token: this.config.registries.npm.token,
},
};
}

Expand Down
6 changes: 6 additions & 0 deletions src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ export type PackageRemote = {
reference: string,
resolved?: ?string,
hash?: ?string,
auth?: {
email?: string,
username?: string,
password?: string,
token?: string,
}
};

// `dependencies` field in package info
Expand Down