Skip to content

Commit

Permalink
Upgrade jsonwebtoken lib (#18634)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanp413 authored Sep 6, 2023
1 parent 54205cf commit b24ae94
Show file tree
Hide file tree
Showing 49 changed files with 95 additions and 121 deletions.
2 changes: 1 addition & 1 deletion components/gitpod-protocol/src/gitpod-file-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { injectable } from "inversify";
import * as yaml from "js-yaml";
import * as Ajv from "ajv";
import Ajv from "ajv";
import { log } from "./util/logging";
import { WorkspaceConfig, PortRangeConfig } from "./protocol";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/

import * as ws from "ws";
import ws from "ws";
import {
IWebSocket,
Logger,
Expand Down
2 changes: 1 addition & 1 deletion components/gitpod-protocol/src/util/debug-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import * as http from "http";
import * as express from "express";
import express from "express";
import { injectable, postConstruct } from "inversify";
import { log, LogrusLogLevel } from "./logging";

Expand Down
5 changes: 3 additions & 2 deletions components/gitpod-protocol/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
"skipLibCheck": true,
"rootDir": "src",
"outDir": "lib",
"useUnknownInCatchVariables": false
"useUnknownInCatchVariables": false,
"esModuleInterop": true
},
"include": [
"src"
]
}
}
2 changes: 1 addition & 1 deletion components/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"redlock": "^5.0.0-beta.2",
"reflect-metadata": "^0.1.10",
"stripe": "^9.0.0",
"twilio": "^3.78.0",
"twilio": "^4.16.0",
"uuid": "^8.3.2",
"vscode-ws-jsonrpc": "^0.2.0",
"ws": "^7.4.6"
Expand Down
2 changes: 1 addition & 1 deletion components/server/src/api/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import * as http from "http";
import * as express from "express";
import express from "express";
import { log } from "@gitpod/gitpod-protocol/lib/util/logging";
import { inject, injectable } from "inversify";
import { APITeamsService } from "./teams";
Expand Down
2 changes: 1 addition & 1 deletion components/server/src/auth/auth-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* See License.AGPL.txt in the project root for license information.
*/

import * as express from "express";
import express from "express";
import { AuthProviderInfo, User, OAuth2Config, AuthProviderEntry } from "@gitpod/gitpod-protocol";

import { UserEnvVarValue } from "@gitpod/gitpod-protocol";
Expand Down
4 changes: 2 additions & 2 deletions components/server/src/auth/authenticator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import { TeamDB } from "@gitpod/gitpod-db/lib";
import { User } from "@gitpod/gitpod-protocol";
import { log } from "@gitpod/gitpod-protocol/lib/util/logging";
import * as express from "express";
import express from "express";
import { inject, injectable, postConstruct } from "inversify";
import * as passport from "passport";
import passport from "passport";
import { Config } from "../config";
import { reportLoginCompleted } from "../prometheus-metrics";
import { TokenProvider } from "../user/token-provider";
Expand Down
2 changes: 1 addition & 1 deletion components/server/src/auth/bearer-authenticator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { UserDB, PersonalAccessTokenDB } from "@gitpod/gitpod-db/lib";
import { GitpodTokenType, User } from "@gitpod/gitpod-protocol";
import { log } from "@gitpod/gitpod-protocol/lib/util/logging";
import * as crypto from "crypto";
import * as express from "express";
import express from "express";
import { IncomingHttpHeaders } from "http";
import { inject, injectable } from "inversify";
import { Config } from "../config";
Expand Down
6 changes: 3 additions & 3 deletions components/server/src/auth/generic-auth-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
*/

import { injectable, inject, postConstruct } from "inversify";
import * as express from "express";
import * as passport from "passport";
import * as OAuth2Strategy from "passport-oauth2";
import express from "express";
import passport from "passport";
import OAuth2Strategy from "passport-oauth2";
import { UserDB } from "@gitpod/gitpod-db/lib";
import { AuthProviderInfo, Identity, Token, User } from "@gitpod/gitpod-protocol";
import { log, LogContext } from "@gitpod/gitpod-protocol/lib/util/logging";
Expand Down
4 changes: 2 additions & 2 deletions components/server/src/auth/jwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* See License.AGPL.txt in the project root for license information.
*/

