New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

github-username

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github-username - npm Package Compare versions

Comparing version 4.0.0 to 4.1.0

26

index.js
'use strict';
const ghGot = require('gh-got');
function searchCommits(email, token) {
return ghGot('search/commits', {
token,
query: {
q: `author-email:${email}`,
sort: 'author-date',
// eslint-disable-next-line camelcase
per_page: 1
},
headers: {
accept: 'application/vnd.github.cloak-preview',
'user-agent': 'https://github.com/sindresorhus/github-username'
}
}).then(result => {
const data = result.body;
if (data.total_count === 0) {
throw new Error(`Couldn't find username for \`${email}\``);
}
return data.items[0].author.login;
});
}
module.exports = (email, token) => {

@@ -21,3 +45,3 @@ if (!(typeof email === 'string' && email.includes('@'))) {

if (data.total_count === 0) {
throw new Error(`Couldn't find username for \`${email}\``);
return searchCommits(email, token);
}

@@ -24,0 +48,0 @@

4

package.json
{
"name": "github-username",
"version": "4.0.0",
"version": "4.1.0",
"description": "Get a GitHub username from an email address",

@@ -31,3 +31,3 @@ "license": "MIT",

"dependencies": {
"gh-got": "^5.0.0"
"gh-got": "^6.0.0"
},

@@ -34,0 +34,0 @@ "devDependencies": {

@@ -5,9 +5,7 @@ # github-username [![Build Status](https://travis-ci.org/sindresorhus/github-username.svg?branch=master)](https://travis-ci.org/sindresorhus/github-username)

*Only works for users that have their email publicly listed on their profile.*
## Install
```
$ npm install --save github-username
$ npm install github-username
```

@@ -42,3 +40,3 @@

Type: `string`
Type: `string`

@@ -45,0 +43,0 @@ GitHub [personal access token](https://github.com/settings/tokens/new).

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc