feat: add routes and config opts for more complete stubs
This commit is contained in:
+71
-29
@@ -1,15 +1,15 @@
|
|||||||
import vue from 'eslint-plugin-vue';
|
|
||||||
import eslint from '@eslint/js';
|
import eslint from '@eslint/js';
|
||||||
import globals from 'globals';
|
import globals from 'globals';
|
||||||
import typescript from '@typescript-eslint/eslint-plugin';
|
|
||||||
import stylistic from '@stylistic/eslint-plugin';
|
import stylistic from '@stylistic/eslint-plugin';
|
||||||
import tseslint from 'typescript-eslint';
|
import tseslint from 'typescript-eslint';
|
||||||
|
import typescript from '@typescript-eslint/eslint-plugin';
|
||||||
|
import vue from 'eslint-plugin-vue';
|
||||||
|
|
||||||
const style = {
|
const style = {
|
||||||
'plugins': {
|
'plugins': {
|
||||||
'@stylistic': stylistic,
|
'@stylistic': stylistic,
|
||||||
'@stylistic/js': stylistic,
|
'@stylistic/js': stylistic,
|
||||||
'@stylistic/ts': stylistic,
|
'@stylistic/ts': stylistic
|
||||||
},
|
},
|
||||||
'files': [
|
'files': [
|
||||||
'**/*.ts',
|
'**/*.ts',
|
||||||
@@ -20,11 +20,26 @@ const style = {
|
|||||||
'**/*.jsx'
|
'**/*.jsx'
|
||||||
],
|
],
|
||||||
'rules': {
|
'rules': {
|
||||||
|
'sort-imports': [
|
||||||
|
'warn',
|
||||||
|
{
|
||||||
|
'ignoreCase': false,
|
||||||
|
'ignoreDeclarationSort': false,
|
||||||
|
'ignoreMemberSort': false,
|
||||||
|
'memberSyntaxSortOrder': [
|
||||||
|
'none',
|
||||||
|
'all',
|
||||||
|
'multiple',
|
||||||
|
'single'
|
||||||
|
],
|
||||||
|
'allowSeparatedGroups': false
|
||||||
|
}
|
||||||
|
],
|
||||||
// Formatting
|
// Formatting
|
||||||
'@stylistic/array-bracket-newline': [
|
'@stylistic/array-bracket-newline': [
|
||||||
'error',
|
'error',
|
||||||
{
|
{
|
||||||
'multiline': true,
|
'multiline': false,
|
||||||
'minItems': 2
|
'minItems': 2
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -35,7 +50,8 @@ const style = {
|
|||||||
'@stylistic/array-element-newline': [
|
'@stylistic/array-element-newline': [
|
||||||
'error',
|
'error',
|
||||||
{
|
{
|
||||||
'multiline': true,
|
'consistent': false,
|
||||||
|
'multiline': false,
|
||||||
'minItems': 2
|
'minItems': 2
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -56,7 +72,14 @@ const style = {
|
|||||||
],
|
],
|
||||||
'@stylistic/brace-style': [
|
'@stylistic/brace-style': [
|
||||||
'error',
|
'error',
|
||||||
'1tbs'
|
'1tbs',
|
||||||
|
{
|
||||||
|
'allowSingleLine': false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'@stylistic/comma-dangle': [
|
||||||
|
'error',
|
||||||
|
'never'
|
||||||
],
|
],
|
||||||
'@stylistic/comma-spacing': [
|
'@stylistic/comma-spacing': [
|
||||||
'error',
|
'error',
|
||||||
@@ -73,9 +96,9 @@ const style = {
|
|||||||
'error',
|
'error',
|
||||||
'property'
|
'property'
|
||||||
],
|
],
|
||||||
'@stylistic/eol-last': [
|
'@stylistic/function-call-argument-newline': [
|
||||||
'error',
|
'error',
|
||||||
'always'
|
'consistent'
|
||||||
],
|
],
|
||||||
'@stylistic/function-call-spacing': [
|
'@stylistic/function-call-spacing': [
|
||||||
'error',
|
'error',
|
||||||
@@ -83,11 +106,7 @@ const style = {
|
|||||||
],
|
],
|
||||||
'@stylistic/function-paren-newline': [
|
'@stylistic/function-paren-newline': [
|
||||||
'error',
|
'error',
|
||||||
'multiline'
|
'multiline-arguments'
|
||||||
],
|
|
||||||
'@stylistic/function-call-argument-newline': [
|
|
||||||
'error',
|
|
||||||
'consistent'
|
|
||||||
],
|
],
|
||||||
'@stylistic/implicit-arrow-linebreak': [
|
'@stylistic/implicit-arrow-linebreak': [
|
||||||
'error',
|
'error',
|
||||||
@@ -97,6 +116,10 @@ const style = {
|
|||||||
'error',
|
'error',
|
||||||
4
|
4
|
||||||
],
|
],
|
||||||
|
'@stylistic/indent-binary-ops': [
|
||||||
|
'error',
|
||||||
|
4
|
||||||
|
],
|
||||||
'@stylistic/key-spacing': [
|
'@stylistic/key-spacing': [
|
||||||
'error',
|
'error',
|
||||||
{
|
{
|
||||||
@@ -118,18 +141,31 @@ const style = {
|
|||||||
'@stylistic/max-len': [
|
'@stylistic/max-len': [
|
||||||
'warn',
|
'warn',
|
||||||
{
|
{
|
||||||
'code': 120,
|
'code': 140,
|
||||||
'comments': 140,
|
'comments': 160,
|
||||||
'ignoreComments': false,
|
'ignoreComments': false,
|
||||||
'ignoreUrls': true,
|
'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': [
|
'@stylistic/new-parens': [
|
||||||
'error',
|
'error',
|
||||||
'always'
|
'always'
|
||||||
],
|
],
|
||||||
'@stylistic/newline-per-chained-call': [ 'error' ],
|
'@stylistic/newline-per-chained-call': 'error',
|
||||||
|
'@stylistic/no-confusing-arrow': 'error',
|
||||||
'@stylistic/no-extra-parens': [
|
'@stylistic/no-extra-parens': [
|
||||||
'error',
|
'error',
|
||||||
'all',
|
'all',
|
||||||
@@ -167,17 +203,17 @@ const style = {
|
|||||||
'always'
|
'always'
|
||||||
],
|
],
|
||||||
'@stylistic/object-property-newline': 'error',
|
'@stylistic/object-property-newline': 'error',
|
||||||
|
'@stylistic/one-var-declaration-per-line': 'error',
|
||||||
'@stylistic/operator-linebreak': [
|
'@stylistic/operator-linebreak': [
|
||||||
'error',
|
'error',
|
||||||
'before'
|
'before'
|
||||||
],
|
],
|
||||||
'@stylistic/one-var-declaration-per-line': 'error',
|
|
||||||
'@stylistic/padded-blocks': [
|
'@stylistic/padded-blocks': [
|
||||||
'error',
|
'error',
|
||||||
{
|
{
|
||||||
'blocks': 'never',
|
'blocks': 'never',
|
||||||
'classes': 'always',
|
'classes': 'always',
|
||||||
'switches': 'never',
|
'switches': 'never'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
@@ -561,7 +597,7 @@ const style = {
|
|||||||
'blankLine': 'always',
|
'blankLine': 'always',
|
||||||
'prev': 'class',
|
'prev': 'class',
|
||||||
'next': '*'
|
'next': '*'
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
'@stylistic/quote-props': [
|
'@stylistic/quote-props': [
|
||||||
'error',
|
'error',
|
||||||
@@ -613,17 +649,23 @@ const style = {
|
|||||||
'error',
|
'error',
|
||||||
'always'
|
'always'
|
||||||
],
|
],
|
||||||
|
'@stylistic/switch-colon-spacing': 'error',
|
||||||
'@stylistic/template-curly-spacing': [
|
'@stylistic/template-curly-spacing': [
|
||||||
'error',
|
'error',
|
||||||
'always'
|
'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': [
|
'@stylistic/wrap-iife': [
|
||||||
'error',
|
'error',
|
||||||
'inside'
|
'inside'
|
||||||
],
|
],
|
||||||
'@stylistic/wrap-regex': 'error',
|
'@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',
|
'ecmaVersion': 'latest',
|
||||||
'globals': globals.browser,
|
'globals': globals.browser,
|
||||||
'parserOptions': {
|
'parserOptions': {
|
||||||
'parser': tseslint.parser,
|
'parser': tseslint.parser
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
'plugins': {
|
'plugins': {
|
||||||
'vue': vue,
|
'vue': vue,
|
||||||
'@stylistic': stylistic,
|
'@stylistic': stylistic,
|
||||||
'@stylistic/js': stylistic,
|
'@stylistic/js': stylistic,
|
||||||
'@stylistic/ts': stylistic,
|
'@stylistic/ts': stylistic,
|
||||||
'@typescript-eslint': typescript,
|
'@typescript-eslint': typescript
|
||||||
},
|
},
|
||||||
'extends': [
|
'extends': [
|
||||||
eslint.configs.recommended,
|
eslint.configs.recommended,
|
||||||
@@ -694,9 +736,9 @@ export default tseslint.config(
|
|||||||
'error',
|
'error',
|
||||||
{
|
{
|
||||||
'singleline': 3,
|
'singleline': 3,
|
||||||
'multiline': 1,
|
'multiline': 1
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
Generated
+707
-1151
File diff suppressed because it is too large
Load Diff
+9
-8
@@ -21,15 +21,16 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://git.janishutz.com/janishutz/oauth-sdk#readme",
|
"homepage": "https://git.janishutz.com/janishutz/oauth-sdk#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.34.0",
|
"@eslint/js": "^10.0.1",
|
||||||
"@stylistic/eslint-plugin": "^4.4.1",
|
"@stylistic/eslint-plugin": "^5.10.0",
|
||||||
"eslint-plugin-vue": "^10.4.0",
|
"@types/express-session": "^1.19.0",
|
||||||
"typescript": "^5.3.3",
|
"eslint": "^10.9.1",
|
||||||
"typescript-eslint": "^8.42.0"
|
"eslint-plugin-vue": "^10.10.0",
|
||||||
|
"globals": "^17.12.0",
|
||||||
|
"typescript-eslint": "^8.69.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/express-session": "^1.18.2",
|
"express": "^5.2.1",
|
||||||
"express": "^4.19.2",
|
"express-session": "^1.19.0"
|
||||||
"express-session": "^1.18.2"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+59
@@ -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
@@ -1,6 +1,12 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||||
|
import {
|
||||||
|
SDKConfig
|
||||||
|
} from './config';
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import expressSession from 'express-session';
|
import expressSession from 'express-session';
|
||||||
|
import {
|
||||||
|
routes
|
||||||
|
} from './routes';
|
||||||
import token from './token';
|
import token from './token';
|
||||||
|
|
||||||
declare module 'express-session' {
|
declare module 'express-session' {
|
||||||
@@ -14,12 +20,14 @@ declare module 'express-session' {
|
|||||||
// │ Functions │
|
// │ Functions │
|
||||||
// ╰───────────────────────────────────────────────╯
|
// ╰───────────────────────────────────────────────╯
|
||||||
// ───────────────────────────────────────────────────────────────────
|
// ───────────────────────────────────────────────────────────────────
|
||||||
const setUp = ( app: express.Application ) => {
|
const setUp = ( configuration: SDKConfig, app: express.Application ) => {
|
||||||
app.use( expressSession( {
|
app.use( expressSession( {
|
||||||
'secret': token.generateToken( 60 ),
|
'secret': token.generateToken( 60 ),
|
||||||
'resave': false,
|
'resave': false,
|
||||||
'saveUninitialized': true
|
'saveUninitialized': true
|
||||||
} ) );
|
} ) );
|
||||||
|
|
||||||
|
routes( app, configuration );
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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' );
|
||||||
|
} );
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user