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

githubauthreq

Package Overview
Dependencies
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

githubauthreq - npm Package Compare versions

Comparing version 5.0.0 to 5.1.0-next.1587956066.f0d0236ddc5b82e02c7613314827cd1e16e52b73

37

edition-browsers/index.js

@@ -5,9 +5,4 @@ /**

* @returns The query string that you should append to your github API request url. Will be an empty string if no valid credentials were provided.
* @example If your credentials are an arbitary object, then typecast like so:
* ``` typescript
* import {fetch, GitHubCredentials} from 'githubauthquerystring'
* fetch({} as GitHubCredentials)
* ```
*/
export function githubQueryString(credentials = process?.env) {
export function getParams(credentials = process?.env) {
if (credentials.GITHUB_ACCESS_TOKEN) {

@@ -21,3 +16,12 @@ return `access_token=${credentials.GITHUB_ACCESS_TOKEN}`

}
export function githubAuthorizationHeader(credentials = process?.env) {
// Aliases
export const githubQueryString = getParams
export const fetch = getParams
export default getParams
/**
* Fetch the GitHub Authorization Header.
* @param credentials If no credentials were passed, then the environment variables are used if they exist.
* @returns The Authorization header to attach to the request to the GitHub request.
*/
export function getAuthHeader(credentials = process?.env) {
if (credentials.GITHUB_ACCESS_TOKEN) {

@@ -31,8 +35,21 @@ return `token ${credentials.GITHUB_ACCESS_TOKEN}`

}
// Aliases
export const githubAuthorizationHeader = getAuthHeader
/**
* Fetch the headers to attach to the request to the GitHub API
* @param credentials If no credentials were passed, then the environment variables are used if they exist.
* @returns The headers to attach to the request to the GitHub request.
*/
export function getHeaders(credentials = process?.env) {
return {
Accept: 'application/vnd.github.v3+json',
Authorization: getAuthHeader(credentials),
}
}
/**
* Redact any github credentials from a string.
* @param value The string to redact credentials from.
* @return The string with the credentials redacted
* @returns The string with the credentials redacted
*/
export function redact(value) {
export function redactParams(value) {
return value.replace(

@@ -43,1 +60,3 @@ /(&?)(access_token|client_id|client_secret)=\w+/gi,

}
// Alias
export const redact = redactParams

@@ -7,9 +7,4 @@ 'use strict'

* @returns The query string that you should append to your github API request url. Will be an empty string if no valid credentials were provided.
* @example If your credentials are an arbitary object, then typecast like so:
* ``` typescript
* import {fetch, GitHubCredentials} from 'githubauthquerystring'
* fetch({} as GitHubCredentials)
* ```
*/
function githubQueryString(
function getParams(
credentials = process === null || process === void 0 ? void 0 : process.env

@@ -25,4 +20,13 @@ ) {

}
exports.githubQueryString = githubQueryString
function githubAuthorizationHeader(
exports.getParams = getParams
// Aliases
exports.githubQueryString = getParams
exports.fetch = getParams
exports.default = getParams
/**
* Fetch the GitHub Authorization Header.
* @param credentials If no credentials were passed, then the environment variables are used if they exist.
* @returns The Authorization header to attach to the request to the GitHub request.
*/
function getAuthHeader(
credentials = process === null || process === void 0 ? void 0 : process.env

@@ -38,9 +42,25 @@ ) {

}
exports.githubAuthorizationHeader = githubAuthorizationHeader
exports.getAuthHeader = getAuthHeader
// Aliases
exports.githubAuthorizationHeader = getAuthHeader
/**
* Fetch the headers to attach to the request to the GitHub API
* @param credentials If no credentials were passed, then the environment variables are used if they exist.
* @returns The headers to attach to the request to the GitHub request.
*/
function getHeaders(
credentials = process === null || process === void 0 ? void 0 : process.env
) {
return {
Accept: 'application/vnd.github.v3+json',
Authorization: getAuthHeader(credentials),
}
}
exports.getHeaders = getHeaders
/**
* Redact any github credentials from a string.
* @param value The string to redact credentials from.
* @return The string with the credentials redacted
* @returns The string with the credentials redacted
*/
function redact(value) {
function redactParams(value) {
return value.replace(

@@ -51,2 +71,4 @@ /(&?)(access_token|client_id|client_secret)=\w+/gi,

}
exports.redact = redact
exports.redactParams = redactParams
// Alias
exports.redact = redactParams
# History
## v5.1.0 2020 April 27
- Renamed `githubQueryString` to `getParams` with b/c alias for `githubQueryString`, `fetch`, and `default`
- Renamed `githubAuthorizationHeader` to `getAuthHeader` with b/c alias for `githubAuthorizationHeader`
- Renamed `redact` to `redactParams` with b/c alias for `redact`
- Added new `getHeaders`
## v5.0.0 2020 March 27

@@ -4,0 +11,0 @@

{
"name": "githubauthreq",
"version": "5.0.0",
"version": "5.1.0-next.1587956066.f0d0236ddc5b82e02c7613314827cd1e16e52b73",
"description": "Authorise GitHub API requests with the appropriate environment variables",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/bevry/githubauthreq",

@@ -47,6 +47,13 @@ <!-- TITLE/ -->

```javascript
import { githubAuthorizationHeader } from 'githubauthreq'
import { getHeaders } from 'githubauthreq'
fetch('https://api.github.com/user', {
headers: getHeaders(),
})
```
```javascript
import { getAuthHeader } from 'githubauthreq'
fetch('https://api.github.com/user', {
headers: {
Authorization: githubAuthorizationHeader(),
Authorization: getAuthHeader(),
Accept: 'application/vnd.github.v3+json',

@@ -62,4 +69,4 @@ },

```javascript
import { githubQueryString } from 'githubauthreq'
fetch(`https://api.github.com/user?${githubQueryString()}`, {
import { getParams } from 'githubauthreq'
fetch(`https://api.github.com/user?${getParams()}`, {
headers: {

@@ -73,3 +80,3 @@ Accept: 'application/vnd.github.v3+json',

Both `githubAuthorizationHeader` and `githubQueryString` accept an object containing either:
Both `getAuthHeader` and `getParams` accept an object containing either:

@@ -86,8 +93,8 @@ - `GITHUB_ACCESS_TOKEN`

```javascript
import { githubQueryString, redact } from 'githubauthreq'
fetch(`https://api.github.com/user?${githubQueryString()}`, {
import { getParams, redactParams } from 'githubauthreq'
fetch(`https://api.github.com/user?${getParams()}`, {
headers: {
Accept: 'application/vnd.github.v3+json',
},
}).catch((err) => console.error(redact(err.message)))
}).catch((err) => console.error(redactParams(err.message)))
```

@@ -110,3 +117,3 @@

<script type="module">
import * as pkg from '//cdn.pika.dev/githubauthreq/^5.0.0'
import * as pkg from '//cdn.pika.dev/githubauthreq/^5.1.0'
</script>

@@ -119,3 +126,3 @@ ```

<script type="module">
import * as pkg from '//unpkg.com/githubauthreq@^5.0.0'
import * as pkg from '//unpkg.com/githubauthreq@^5.1.0'
</script>

@@ -128,3 +135,3 @@ ```

<script type="module">
import * as pkg from '//dev.jspm.io/githubauthreq@5.0.0'
import * as pkg from '//dev.jspm.io/githubauthreq@5.1.0'
</script>

@@ -131,0 +138,0 @@ ```

@@ -33,9 +33,4 @@ import type { StrictUnion } from 'simplytyped'

* @returns The query string that you should append to your github API request url. Will be an empty string if no valid credentials were provided.
* @example If your credentials are an arbitary object, then typecast like so:
* ``` typescript
* import {fetch, GitHubCredentials} from 'githubauthquerystring'
* fetch({} as GitHubCredentials)
* ```
*/
export function githubQueryString(
export function getParams(
credentials: GitHubCredentials = process?.env as GitHubEnv

@@ -52,3 +47,13 @@ ) {

export function githubAuthorizationHeader(
// Aliases
export const githubQueryString = getParams
export const fetch = getParams
export default getParams
/**
* Fetch the GitHub Authorization Header.
* @param credentials If no credentials were passed, then the environment variables are used if they exist.
* @returns The Authorization header to attach to the request to the GitHub request.
*/
export function getAuthHeader(
credentials: GitHubCredentials = process?.env as GitHubEnv

@@ -64,8 +69,26 @@ ) {

}
// Aliases
export const githubAuthorizationHeader = getAuthHeader
/**
* Fetch the headers to attach to the request to the GitHub API
* @param credentials If no credentials were passed, then the environment variables are used if they exist.
* @returns The headers to attach to the request to the GitHub request.
*/
export function getHeaders(
credentials: GitHubCredentials = process?.env as GitHubEnv
) {
return {
Accept: 'application/vnd.github.v3+json',
Authorization: getAuthHeader(credentials),
}
}
/**
* Redact any github credentials from a string.
* @param value The string to redact credentials from.
* @return The string with the credentials redacted
* @returns The string with the credentials redacted
*/
export function redact(value: string) {
export function redactParams(value: string) {
return value.replace(

@@ -76,1 +99,4 @@ /(&?)(access_token|client_id|client_secret)=\w+/gi,

}
// Alias
export const redact = redactParams
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