Skip to content

Commit

Permalink
BREAKING: Move to JSR
Browse files Browse the repository at this point in the history
  • Loading branch information
InkoHX committed Mar 9, 2024
1 parent fa6726a commit 5d712f5
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 166 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"deno.enable": true
"deno.enable": true,
"deno.unstable": true
}
8 changes: 2 additions & 6 deletions basic-auth/fetcher.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import {
assertInstanceOf,
assertSpyCalls,
assertStrictEquals,
stub,
} from "../deps_test.ts";
import { assertInstanceOf, assertStrictEquals } from "@std/assert";
import { assertSpyCalls, stub } from "@std/testing/mock";
import { fetcher as basicAuth } from "./fetcher.ts";

Deno.test('When calling fetch, the "Authorization" header must be set to the correct value.', async () => {
Expand Down
4 changes: 2 additions & 2 deletions basic-auth/fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { base64encode } from "../deps.ts";
import { encodeBase64 } from "@std/encoding/base64";
import { resolveURL } from "../utils/url.ts";

/**
Expand All @@ -21,7 +21,7 @@ import { resolveURL } from "../utils/url.ts";
* @param password your password
*/
export const fetcher = (username: string, password: string) => {
const token = base64encode(`${username}:${password}`);
const token = encodeBase64(`${username}:${password}`);

return (input: string | Request, init?: RequestInit) => {
const url = resolveURL(input);
Expand Down
113 changes: 0 additions & 113 deletions build.ts

This file was deleted.

23 changes: 11 additions & 12 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
{
"tasks": {
"build:node": "deno run -A ./build.ts"
},
"name": "@nexterias/twitter-api-fetch",
"version": "3.0.0",
"exports": "./mod.ts",
"lint": {
"files": {
"exclude": ["./npm", "./coverage"]
}
"exclude": ["./coverage"]
},
"fmt": {
"files": {
"exclude": ["./npm", "./coverage"]
}
"exclude": ["./coverage"]
},
"test": {
"files": {
"exclude": ["./npm", "./coverage"]
}
"exclude": ["./coverage"]
},
"imports": {
"@std/assert": "jsr:@std/assert@^0.219.1",
"@std/encoding": "jsr:@std/encoding@^0.219.1",
"@std/testing": "jsr:@std/testing@^0.219.1"
}
}
49 changes: 47 additions & 2 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion deps.ts

This file was deleted.

10 changes: 0 additions & 10 deletions deps_test.ts

This file was deleted.

2 changes: 1 addition & 1 deletion oauth1/hmac.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as hmac from "./hmac.ts";
import { assertStrictEquals } from "../deps_test.ts";
import { assertStrictEquals } from "@std/assert";
import * as oauth1a from "./oauth1a.ts";

const credentials = {
Expand Down
4 changes: 2 additions & 2 deletions oauth1/hmac.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
OAuth1aSignedParameters,
} from "./types.ts";
import * as percent from "../utils/percent.ts";
import { base64encode } from "../deps.ts";
import { encodeBase64 } from "@std/encoding/base64";

/**
* {@link https://developer.twitter.com/en/docs/authentication/oauth-1-0a/creating-a-signature Creating a signature | Docs | Twitter Developer Platform} - Getting a signing key
Expand Down Expand Up @@ -73,7 +73,7 @@ export const sign = async (
textEncoder.encode(message),
);

clonedParams.set("oauth_signature", base64encode(hash));
clonedParams.set("oauth_signature", encodeBase64(hash));

return clonedParams;
};
9 changes: 3 additions & 6 deletions oauth1/oauth1a.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import {
assertInstanceOf,
assertStrictEquals,
FakeTime,
stub,
} from "../deps_test.ts";
import { assertInstanceOf, assertStrictEquals } from "@std/assert";
import { stub } from "@std/testing/mock";
import { FakeTime } from "@std/testing/time";
import { createBaseParams, createHttpHeader } from "./oauth1a.ts";

Deno.test("createBaseParams", () => {
Expand Down
4 changes: 2 additions & 2 deletions oauth1/oauth1a.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { base64encode } from "../deps.ts";
import { encodeBase64 } from "@std/encoding/base64";
import { OAuth1aBaseParameters, OAuth1aSignedParameters } from "./types.ts";
import * as percent from "../utils/percent.ts";

Expand All @@ -10,7 +10,7 @@ export const createBaseParams = (

return new Map([
["oauth_consumer_key", consumerKey],
["oauth_nonce", base64encode(randomBytes)],
["oauth_nonce", encodeBase64(randomBytes)],
["oauth_timestamp", (Date.now() / 1000).toFixed(0)],
["oauth_token", accessToken],
["oauth_version", "1.0"],
Expand Down
8 changes: 2 additions & 6 deletions oauth2/fetcher.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import {
assertInstanceOf,
assertSpyCalls,
assertStrictEquals,
stub,
} from "../deps_test.ts";
import { assertInstanceOf, assertStrictEquals } from "@std/assert";
import { assertSpyCalls, stub } from "@std/testing/mock";
import { fetcher as oauth2 } from "./fetcher.ts";

Deno.test('When calling fetch, the "Authorization" header must be set to the correct value.', async () => {
Expand Down
2 changes: 1 addition & 1 deletion utils/percent.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertStrictEquals } from "../deps_test.ts";
import { assertStrictEquals } from "@std/assert";
import * as percent from "./percent.ts";

Deno.test("encode", () => {
Expand Down
2 changes: 1 addition & 1 deletion utils/url.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
assertInstanceOf,
assertStrictEquals,
assertThrows,
} from "../deps_test.ts";
} from "@std/assert";
import { resolveURL } from "./url.ts";

Deno.test("Returns URL (string) when a Request object is passed", () => {
Expand Down

0 comments on commit 5d712f5

Please sign in to comment.