import * as jsonwebtoken from "jsonwebtoken";
import jsonwebtoken from "jsonwebtoken";
import { Config } from "../config";
import { inject, injectable, postConstruct } from "inversify";
import { AuthFlow } from "./auth-provider";
Expand Down Expand Up @@ -130,7 +130,7 @@ export async function verify(
if (err || !decoded) {
return reject(err);
}
resolve(decoded);
resolve(decoded as jsonwebtoken.JwtPayload);
});
});
}
Expand Down
2 changes: 1 addition & 1 deletion components/server/src/auth/login-completion-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { inject, injectable } from "inversify";
import * as express from "express";
import express from "express";
import { User } from "@gitpod/gitpod-protocol";
import { log, LogContext } from "@gitpod/gitpod-protocol/lib/util/logging";
import { Config } from "../config";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { AuthProviderInfo } from "@gitpod/gitpod-protocol";
import { log } from "@gitpod/gitpod-protocol/lib/util/logging";
import * as express from "express";
import express from "express";
import { inject, injectable } from "inversify";
import { AuthUserSetup } from "../auth/auth-provider";
import { GenericAuthProvider } from "../auth/generic-auth-provider";
Expand Down
2 changes: 1 addition & 1 deletion components/server/src/bitbucket/bitbucket-auth-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { AuthProviderInfo } from "@gitpod/gitpod-protocol";
import { log } from "@gitpod/gitpod-protocol/lib/util/logging";
import { Bitbucket } from "bitbucket";
import * as express from "express";
import express from "express";
import { injectable } from "inversify";
import { AuthUserSetup } from "../auth/auth-provider";
import { GenericAuthProvider } from "../auth/generic-auth-provider";
Expand Down
2 changes: 1 addition & 1 deletion components/server/src/code-sync/code-sync-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { status } from "@grpc/grpc-js";
import fetch from "node-fetch";
import { User } from "@gitpod/gitpod-protocol/lib/protocol";
import * as util from "util";
import * as express from "express";
import express from "express";
import { inject, injectable } from "inversify";
import { BearerAuth } from "../auth/bearer-authenticator";
import { isWithFunctionAccessGuard } from "../auth/function-access";
Expand Down
2 changes: 1 addition & 1 deletion components/server/src/dev/authenticator-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { AuthProviderInfo } from "@gitpod/gitpod-protocol";
import * as express from "express";
import express from "express";
import { injectable } from "inversify";
import { Strategy as DummyStrategy } from "passport-dummy";
import { AuthProvider } from "../auth/auth-provider";
Expand Down
2 changes: 1 addition & 1 deletion components/server/src/dev/passport-dummy.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

