feat: imports, retrievable backend URL

This commit is contained in:
janishutz committed 2026-09-22 08:04:31 +02:00
1 parent b08532e89a
commit f0ed64d0de
2 files changed
+14 -6

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@janishutz/oidc-login-sdk-browser", "name": "@janishutz/oidc-login-sdk-browser",
"version": "1.2.0", "version": "1.3.1",
"description": "SDK to communicate with and log into a backend running express-openid-connect", "description": "SDK to communicate with and log into a backend running express-openid-connect",
"homepage": "https://github.com/janishutz/oidc-login-sdk#readme", "homepage": "https://github.com/janishutz/oidc-login-sdk#readme",
"bugs": { "bugs": {
+13 -5
View File
@@ -1,7 +1,6 @@
import { import config, {
AuthErrorResolution AuthErrorResolution
} from './dtype.js'; } from './config.js';
import config from './config.js';
import { import {
login login
} from './auth.js'; } from './auth.js';
@@ -55,6 +54,14 @@ const deleteRequest = async ( url: string, authErrorResolution?: AuthErrorResolu
}, authErrorResolution ); }, authErrorResolution );
}; };
/**
* Retrieve the configured backend URL
* @returns The URL to the backend
*/
const getBackendURL = () => {
return config.get().backendURL;
};
const wrapper = async ( url: string, opts: RequestInit, authErrorResolution?: AuthErrorResolution ): Promise<Response> => { const wrapper = async ( url: string, opts: RequestInit, authErrorResolution?: AuthErrorResolution ): Promise<Response> => {
const res = await fetch( config.get().backendURL + url, { const res = await fetch( config.get().backendURL + url, {
'redirect': 'manual', 'redirect': 'manual',
@@ -75,7 +82,7 @@ const wrapper = async ( url: string, opts: RequestInit, authErrorResolution?: Au
} }
}; };
const handleUnauth = ( authErrorResolution: AuthErrorResolution ) => { const handleUnauth = ( authErrorResolution?: AuthErrorResolution ) => {
if ( config.get().authErrorEvent ) { if ( config.get().authErrorEvent ) {
document.dispatchEvent( new CustomEvent( 'autherror' ) ); document.dispatchEvent( new CustomEvent( 'autherror' ) );
} }
@@ -90,5 +97,6 @@ const handleUnauth = ( authErrorResolution: AuthErrorResolution ) => {
export default { export default {
get, get,
post, post,
'delete': deleteRequest 'delete': deleteRequest,
getBackendURL
}; };