diff --git a/browser/README.md b/browser/README.md index e69de29..41b8d52 100644 --- a/browser/README.md +++ b/browser/README.md @@ -0,0 +1,21 @@ +# OIDC Login SDK Browser +To get completion for the `autherror` event, in the global types file, add the below snippet. + +```typescript +declare global { + interface GlobalEventHandlersEventMap { + 'autherror': CustomEvent + } +} +``` + +To define a global types file (i.e. a `typeRoot`), update your `tsconfig.json` file with the following: +```json +{ + "compilerOptions": { + "typeRoots": [ + "./relative/path/to/global.d.ts" + ] + } +} +``` diff --git a/browser/src/config.ts b/browser/src/config.ts index 4bdba82..db264d5 100644 --- a/browser/src/config.ts +++ b/browser/src/config.ts @@ -1,6 +1,14 @@ -import { - Config -} from './dtype.js'; +export type AuthErrorResolution = 'resolve' | 'error'; + +export interface Config { + 'backendURL': URL; + 'defaultAuthErrorResolution': AuthErrorResolution; + 'authErrorEvent'?: string; + 'authCheckEndpoint'?: string; + 'loginEndpoint'?: string; + 'logoutEndpoint'?: string; + 'checkAutoRedirect'?: boolean; +} let configuration: Config = { 'backendURL': new URL( '' ), @@ -11,7 +19,7 @@ const get = () => { return configuration; }; -const configure = ( config: Config ) => { +export const configure = ( config: Config ) => { configuration = config; }; diff --git a/browser/src/dtype.d.ts b/browser/src/dtype.d.ts deleted file mode 100644 index 25560fd..0000000 --- a/browser/src/dtype.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -export type AuthErrorResolution = 'resolve' | 'error'; - -export interface Config { - 'backendURL': URL; - 'defaultAuthErrorResolution': AuthErrorResolution; - 'authErrorEvent'?: string; - 'authCheckEndpoint'?: string; - 'loginEndpoint'?: string; - 'logoutEndpoint'?: string; - 'checkAutoRedirect'?: boolean; -} - -declare global { - interface GlobalEventHandlersEventMap { - 'autherror': CustomEvent - } -} diff --git a/browser/src/index.ts b/browser/src/index.ts index cfd8ef1..485776f 100644 --- a/browser/src/index.ts +++ b/browser/src/index.ts @@ -1,7 +1,5 @@ import config from './config.js'; -export type * as dtype from './dtype.d.ts'; - export const configure = config.configure; export * as auth from './auth.js';