Huge News!Announcing our $40M Series B led by Abstract Ventures.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 7.0.0 to 8.0.0-next.1628065794.b54a3b82f81100186780ea0f79388f5f891cb971

15

compiled-types/index.d.ts

@@ -99,4 +99,7 @@ import type { StrictUnion } from 'simplytyped';

* You probably want to use {@link fetch} directly, instead of going through this method.
* If the credentials property is nullish, then the environment variables are attempted.
*/
export declare function getURL(credentials: GitHubCredentials, props?: {
export declare function getURL(props?: {
credentials?: GitHubCredentials;
url?: string;
pathname?: string;

@@ -109,4 +112,7 @@ searchParams?: URLSearchParams | Record<string, string>;

* You probably want to use {@link fetch} directly, instead of going through this method.
* If the credentials property is nullish, then the environment variables are attempted.
*/
export declare function getCredentialedURL(credentials: GitHubCredentials, props?: {
export declare function getCredentialedURL(props?: {
credentials?: GitHubCredentials;
url?: string;
pathname?: string;

@@ -119,4 +125,7 @@ searchParams?: URLSearchParams | Record<string, string>;

* This is probably the method you want to use.
* If the credentials property is nullish, then the environment variables are attempted.
*/
export declare function fetch(credentials: GitHubCredentials, props?: {
export declare function fetch(props?: {
credentials?: GitHubCredentials;
url?: string;
pathname?: string;

@@ -123,0 +132,0 @@ searchParams?: URLSearchParams | Record<string, string>;

40

edition-browsers/index.js
import _fetch from 'node-fetch';
// defaults
import { env } from 'process';
const envCredentials = env;
/**

@@ -119,10 +122,13 @@ * Check whether or not sufficient GitHub credentials were supplied.

* You probably want to use {@link fetch} directly, instead of going through this method.
* If the credentials property is nullish, then the environment variables are attempted.
*/
export function getURL(credentials, props) {
// prepare
const hostname = credentials.GITHUB_API_URL ||
credentials.GITHUB_API ||
'https://api.github.com';
export function getURL(props = {}) {
// default credentials
if (props.credentials == null)
props = { ...props, credentials: envCredentials };
// fetch url
const url = new URL(hostname);
const url = new URL(props.url ||
props.credentials.GITHUB_API_URL ||
props.credentials.GITHUB_API ||
'https://api.github.com');
// add user params

@@ -157,8 +163,12 @@ if (props?.searchParams) {

* You probably want to use {@link fetch} directly, instead of going through this method.
* If the credentials property is nullish, then the environment variables are attempted.
*/
export function getCredentialedURL(credentials, props) {
export function getCredentialedURL(props = {}) {
// default credentials
if (props.credentials == null)
props = { ...props, credentials: envCredentials };
// fetch url
const url = getURL(credentials, props);
const url = getURL(props);
// add auth params
getSearchParams(credentials, url.searchParams);
getSearchParams(props.credentials, url.searchParams);
// return

@@ -171,9 +181,15 @@ return url;

* This is probably the method you want to use.
* If the credentials property is nullish, then the environment variables are attempted.
*/
export function fetch(credentials, props) {
const url = getURL(credentials, props);
export function fetch(props = {}) {
// default credentials
if (props.credentials == null)
props = { ...props, credentials: envCredentials };
// prep
const url = getURL(props);
const opts = {
headers: getHeaders(credentials, props && props.headers),
headers: getHeaders(props.credentials, props.headers),
};
// fetch and return
return _fetch(url, opts);
}
import _fetch from 'node-fetch';
// defaults
import { env } from 'process';
const envCredentials = env;
/**

@@ -119,10 +122,13 @@ * Check whether or not sufficient GitHub credentials were supplied.

* You probably want to use {@link fetch} directly, instead of going through this method.
* If the credentials property is nullish, then the environment variables are attempted.
*/
export function getURL(credentials, props) {
// prepare
const hostname = credentials.GITHUB_API_URL ||
credentials.GITHUB_API ||
'https://api.github.com';
export function getURL(props = {}) {
// default credentials
if (props.credentials == null)
props = { ...props, credentials: envCredentials };
// fetch url
const url = new URL(hostname);
const url = new URL(props.url ||
props.credentials.GITHUB_API_URL ||
props.credentials.GITHUB_API ||
'https://api.github.com');
// add user params

@@ -157,8 +163,12 @@ if (props === null || props === void 0 ? void 0 : props.searchParams) {

* You probably want to use {@link fetch} directly, instead of going through this method.
* If the credentials property is nullish, then the environment variables are attempted.
*/
export function getCredentialedURL(credentials, props) {
export function getCredentialedURL(props = {}) {
// default credentials
if (props.credentials == null)
props = { ...props, credentials: envCredentials };
// fetch url
const url = getURL(credentials, props);
const url = getURL(props);
// add auth params
getSearchParams(credentials, url.searchParams);
getSearchParams(props.credentials, url.searchParams);
// return

@@ -171,9 +181,15 @@ return url;

* This is probably the method you want to use.
* If the credentials property is nullish, then the environment variables are attempted.
*/
export function fetch(credentials, props) {
const url = getURL(credentials, props);
export function fetch(props = {}) {
// default credentials
if (props.credentials == null)
props = { ...props, credentials: envCredentials };
// prep
const url = getURL(props);
const opts = {
headers: getHeaders(credentials, props && props.headers),
headers: getHeaders(props.credentials, props.headers),
};
// fetch and return
return _fetch(url, opts);
}

@@ -8,2 +8,5 @@ "use strict";

const node_fetch_1 = __importDefault(require("node-fetch"));
// defaults
const process_1 = require("process");
const envCredentials = process_1.env;
/**

@@ -135,10 +138,13 @@ * Check whether or not sufficient GitHub credentials were supplied.

* You probably want to use {@link fetch} directly, instead of going through this method.
* If the credentials property is nullish, then the environment variables are attempted.
*/
function getURL(credentials, props) {
// prepare
const hostname = credentials.GITHUB_API_URL ||
credentials.GITHUB_API ||
'https://api.github.com';
function getURL(props = {}) {
// default credentials
if (props.credentials == null)
props = { ...props, credentials: envCredentials };
// fetch url
const url = new URL(hostname);
const url = new URL(props.url ||
props.credentials.GITHUB_API_URL ||
props.credentials.GITHUB_API ||
'https://api.github.com');
// add user params

@@ -174,8 +180,12 @@ if (props === null || props === void 0 ? void 0 : props.searchParams) {

* You probably want to use {@link fetch} directly, instead of going through this method.
* If the credentials property is nullish, then the environment variables are attempted.
*/
function getCredentialedURL(credentials, props) {
function getCredentialedURL(props = {}) {
// default credentials
if (props.credentials == null)
props = { ...props, credentials: envCredentials };
// fetch url
const url = getURL(credentials, props);
const url = getURL(props);
// add auth params
getSearchParams(credentials, url.searchParams);
getSearchParams(props.credentials, url.searchParams);
// return

@@ -189,10 +199,16 @@ return url;

* This is probably the method you want to use.
* If the credentials property is nullish, then the environment variables are attempted.
*/
function fetch(credentials, props) {
const url = getURL(credentials, props);
function fetch(props = {}) {
// default credentials
if (props.credentials == null)
props = { ...props, credentials: envCredentials };
// prep
const url = getURL(props);
const opts = {
headers: getHeaders(credentials, props && props.headers),
headers: getHeaders(props.credentials, props.headers),
};
// fetch and return
return node_fetch_1.default(url, opts);
}
exports.fetch = fetch;
# History
## v8.0.0 2021 August 4
- `getURL`, `getCredentialedURL`, and `fetch` now accept a single argument, which is the same as before but now supports `url` and `credentials` properties, and if `credentials` is nullish then it attempts to use the environment variables
## v7.0.0 2021 August 4

@@ -4,0 +8,0 @@

{
"name": "githubauthreq",
"version": "7.0.0",
"version": "8.0.0-next.1628065794.b54a3b82f81100186780ea0f79388f5f891cb971",
"description": "Authorize GitHub API requests with the appropriate credentials and preferences.",

@@ -212,2 +212,2 @@ "homepage": "https://github.com/bevry/githubauthreq",

}
}
}

@@ -44,10 +44,8 @@ <!-- TITLE/ -->

// imports using typescript
import { fetch, GitHubCredentials } from 'githubauthreq'
import { env } from 'process'
const githubCredentials = env as GitHubCredentials
import { fetch } from 'githubauthreq'
// fetches the GitHub API URL securely via headers authorization, so no redaction is necessary
fetch(githubCredentials, {
fetch({
pathname: `user`,
// searchParams, headers
// url, searchParams, headers, credentials = process.env as GitHubCredentials
})

@@ -61,8 +59,7 @@ ```

import { fetch } from 'githubauthreq'
import { env as githubCredentials } from 'process'
// fetches the GitHub API URL securely via headers authorization, so no redaction is necessary
fetch(githubCredentials, {
fetch({
pathname: `user`,
// searchParams, headers
// url, searchParams, headers, credentials = process.env
})

@@ -88,3 +85,3 @@ ```

<script type="module">
import * as pkg from '//cdn.skypack.dev/githubauthreq@^7.0.0'
import * as pkg from '//cdn.skypack.dev/githubauthreq@^8.0.0'
</script>

@@ -97,3 +94,3 @@ ```

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

@@ -106,3 +103,3 @@ ```

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

@@ -109,0 +106,0 @@ ```

@@ -5,2 +5,6 @@ // external

// defaults
import { env } from 'process'
const envCredentials = env as GitHubCredentials
/** If the variable `GITHUB_API_URL` or `GITHUB_API` exists, use that, otherwise use the value `https://api.github.com`. */

@@ -186,18 +190,23 @@ type GitHubApiUrl = StrictUnion<

* You probably want to use {@link fetch} directly, instead of going through this method.
* If the credentials property is nullish, then the environment variables are attempted.
*/
export function getURL(
credentials: GitHubCredentials,
props?: {
props: {
credentials?: GitHubCredentials
url?: string
pathname?: string
searchParams?: URLSearchParams | Record<string, string>
}
} = {}
) {
// prepare
const hostname =
credentials.GITHUB_API_URL ||
credentials.GITHUB_API ||
'https://api.github.com'
// default credentials
if (props.credentials == null)
props = { ...props, credentials: envCredentials }
// fetch url
const url = new URL(hostname)
const url = new URL(
props.url ||
props.credentials!.GITHUB_API_URL ||
props.credentials!.GITHUB_API ||
'https://api.github.com'
)

@@ -240,15 +249,21 @@ // add user params

* You probably want to use {@link fetch} directly, instead of going through this method.
* If the credentials property is nullish, then the environment variables are attempted.
*/
export function getCredentialedURL(
credentials: GitHubCredentials,
props?: {
props: {
credentials?: GitHubCredentials
url?: string
pathname?: string
searchParams?: URLSearchParams | Record<string, string>
}
} = {}
): URL {
// default credentials
if (props.credentials == null)
props = { ...props, credentials: envCredentials }
// fetch url
const url = getURL(credentials, props)
const url = getURL(props)
// add auth params
getSearchParams(credentials, url.searchParams)
getSearchParams(props.credentials!, url.searchParams)

@@ -263,16 +278,25 @@ // return

* This is probably the method you want to use.
* If the credentials property is nullish, then the environment variables are attempted.
*/
export function fetch(
credentials: GitHubCredentials,
props?: {
props: {
credentials?: GitHubCredentials
url?: string
pathname?: string
searchParams?: URLSearchParams | Record<string, string>
headers?: Record<string, string>
}
} = {}
) {
const url = getURL(credentials, props)
// default credentials
if (props.credentials == null)
props = { ...props, credentials: envCredentials }
// prep
const url = getURL(props)
const opts = {
headers: getHeaders(credentials, props && props.headers),
headers: getHeaders(props.credentials!, props.headers),
}
// fetch and return
return _fetch(url, opts)
}

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