feat: add routes and config opts for more complete stubs

This commit is contained in:
2026-09-04 11:22:43 +02:00
parent 97d68ca8b1
commit c32569317a
6 changed files with 881 additions and 1189 deletions
+71 -29
View File
@@ -1,15 +1,15 @@
import vue from 'eslint-plugin-vue';
import eslint from '@eslint/js';
import globals from 'globals';
import typescript from '@typescript-eslint/eslint-plugin';
import stylistic from '@stylistic/eslint-plugin';
import tseslint from 'typescript-eslint';
import typescript from '@typescript-eslint/eslint-plugin';
import vue from 'eslint-plugin-vue';
const style = {
'plugins': {
'@stylistic': stylistic,
'@stylistic/js': stylistic,
'@stylistic/ts': stylistic,
'@stylistic/ts': stylistic
},
'files': [
'**/*.ts',
@@ -20,11 +20,26 @@ const style = {
'**/*.jsx'
],
'rules': {
'sort-imports': [
'warn',
{
'ignoreCase': false,
'ignoreDeclarationSort': false,
'ignoreMemberSort': false,
'memberSyntaxSortOrder': [
'none',
'all',
'multiple',
'single'
],
'allowSeparatedGroups': false
}
],
// Formatting
'@stylistic/array-bracket-newline': [
'error',
{
'multiline': true,
'multiline': false,
'minItems': 2
}
],
@@ -35,7 +50,8 @@ const style = {
'@stylistic/array-element-newline': [
'error',
{
'multiline': true,
'consistent': false,
'multiline': false,
'minItems': 2
}
],
@@ -56,7 +72,14 @@ const style = {
],
'@stylistic/brace-style': [
'error',
'1tbs'
'1tbs',
{
'allowSingleLine': false
}
],
'@stylistic/comma-dangle': [
'error',
'never'
],
'@stylistic/comma-spacing': [
'error',
@@ -73,9 +96,9 @@ const style = {
'error',
'property'
],
'@stylistic/eol-last': [
'@stylistic/function-call-argument-newline': [
'error',
'always'
'consistent'
],
'@stylistic/function-call-spacing': [
'error',
@@ -83,11 +106,7 @@ const style = {
],
'@stylistic/function-paren-newline': [
'error',
'multiline'
],
'@stylistic/function-call-argument-newline': [
'error',
'consistent'
'multiline-arguments'
],
'@stylistic/implicit-arrow-linebreak': [
'error',
@@ -97,6 +116,10 @@ const style = {
'error',
4
],
'@stylistic/indent-binary-ops': [
'error',
4
],
'@stylistic/key-spacing': [
'error',
{
@@ -118,18 +141,31 @@ const style = {
'@stylistic/max-len': [
'warn',
{
'code': 120,
'comments': 140,
'code': 140,
'comments': 160,
'ignoreComments': false,
'ignoreUrls': true,
'ignoreStrings': false
'ignoreStrings': true,
'ignoreTemplateLiterals': true,
'ignoreRegExpLiterals': true
}
],
'@stylistic/max-statements-per-line': [
'error',
{
'max': 1
}
],
'@stylistic/multiline-ternary': [
'error',
'always-multiline'
],
'@stylistic/new-parens': [
'error',
'always'
],
'@stylistic/newline-per-chained-call': [ 'error' ],
'@stylistic/newline-per-chained-call': 'error',
'@stylistic/no-confusing-arrow': 'error',
'@stylistic/no-extra-parens': [
'error',
'all',
@@ -167,17 +203,17 @@ const style = {
'always'
],
'@stylistic/object-property-newline': 'error',
'@stylistic/one-var-declaration-per-line': 'error',
'@stylistic/operator-linebreak': [
'error',
'before'
],
'@stylistic/one-var-declaration-per-line': 'error',
'@stylistic/padded-blocks': [
'error',
{
'blocks': 'never',
'classes': 'always',
'switches': 'never',
'switches': 'never'
}
],
@@ -561,7 +597,7 @@ const style = {
'blankLine': 'always',
'prev': 'class',
'next': '*'
},
}
],
'@stylistic/quote-props': [
'error',
@@ -613,17 +649,23 @@ const style = {
'error',
'always'
],
'@stylistic/switch-colon-spacing': 'error',
'@stylistic/template-curly-spacing': [
'error',
'always'
],
'@stylistic/switch-colon-spacing': 'error',
'@stylistic/template-tag-spacing': [
'error',
'always'
],
'@stylistic/type-generic-spacing': 'error',
'@stylistic/type-named-tuple-spacing': 'error',
'@stylistic/wrap-iife': [
'error',
'inside'
],
'@stylistic/wrap-regex': 'error',
'@stylistic/ts/type-annotation-spacing': 'error',
'@stylistic/ts/type-annotation-spacing': 'error'
}
};
@@ -642,15 +684,15 @@ export default tseslint.config(
'ecmaVersion': 'latest',
'globals': globals.browser,
'parserOptions': {
'parser': tseslint.parser,
},
'parser': tseslint.parser
}
},
'plugins': {
'vue': vue,
'@stylistic': stylistic,
'@stylistic/js': stylistic,
'@stylistic/ts': stylistic,
'@typescript-eslint': typescript,
'@typescript-eslint': typescript
},
'extends': [
eslint.configs.recommended,
@@ -694,9 +736,9 @@ export default tseslint.config(
'error',
{
'singleline': 3,
'multiline': 1,
'multiline': 1
}
],
},
},
]
}
}
);
+707 -1151
View File
File diff suppressed because it is too large Load Diff
+9 -8
View File
@@ -21,15 +21,16 @@
},
"homepage": "https://git.janishutz.com/janishutz/oauth-sdk#readme",
"devDependencies": {
"@eslint/js": "^9.34.0",
"@stylistic/eslint-plugin": "^4.4.1",
"eslint-plugin-vue": "^10.4.0",
"typescript": "^5.3.3",
"typescript-eslint": "^8.42.0"
"@eslint/js": "^10.0.1",
"@stylistic/eslint-plugin": "^5.10.0",
"@types/express-session": "^1.19.0",
"eslint": "^10.9.1",
"eslint-plugin-vue": "^10.10.0",
"globals": "^17.12.0",
"typescript-eslint": "^8.69.0"
},
"dependencies": {
"@types/express-session": "^1.18.2",
"express": "^4.19.2",
"express-session": "^1.18.2"
"express": "^5.2.1",
"express-session": "^1.19.0"
}
}
+59
View File
@@ -0,0 +1,59 @@
/**
* The configuration interface for the SDK
*/
export interface SDKConfig {
/**
* Service configuration
*/
'service': ServiceConfig;
/**
* The URL of the frontend. Leave empty if none. Will be concatenated with redirectURL
*/
'frontendURL'?: string;
/**
* If running in prod or not
*/
'prod': boolean;
/**
* The verification type the advanced verification function should use
*/
'advancedVerification': VerificationType;
/**
* The type of session store you are using
*/
'sessionType': SessionType;
/**
* The CORS whitelist for which base URLs to allow CORS from
*/
'corsWhitelist': string[];
/**
* The path to the logout store. Leave empty to not store on disk
*/
'toBeLoggedOutStorePath'?: string;
/**
* Primarily used for testing. If left empty, will use default
*/
'accountServiceURL'?: string;
/**
* Set the URL to redirect to on login if none is specified. If left empty, defaults to /account
*/
'defaultRedirectURL'?: string;
/**
* The number of seconds until on the advancedLoginCheck middleware, a full check is executed again
*/
'recheckTimeout': number;
/**
* The user-agent to verify against when checking authentication. Set to * to disable check
*/
'user-agent': string;
}
+9 -1
View File
@@ -1,6 +1,12 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import {
SDKConfig
} from './config';
import express from 'express';
import expressSession from 'express-session';
import {
routes
} from './routes';
import token from './token';
declare module 'express-session' {
@@ -14,12 +20,14 @@ declare module 'express-session' {
// │ Functions │
// ╰───────────────────────────────────────────────╯
// ───────────────────────────────────────────────────────────────────
const setUp = ( app: express.Application ) => {
const setUp = ( configuration: SDKConfig, app: express.Application ) => {
app.use( expressSession( {
'secret': token.generateToken( 60 ),
'resave': false,
'saveUninitialized': true
} ) );
routes( app, configuration );
};
/**
+26
View File
@@ -0,0 +1,26 @@
import {
SDKConfig
} from './config';
import express from 'express';
export const routes = ( app: express.Application, configuration: SDKConfig ) => {
app.get( '/jhid/v2/verify/full/sdk', ( _request: express.Request, response: express.Response ) => {
response.send( 'ok' );
} );
app.get( '/jhid/v2/verify/simple', ( _request: express.Request, response: express.Response ) => {
response.send( 'ok' );
} );
app.get( '/jhid/v2/login', ( _request: express.Request, response: express.Response ) => {
response.redirect( ( configuration.frontendURL ?? '' ) + ( configuration.defaultRedirectURL ?? '/account' ) );
} );
app.get( '/jhid/v2/logout', ( _request: express.Request, response: express.Response ) => {
response.redirect( configuration.frontendURL ?? '/' );
} );
app.get( '/jhid/v2/check/cors', ( request: express.Request, response: express.Response ) => {
response.send( 'ok' );
} );
};