Skip to content

Commit

Permalink
feat: support unauthenticated requests (#59)
Browse files Browse the repository at this point in the history
GitHub API behaves differently for authenticated and unauthenticated
requests.

For example IP whitelisting for organisations is influenced by the type
of the request.

This will allow unauthenticated requests to GitHub API if `token: ""` is passed.
  • Loading branch information
maciekmm authored Nov 28, 2023
1 parent 5d24fa7 commit cdaf216
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13824,9 +13824,10 @@ var baseFetchAssetFile = async (octokit, { id, outputPath, owner, repo, token })
repo
});
let headers = {
accept,
authorization: `token ${token}`
accept
};
if (token !== "")
headers = { ...headers, authorization: `token ${token}` };
if (typeof userAgent !== "undefined")
headers = { ...headers, "user-agent": userAgent };
const response = await fetch(url, { body, headers, method });
Expand Down
4 changes: 3 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ const baseFetchAssetFile = async (
);
let headers: HeadersInit = {
accept,
authorization: `token ${token}`,
};
if (token !== '')
headers = { ...headers, authorization: `token ${token}` };

if (typeof userAgent !== 'undefined')
headers = { ...headers, 'user-agent': userAgent };

Expand Down

0 comments on commit cdaf216

Please sign in to comment.