Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
4 changes: 3 additions & 1 deletion jest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ export default {
],
setupFilesAfterEnv: ['./test/helpers/setup.ts'],
moduleNameMapper: {
'^.+\\.css$': '<rootDir>/__mocks__/styleMock.js'
'^.+\\.css$': '<rootDir>/__mocks__/styleMock.js',
'^solid-logic$': '<rootDir>/../solid-logic/src',
'^@uvdsl/solid-oidc-client-browser$': '<rootDir>/test/mocks/solid-oidc-client-browser.ts'
},
Comment on lines 17 to 21
testMatch: ['**/?(*.)+(spec|test).[tj]s?(x)'],
roots: ['<rootDir>/src', '<rootDir>/test', '<rootDir>/__mocks__'],
Expand Down
11 changes: 4 additions & 7 deletions src/login/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,10 +513,7 @@ export function renderSignInPopup (dom: HTMLDocument) {
// Login
const locationUrl = new URL(window.location.href)
locationUrl.hash = '' // remove hash part
await authSession.login({
redirectUrl: locationUrl.href,
oidcIssuer: issuerUri
})
await authSession.login(issuerUri, locationUrl.href)
} catch (err) {
alert(err.message)
}
Expand Down Expand Up @@ -669,9 +666,9 @@ export function loginStatusBox (
}

box.refresh = function () {
const sessionInfo = authSession.info
if (sessionInfo && sessionInfo.webId && sessionInfo.isLoggedIn) {
me = solidLogicSingleton.store.sym(sessionInfo.webId)
const webId = authSession.webId
if (webId) {
me = solidLogicSingleton.store.sym(webId)
} else {
me = null
}
Comment on lines 668 to 674
Expand Down
3 changes: 0 additions & 3 deletions src/v2/components/footer/Footer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,6 @@ export class Footer extends LitElement {
if (typeof authSession.events.off === 'function') {
authSession.events.off('login', this._updateFooter)
authSession.events.off('logout', this._updateFooter)
} else if (typeof authSession.events.removeListener === 'function') {
authSession.events.removeListener('login', this._updateFooter)
authSession.events.removeListener('logout', this._updateFooter)
}
super.disconnectedCallback()
}
Expand Down
5 changes: 1 addition & 4 deletions src/v2/components/loginButton/LoginButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,7 @@ export class LoginButton extends LitElement {

const locationUrl = new URL(window.location.href)
locationUrl.hash = ''
await authSession.login({
redirectUrl: locationUrl.href,
oidcIssuer: issuerUri
})
await authSession.login(issuerUri, locationUrl.href)
} catch (err: any) {
this._errorMsg = err.message || String(err)
this.requestUpdate()
Expand Down
73 changes: 73 additions & 0 deletions test/mocks/solid-oidc-client-browser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
type Listener = (...args: any[]) => void

class EventEmitterLike {
private listeners: Record<string, Listener[]> = {}

on (event: string, listener: Listener): void {
const list = this.listeners[event] || []
list.push(listener)
this.listeners[event] = list
}

off (event: string, listener: Listener): void {
const list = this.listeners[event] || []
this.listeners[event] = list.filter(item => item !== listener)
}

emit (event: string, ...args: any[]): void {
const list = this.listeners[event] || []
list.forEach(listener => listener(...args))
}
}

export class Session {
info: { webId?: string, isLoggedIn: boolean } = { isLoggedIn: false }
webId?: string
isActive = false
events = new EventEmitterLike()

private eventTarget = new EventTarget()

addEventListener (type: string, listener: EventListenerOrEventListenerObject | null): void {
if (!listener) return
this.eventTarget.addEventListener(type, listener)
}

removeEventListener (type: string, listener: EventListenerOrEventListenerObject | null): void {
if (!listener) return
this.eventTarget.removeEventListener(type, listener)
}

dispatchEvent (event: Event): boolean {
return this.eventTarget.dispatchEvent(event)
}

async handleIncomingRedirect (): Promise<void> {

}

async handleRedirectFromLogin (): Promise<void> {

}

async restore (): Promise<void> {

}

async login (_idp?: string, _redirectUri?: string): Promise<void> {
}

async logout (): Promise<void> {
this.info = { isLoggedIn: false }
this.webId = undefined
this.isActive = false
}

fetch (input: RequestInfo | URL, init?: RequestInit): Promise<Response> {
return globalThis.fetch(input, init)
}

authFetch (input: RequestInfo | URL, init?: RequestInit): Promise<Response> {
return globalThis.fetch(input, init)
}
}
6 changes: 4 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@
"declarations.d.ts"
] /* List of folders to include type definitions from. */,
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
"preserveSymlinks": true, /* Do not resolve the real path of symlinks. Needed for local linked solid-logic. */
"baseUrl": ".", /* Base directory to resolve non-absolute module names. Needed for paths mapping. */
"paths": { "rdflib": ["./node_modules/rdflib"] }, /* Map rdflib to avoid duplicate type identity when linked with solid-logic. */

/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
Expand Down
Loading