Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1803304

Browse filesBrowse files
fix(deps): bump Octokit dependencies to mitigate ReDos, devDependency modernization, bump prettier (#318)
* maint: modernize devDependencies * chore(deps): update dependency prettier to v3.5.1 * fix(deps): bump Octokit dependencies to mitigate ReDos --------- Co-authored-by: wolfy1339 <webmaster@wolfy1339.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
1 parent b827dee commit 1803304
Copy full SHA for 1803304

File tree

Expand file treeCollapse file tree

8 files changed

+1880
-4164
lines changed
Filter options
Expand file treeCollapse file tree

8 files changed

+1880
-4164
lines changed

‎package-lock.json

Copy file name to clipboardExpand all lines: package-lock.json
+1,823-4,105Lines changed: 1823 additions & 4105 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

Copy file name to clipboardExpand all lines: package.json
+9-44Lines changed: 9 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"lint": "prettier --check '{src,test,scripts}/**/*' README.md package.json",
1313
"lint:fix": "prettier --write '{src,test,scripts}/**/*' README.md package.json",
1414
"pretest": "npm run -s lint",
15-
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest --coverage"
15+
"test": "vitest run --coverage"
1616
},
1717
"repository": "https://github.com/octokit/auth-oauth-user.js",
1818
"keywords": [
@@ -24,62 +24,27 @@
2424
"author": "Gregor Martynus (https://dev.to/gr2m)",
2525
"license": "MIT",
2626
"dependencies": {
27-
"@octokit/auth-oauth-device": "^7.1.2",
28-
"@octokit/oauth-methods": "^5.1.2",
29-
"@octokit/request": "^9.1.4",
27+
"@octokit/auth-oauth-device": "^7.1.3",
28+
"@octokit/oauth-methods": "^5.1.3",
29+
"@octokit/request": "^9.2.1",
3030
"@octokit/types": "^13.6.2",
3131
"universal-user-agent": "^7.0.0"
3232
},
3333
"devDependencies": {
3434
"@octokit/core": "^6.1.3",
3535
"@octokit/tsconfig": "^4.0.0",
36-
"@types/jest": "^29.0.0",
3736
"@types/node": "^22.0.0",
37+
"@vitest/coverage-v8": "^2.1.8",
3838
"esbuild": "^0.25.0",
39-
"fetch-mock": "npm:@gr2m/fetch-mock@9.11.0-pull-request-644.1",
39+
"fetch-mock": "^11.0.0",
4040
"glob": "^11.0.0",
41-
"jest": "^29.0.0",
4241
"mockdate": "^3.0.4",
43-
"prettier": "3.4.2",
42+
"prettier": "3.5.1",
4443
"semantic-release-plugin-update-version-in-files": "^1.1.0",
45-
"ts-jest": "^29.0.0",
46-
"typescript": "^5.0.0"
47-
},
48-
"jest": {
49-
"extensionsToTreatAsEsm": [
50-
".ts"
51-
],
52-
"transform": {
53-
"^.+\\.(ts|tsx)$": [
54-
"ts-jest",
55-
{
56-
"tsconfig": "test/tsconfig.test.json",
57-
"useESM": true
58-
}
59-
]
60-
},
61-
"coverageThreshold": {
62-
"global": {
63-
"statements": 100,
64-
"branches": 100,
65-
"functions": 100,
66-
"lines": 100
67-
}
68-
},
69-
"moduleNameMapper": {
70-
"^(.+)\\.jsx?$": "$1"
71-
}
44+
"typescript": "^5.0.0",
45+
"vitest": "^2.1.8"
7246
},
7347
"release": {
74-
"branches": [
75-
"+([0-9]).x",
76-
"main",
77-
"next",
78-
{
79-
"name": "beta",
80-
"prerelease": true
81-
}
82-
],
8348
"plugins": [
8449
"@semantic-release/commit-analyzer",
8550
"@semantic-release/release-notes-generator",

‎src/auth.ts

Copy file name to clipboardExpand all lines: src/auth.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export async function auth(
117117
| GitHubAppAuthentication
118118
| GitHubAppAuthenticationWithExpiration;
119119
} catch (error: any) {
120-
// istanbul ignore else
120+
/* v8 ignore next 5 */
121121
if (error.status === 404) {
122122
error.message = "[@octokit/auth-oauth-user] Token is invalid";
123123

@@ -143,7 +143,7 @@ export async function auth(
143143
request: state.request,
144144
});
145145
} catch (error: any) {
146-
// istanbul ignore if
146+
/* v8 ignore next */
147147
if (error.status !== 404) throw error;
148148
}
149149

‎src/types.ts

Copy file name to clipboardExpand all lines: src/types.ts
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import * as OctokitTypes from "@octokit/types";
2-
import * as DeviceTypes from "@octokit/auth-oauth-device";
3-
import * as OAuthMethodsTypes from "@octokit/oauth-methods";
1+
import type * as OctokitTypes from "@octokit/types";
2+
import type * as DeviceTypes from "@octokit/auth-oauth-device";
3+
import type * as OAuthMethodsTypes from "@octokit/oauth-methods";
44

55
export type ClientType = "oauth-app" | "github-app";
66

‎test/octokit.test.ts

Copy file name to clipboardExpand all lines: test/octokit.test.ts
+26-7Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1+
import { describe, expect, it, test } from "vitest";
12
import { Octokit } from "@octokit/core";
2-
import fetchMock, { type MockMatcherFunction } from "fetch-mock";
3+
import fetchMock from "fetch-mock";
34

45
import { createOAuthUserAuth } from "../src/index.js";
56

67
describe("Octokit + OAuth web flow", () => {
78
it("README example", async () => {
8-
const matchCreateTokenRequest: MockMatcherFunction = (url, options) => {
9+
const matchCreateTokenRequest: fetchMock.MockMatcherFunction = (
10+
url,
11+
options,
12+
) => {
913
expect(url).toEqual("https://github.com/login/oauth/access_token");
1014
expect(options.headers).toEqual(
1115
expect.objectContaining({
@@ -17,7 +21,10 @@ describe("Octokit + OAuth web flow", () => {
1721
return true;
1822
};
1923

20-
const matchGetUserRequest: MockMatcherFunction = (url, options) => {
24+
const matchGetUserRequest: fetchMock.MockMatcherFunction = (
25+
url,
26+
options,
27+
) => {
2128
expect(url).toEqual("https://api.github.com/user");
2229
expect(options.headers).toEqual(
2330
expect.objectContaining({
@@ -61,7 +68,10 @@ describe("Octokit + OAuth web flow", () => {
6168
});
6269

6370
it("GitHub App auth", async () => {
64-
const matchCreateTokenRequest: MockMatcherFunction = (url, options) => {
71+
const matchCreateTokenRequest: fetchMock.MockMatcherFunction = (
72+
url,
73+
options,
74+
) => {
6575
expect(url).toEqual("https://github.com/login/oauth/access_token");
6676
expect(options.headers).toEqual(
6777
expect.objectContaining({
@@ -73,7 +83,10 @@ describe("Octokit + OAuth web flow", () => {
7383
return true;
7484
};
7585

76-
const matchGetUserRequest: MockMatcherFunction = (url, options) => {
86+
const matchGetUserRequest: fetchMock.MockMatcherFunction = (
87+
url,
88+
options,
89+
) => {
7790
expect(url).toEqual("https://api.github.com/user");
7891
expect(options.headers).toEqual(
7992
expect.objectContaining({
@@ -119,7 +132,10 @@ describe("Octokit + OAuth web flow", () => {
119132
});
120133

121134
test("Sets clientId/clientSecret as Basic auth for /authentication/{clientId}/* requests", async () => {
122-
const matchCheckTokenRequest: MockMatcherFunction = (url, options) => {
135+
const matchCheckTokenRequest: fetchMock.MockMatcherFunction = (
136+
url,
137+
options,
138+
) => {
123139
expect(url).toEqual(
124140
"https://api.github.com/applications/1234567890abcdef1234/token",
125141
);
@@ -166,7 +182,10 @@ test("Sets clientId/clientSecret as Basic auth for /authentication/{clientId}/*
166182
});
167183

168184
test("Sets no auth for OAuth Web flow requests", async () => {
169-
const matchCreateTokenRequest: MockMatcherFunction = (url, options) => {
185+
const matchCreateTokenRequest: fetchMock.MockMatcherFunction = (
186+
url,
187+
options,
188+
) => {
170189
expect(url).toEqual("https://github.com/login/oauth/access_token");
171190
// @ts-ignore
172191
expect(options.headers.authorization).toBeUndefined();

‎test/smoke.test.ts

Copy file name to clipboardExpand all lines: test/smoke.test.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, expect, it } from "vitest";
12
import { createOAuthUserAuth, requiresBasicAuth } from "../src/index.js";
23

34
describe("Smoke test", () => {

‎test/standalone.test.ts

Copy file name to clipboardExpand all lines: test/standalone.test.ts
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import { describe, expect, it, test, vi } from "vitest";
12
import fetchMock from "fetch-mock";
23
import MockDate from "mockdate";
34
import { request } from "@octokit/request";
4-
import { jest } from "@jest/globals";
55

66
import { createOAuthUserAuth } from "../src/index.js";
77

@@ -187,7 +187,7 @@ describe("OAuth device flow", () => {
187187
user_code: "usercode123",
188188
verification_uri: "https://github.com/login/device",
189189
expires_in: 900,
190-
// use low number because jest.useFakeTimers() & jest.runAllTimers() didn't work for me
190+
// use low number because vi.useFakeTimers() & vi.runAllTimers() didn't work for me
191191
interval: 0.005,
192192
},
193193
{
@@ -223,7 +223,7 @@ describe("OAuth device flow", () => {
223223
},
224224
);
225225

226-
const onVerification = jest.fn();
226+
const onVerification = vi.fn();
227227
const auth = createOAuthUserAuth({
228228
clientId: "1234567890abcdef1234",
229229
clientSecret: "secret",

‎vite.config.js

Copy file name to clipboard
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { defineConfig } from "vite";
2+
3+
export default defineConfig({
4+
test: {
5+
coverage: {
6+
include: ["src/**/*.ts"],
7+
reporter: ["html"],
8+
thresholds: {
9+
100: true,
10+
},
11+
},
12+
},
13+
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.