Skip to content

refactor: Refactor service module to TS + ESM #1063

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
e0c61ca
refactor(ts): OIDC passport strategy
jescalada Jun 24, 2025
75c4b25
refactor(ts): local passport strategy
jescalada Jun 24, 2025
ba0dad1
refactor(ts): AD passport strategy and test fixes
jescalada Jun 24, 2025
60b51c8
refactor(ts): passport helper files
jescalada Jun 25, 2025
c93fe25
refactor(ts): JWT auth handler and main passport handler
jescalada Jun 25, 2025
4706ee5
chore(ts): add types for JWT-related libraries
jescalada Jun 25, 2025
d94d1db
refactor(ts): service helper functions
jescalada Jun 26, 2025
19049eb
refactor(ts): service module auth routes
jescalada Jun 26, 2025
a2b5aae
refactor(ts): service index file
jescalada Jun 27, 2025
08269c8
ts(refactor): service push routes
jescalada Jun 27, 2025
885c061
refactor(ts): service module helpers and minor fixes
jescalada Jun 27, 2025
c7502b2
refactor(ts): service repo routes, add missing library types
jescalada Jun 27, 2025
b632de5
refactor(ts): service module users routes
jescalada Jun 27, 2025
6e5a933
Merge remote-tracking branch 'origin/main' into refactor-service-to-ts
jescalada Jun 29, 2025
d5ee52d
chore: add AD type for passport
jescalada Jun 29, 2025
0cfddab
chore: fix linting issues
jescalada Jun 29, 2025
cde190f
Merge remote-tracking branch 'origin/main' into refactor-service-to-ts
jescalada Jul 3, 2025
c7ec2e3
chore: fix type errors and clean up
jescalada Jul 3, 2025
6074d31
fix: failing test on empty username
jescalada Jul 3, 2025
f57b1a1
Merge branch 'main' into refactor-service-to-ts
jescalada Jul 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
"@typescript-eslint/no-explicit-any": "off", // temporary until TS refactor is complete
"@typescript-eslint/no-unused-vars": "off", // temporary until TS refactor is complete
"@typescript-eslint/no-require-imports": "off", // prevents error on old "require" imports
"@typescript-eslint/no-unused-expressions": "off" // prevents error on test "expect" expressions
"@typescript-eslint/no-unused-expressions": "off", // prevents error on test "expect" expressions
"new-cap": "off" // prevents error on express.Router()
},
"settings": {
"react": {
Expand Down
2 changes: 1 addition & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { hideBin } from 'yargs/helpers';
import * as fs from 'fs';
import { configFile, setConfigFile, validate } from './src/config/file';
import proxy from './src/proxy';
import service from './src/service';
import * as service from './src/service';

const argv = yargs(hideBin(process.argv))
.usage('Usage: $0 [options]')
Expand Down
94 changes: 94 additions & 0 deletions package-lock.json

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

6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,17 @@
"@babel/preset-react": "^7.22.5",
"@commitlint/cli": "^19.0.0",
"@commitlint/config-conventional": "^19.0.0",
"@types/cors": "^2.8.19",
"@types/express": "^5.0.1",
"@types/express-http-proxy": "^1.6.6",
"@types/express-session": "^1.18.2",
"@types/jsonwebtoken": "^9.0.10",
"@types/jwk-to-pem": "^2.0.3",
"@types/lodash": "^4.17.15",
"@types/lusca": "^1.7.5",
"@types/mocha": "^10.0.10",
"@types/node": "^22.13.5",
"@types/passport-local": "^1.0.38",
"@types/yargs": "^17.0.33",
"@typescript-eslint/eslint-plugin": "^8.26.1",
"@typescript-eslint/parser": "^8.26.1",
Expand Down
2 changes: 1 addition & 1 deletion src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ let _privateOrganizations: string[] = defaultSettings.privateOrganizations;
let _urlShortener: string = defaultSettings.urlShortener;
let _contactEmail: string = defaultSettings.contactEmail;
let _csrfProtection: boolean = defaultSettings.csrfProtection;
let _domains: Record<string, unknown> = defaultSettings.domains;
let _domains: Record<string, string> = defaultSettings.domains;
let _rateLimit: RateLimitConfig = defaultSettings.rateLimit;

// These are not always present in the default config file, so casting is required
Expand Down
36 changes: 34 additions & 2 deletions src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface UserSettings {
urlShortener: string;
contactEmail: string;
csrfProtection: boolean;
domains: Record<string, unknown>;
domains: Record<string, string>;
rateLimit: RateLimitConfig;
}

Expand All @@ -48,7 +48,39 @@ export interface Database {
export interface Authentication {
type: string;
enabled: boolean;
options?: Record<string, unknown>;
oidcConfig?: OidcConfig;
adConfig?: AdConfig;
jwtConfig?: JwtConfig;

// Deprecated fields for backwards compatibility
// TODO: remove in future release and keep the ones in adConfig
userGroup?: string;
adminGroup?: string;
domain?: string;
}

export interface OidcConfig {
issuer: string;
clientID: string;
clientSecret: string;
callbackURL: string;
scope: string;
}

export interface AdConfig {
url: string;
baseDN: string;
searchBase: string;
userGroup?: string;
adminGroup?: string;
domain?: string;
}

export interface JwtConfig {
clientID: string;
authorityURL: string;
roleMapping: Record<string, unknown>;
expectedAudience?: string;
}

export interface TempPasswordConfig {
Expand Down
5 changes: 3 additions & 2 deletions src/proxy/processors/push-action/pullRemote.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Action, Step } from '../../actions';
import fs from 'fs';
import git from 'isomorphic-git';
import gitHttpClient from 'isomorphic-git/http/node';

const dir = './.remote';

const exec = async (req: any, action: Action): Promise<Action> => {
const git = await import('isomorphic-git');
const gitHttpClient = await import('isomorphic-git/http/node/index.js');

const step = new Step('pullRemote');

try {
Expand Down
2 changes: 1 addition & 1 deletion src/proxy/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const validGitRequest = (url: string, headers: any): boolean => {
return false;
}
// https://www.git-scm.com/docs/http-protocol#_uploading_data
return agent.startsWith('git/') && accept.startsWith('application/x-git-') ;
return agent.startsWith('git/') && accept.startsWith('application/x-git-');
}
return false;
};
Expand Down
123 changes: 0 additions & 123 deletions src/service/index.js

This file was deleted.

Loading
Loading