Skip to content

Commit

Permalink
fix: fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
InkoHX committed Mar 9, 2024
1 parent 3da6313 commit 94fa3ac
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
5 changes: 4 additions & 1 deletion basic-auth/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ import { resolveURL } from "../utils/url.ts";
* @param username your email address
* @param password your password
*/
export const fetcher = (username: string, password: string) => {
export const fetcher = (
username: string,
password: string,
): (input: string | Request, init?: RequestInit) => Promise<Response> => {
const token = encodeBase64(`${username}:${password}`);

return (input: string | Request, init?: RequestInit) => {
Expand Down
6 changes: 5 additions & 1 deletion oauth1/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ import { resolveURL } from "../utils/url.ts";
* console.log(await response.json());
* ```
*/
export const fetcher = async (credentials: Readonly<OAuth1aCredential>) => {
export const fetcher = async (
credentials: Readonly<OAuth1aCredential>,
): Promise<
(input: string | Request, init?: RequestInit) => Promise<Response>
> => {
const signingKey = await createSigningKey({
secretAccessToken: credentials.secretAccessToken,
secretConsumerKey: credentials.secretConsumerKey,
Expand Down
4 changes: 2 additions & 2 deletions oauth1/hmac.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const combineKeys = (
OAuth1aCredential,
"secretAccessToken" | "secretConsumerKey"
>,
) =>
): string =>
[
credentials.secretConsumerKey,
credentials.secretAccessToken,
Expand All @@ -28,7 +28,7 @@ export const createSigningKey = (
OAuth1aCredential,
"secretAccessToken" | "secretConsumerKey"
>,
) => {
): Promise<CryptoKey> => {
const key = combineKeys(credentials);
const textEncoder = new TextEncoder();

Expand Down
4 changes: 3 additions & 1 deletion oauth2/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import { resolveURL } from "../utils/url.ts";
* console.log(await fetcher("/2/tweets"));
* ```
*/
export const fetcher = (bearerToken: string) => {
export const fetcher = (
bearerToken: string,
): (input: string | Request, init?: RequestInit) => Promise<Response> => {
return (input: string | Request, init?: RequestInit) => {
const url = resolveURL(input);
const request = new Request(url, init);
Expand Down
4 changes: 2 additions & 2 deletions utils/url.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
export const ALLOW_HOSTNAMES = new Set([
export const ALLOW_HOSTNAMES: Set<string> = new Set([
"gnip-stream.twitter.com",
"data-api.twitter.com",
"gnip-stream.gnip.com",
"api.twitter.com",
"gnip-api.twitter.com",
]);

export const resolveURL = (info: string | Request) => {
export const resolveURL = (info: string | Request): URL => {
const url = new URL(
typeof info === "string" ? info : info.url,
"https://api.twitter.com",
Expand Down

0 comments on commit 94fa3ac

Please sign in to comment.