declare module "passport-dummy" {
import * as passport from "passport";
import passport from "passport";

export class Strategy extends passport.Strategy {
constructor(verify: (done: (error: any, user: any) => void) => void);
Expand Down
2 changes: 1 addition & 1 deletion components/server/src/express-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { URL } from "url";
import * as express from "express";
import express from "express";
import * as crypto from "crypto";

export const query = (...tuples: [string, string][]) => {
Expand Down
4 changes: 2 additions & 2 deletions components/server/src/express/ws-connection-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* See License.AGPL.txt in the project root for license information.
*/

import * as express from "express";
import * as websocket from "ws";
import express from "express";
import websocket from "ws";
import { Disposable, DisposableCollection } from "@gitpod/gitpod-protocol";
import { repeat } from "@gitpod/gitpod-protocol/lib/util/repeat";
import { log } from "@gitpod/gitpod-protocol/lib/util/logging";
Expand Down
20 changes: 10 additions & 10 deletions components/server/src/express/ws-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* See License.AGPL.txt in the project root for license information.
*/

import * as websocket from "ws";
import * as express from "express";
import WebSocket from "ws";
import express from "express";
import * as http from "http";
import * as https from "https";
import * as url from "url";
Expand All @@ -24,27 +24,27 @@ export interface WsNextFunction {
(err?: any): MaybePromise;
}
export interface WsRequestHandler {
(ws: websocket, req: express.Request, next: WsNextFunction): MaybePromise;
(ws: WebSocket, req: express.Request, next: WsNextFunction): MaybePromise;
}
export interface WsErrorHandler {
(err: any | undefined, ws: websocket, req: express.Request, next: WsNextFunction): MaybePromise;
(err: any | undefined, ws: WebSocket, req: express.Request, next: WsNextFunction): MaybePromise;
}
export type WsHandler = WsRequestHandler | WsErrorHandler;

export type WsConnectionFilter = websocket.VerifyClientCallbackAsync | websocket.VerifyClientCallbackSync;
export type WsConnectionFilter = WebSocket.VerifyClientCallbackAsync | WebSocket.VerifyClientCallbackSync;

interface Route {
matcher: RouteMatcher;
handler: (ws: websocket, req: express.Request) => void;
handler: (ws: WebSocket, req: express.Request) => void;
}

export class WsExpressHandler implements Disposable {
protected readonly wss: websocket.Server;
protected readonly wss: WebSocket.Server;
protected readonly routes: Route[] = [];
private disposables = new DisposableCollection();

constructor(protected readonly httpServer: HttpServer, protected readonly verifyClient?: WsConnectionFilter) {
this.wss = new websocket.Server({
this.wss = new WebSocket.Server({
verifyClient,
noServer: true,
// disabling to reduce memory consumption, cf.
Expand Down Expand Up @@ -78,11 +78,11 @@ export class WsExpressHandler implements Disposable {

ws(
matcher: RouteMatcher,
handler: (ws: websocket, request: express.Request) => void,
handler: (ws: WebSocket, request: express.Request) => void,
...handlers: WsHandler[]
): void {
const stack = WsLayer.createStack(...handlers);
const dispatch = (ws: websocket, request: express.Request) => {
const dispatch = (ws: WebSocket, request: express.Request) => {
handler(ws, request);
stack
.dispatch(ws, request)
Expand Down
4 changes: 2 additions & 2 deletions components/server/src/express/ws-layer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

require("reflect-metadata");

import * as ws from "ws";
import * as express from "express";
import ws from "ws";
import express from "express";

import { suite, test } from "@testdeck/mocha";
import * as chai from "chai";
Expand Down
4 changes: 2 additions & 2 deletions components/server/src/express/ws-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* See License.AGPL.txt in the project root for license information.
*/

import * as websocket from "ws";
import * as express from "express";
import websocket from "ws";
import express from "express";
import { WsHandler, WsRequestHandler, WsErrorHandler, WsNextFunction, MaybePromise } from "./ws-handler";
import { log } from "@gitpod/gitpod-protocol/lib/util/logging";

Expand Down
2 changes: 1 addition & 1 deletion components/server/src/github/github-auth-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { injectable } from "inversify";
import * as express from "express";
import express from "express";
import { AuthProviderInfo } from "@gitpod/gitpod-protocol";
import { log } from "@gitpod/gitpod-protocol/lib/util/logging";
import { GitHubScope } from "./scopes";
Expand Down
2 changes: 1 addition & 1 deletion components/server/src/gitlab/gitlab-auth-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* See License.AGPL.txt in the project root for license information.
*/

import * as express from "express";
import express from "express";
import { injectable } from "inversify";
import { log } from "@gitpod/gitpod-protocol/lib/util/logging";
import { AuthProviderInfo } from "@gitpod/gitpod-protocol";
Expand Down
6 changes: 3 additions & 3 deletions components/server/src/iam/iam-session-app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import { Config } from "../config";
import { Authenticator } from "../auth/authenticator";
import { UserAuthentication } from "../user/user-authentication";

import * as passport from "passport";
import * as express from "express";
import * as request from "supertest";
import passport from "passport";
import express from "express";
import request from "supertest";

import * as chai from "chai";
import { OIDCCreateSessionPayload } from "./iam-oidc-create-session-payload";
Expand Down
2 changes: 1 addition & 1 deletion components/server/src/iam/iam-session-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { injectable, inject } from "inversify";
import * as express from "express";
import express from "express";
import { SessionHandler } from "../session-handler";
import { Authenticator } from "../auth/authenticator";
import { UserAuthentication } from "../user/user-authentication";
Expand Down
2 changes: 1 addition & 1 deletion components/server/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ if (typeof (Symbol as any).asyncIterator === "undefined") {
(Symbol as any).asyncIterator = Symbol.asyncIterator || Symbol("asyncIterator");
}

import * as express from "express";
import express from "express";
import { Container } from "inversify";
import { Server } from "./server";
import { log, LogrusLogLevel } from "@gitpod/gitpod-protocol/lib/util/logging";
Expand Down
2 changes: 1 addition & 1 deletion components/server/src/liveness/liveness-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { injectable, inject } from "inversify";
import * as express from "express";
import express from "express";
import * as prom from "prom-client";
import { Config } from "../config";
import { log } from "@gitpod/gitpod-protocol/lib/util/logging";
Expand Down
2 changes: 1 addition & 1 deletion components/server/src/monitoring-endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* See License.AGPL.txt in the project root for license information.
*/

import * as express from "express";
import express from "express";
import { injectable } from "inversify";
import * as prometheusClient from "prom-client";
import { redisMetricsRegistry, registerDBMetrics } from "@gitpod/gitpod-db/lib";
Expand Down
2 changes: 1 addition & 1 deletion components/server/src/oauth-server/oauth-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { User } from "@gitpod/gitpod-protocol";
import { log } from "@gitpod/gitpod-protocol/lib/util/logging";
import { OAuthRequest, OAuthResponse } from "@jmondi/oauth2-server";
import { handleExpressResponse, handleExpressError } from "@jmondi/oauth2-server/dist/adapters/express";
import * as express from "express";
import express from "express";
import { inject, injectable } from "inversify";
import { URL } from "url";
import { Config } from "../config";
Expand Down
2 changes: 1 addition & 1 deletion components/server/src/one-time-secret-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { injectable, inject } from "inversify";
import * as express from "express";
import express from "express";
import { log } from "@gitpod/gitpod-protocol/lib/util/logging";
import { OneTimeSecretDB, DBWithTracing, TracedOneTimeSecretDB } from "@gitpod/gitpod-db/lib";
import { Disposable } from "@gitpod/gitpod-protocol";
Expand Down
2 changes: 1 addition & 1 deletion components/server/src/prebuilds/bitbucket-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* See License.AGPL.txt in the project root for license information.
*/

import * as express from "express";
import express from "express";
import { postConstruct, injectable, inject } from "inversify";
import { ProjectDB, TeamDB, WebhookEventDB } from "@gitpod/gitpod-db/lib";
import { User, StartPrebuildResult, CommitContext, CommitInfo, Project, WebhookEvent } from "@gitpod/gitpod-protocol";
Expand Down
2 changes: 1 addition & 1 deletion components/server/src/prebuilds/bitbucket-server-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* See License.AGPL.txt in the project root for license information.
*/

import * as express from "express";
import express from "express";
import { postConstruct, injectable, inject } from "inversify";
import { ProjectDB, TeamDB, WebhookEventDB } from "@gitpod/gitpod-db/lib";
import { PrebuildManager } from "./prebuild-manager";
Expand Down
2 changes: 1 addition & 1 deletion components/server/src/prebuilds/github-app-rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { injectable } from "inversify";
import { WorkspaceConfig, GithubAppConfig } from "@gitpod/gitpod-protocol";
import * as deepmerge from "deepmerge";
import deepmerge from "deepmerge";
import { log } from "@gitpod/gitpod-protocol/lib/util/logging";

const defaultConfig: GithubAppConfig = {
Expand Down
2 changes: 1 addition & 1 deletion components/server/src/prebuilds/github-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
TeamDB,
WebhookEventDB,
} from "@gitpod/gitpod-db/lib";
import * as express from "express";
import express from "express";
import { log, LogContext, LogrusLogLevel } from "@gitpod/gitpod-protocol/lib/util/logging";
import {
WorkspaceConfig,
Expand Down
Loading

0 comments on commit b24ae94

Please sign in to comment.