Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
fc90d8d
replace Inrupt by Uvdsl OIDC client
bourgeoa May 20, 2026
cc582ca
lint-fix
bourgeoa May 20, 2026
b5c8420
feat(auth): address Copilot review findings for uvdsl migration
bourgeoa May 21, 2026
d4078aa
add IndexedDbSessionDatabase fallback
bourgeoa May 21, 2026
41b9e23
feat(auth): export RefreshWorker asset and support same-origin worker…
bourgeoa May 22, 2026
c9ab4d9
update RefreshWorker URL
bourgeoa May 22, 2026
5935525
revert(auth): remove RefreshWorker integration and URL override
bourgeoa May 22, 2026
24c3ea5
fix(auth): avoid SharedWorker startup on localhost dev http
May 23, 2026
ac99dd5
fix(auth): accept object-style login args for UVDSL session
May 25, 2026
e26518a
Merge remote-tracking branch 'origin/main' into uvdsl
bourgeoa May 27, 2026
0d895f0
fix(auth): handle NSS local issuer and cookie-backed logout
May 29, 2026
232c30c
fix(issuer): preserve current host suggestion for subdomains
May 29, 2026
ff4a2d3
update rdflib
bourgeoa May 29, 2026
a54b216
normalize subdomain issuer from /.well-known/openid-configuration
bourgeoa May 30, 2026
0bd4659
Preserve existing refresh_token when new value is null/empty
bourgeoa May 30, 2026
ae2d120
Bump webpack-cli from 7.0.2 to 7.0.3
dependabot[bot] Jun 3, 2026
20db203
Merge pull request #283 from SolidOS/dependabot/npm_and_yarn/webpack-…
github-actions[bot] Jun 3, 2026
85ed0be
Bump terser-webpack-plugin from 5.6.0 to 5.6.1
dependabot[bot] Jun 3, 2026
6f58575
Merge pull request #285 from SolidOS/dependabot/npm_and_yarn/terser-w…
github-actions[bot] Jun 3, 2026
accd478
Bump @babel/core from 7.29.0 to 7.29.7
dependabot[bot] Jun 3, 2026
9a9bd39
Merge pull request #284 from SolidOS/dependabot/npm_and_yarn/babel/co…
github-actions[bot] Jun 3, 2026
05626ab
Bump @typescript-eslint/parser from 8.60.0 to 8.60.1
dependabot[bot] Jun 3, 2026
9268dfd
Merge pull request #287 from SolidOS/dependabot/npm_and_yarn/typescri…
github-actions[bot] Jun 3, 2026
1a13227
refactor(authSession): split into session, events, issuer modules
Jun 5, 2026
ceffa35
Merge branch 'main' into uvdsl
bourgeoa Jun 5, 2026
069ebe0
apply Copilot reviews
bourgeoa Jun 5, 2026
74a5e6f
Bump @typescript-eslint/parser from 8.60.1 to 8.61.0
dependabot[bot] Jun 8, 2026
cbd34c0
Merge pull request #288 from SolidOS/dependabot/npm_and_yarn/typescri…
github-actions[bot] Jun 8, 2026
a387333
Bump ts-loader from 9.5.7 to 9.6.0
dependabot[bot] Jun 8, 2026
05cd8ac
Merge pull request #289 from SolidOS/dependabot/npm_and_yarn/ts-loade…
github-actions[bot] Jun 8, 2026
8a3d8be
Merge branch 'main' into uvdsl
bourgeoa Jun 10, 2026
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: 4 additions & 0 deletions jest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export default {
transform: {
'^.+\\.[tj]sx?$': ['babel-jest', { configFile: './babel.config.mjs' }],
},
moduleNameMapper: {
'^@uvdsl/solid-oidc-client-browser$': '<rootDir>/test/mocks/solid-oidc-client-browser.ts',
'^@uvdsl/solid-oidc-client-browser/core$': '<rootDir>/test/mocks/solid-oidc-client-browser.ts',
},
setupFilesAfterEnv: ['./test/helpers/setup.ts'],
testMatch: ['**/__tests__/**/*.ts?(x)', '**/?(*.)+(spec|test).ts?(x)'],
roots: ['<rootDir>/src', '<rootDir>/test'],
Expand Down
243 changes: 91 additions & 152 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"build-dist": "webpack --progress",
"postbuild-js": "rm -f dist/versionInfo.d.ts dist/versionInfo.d.ts.map",
"lint": "eslint",
"lint-fix": "eslint --fix",
"typecheck": "tsc --noEmit",
"typecheck-test": "tsc --noEmit -p tsconfig.test.json",
"test": "jest --no-coverage",
Expand Down Expand Up @@ -72,10 +73,10 @@
"webpack-cli": "^7.0.2"
},
"dependencies": {
"@inrupt/solid-client-authn-browser": "^4.0.0",
"@uvdsl/solid-oidc-client-browser": "^0.2.2",
"solid-namespace": "^0.5.4"
},
"peerDependencies": {
"rdflib": "^2.3.7"
"rdflib": "^2.3.9"
}
}
94 changes: 90 additions & 4 deletions src/authSession/authSession.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,93 @@
import {
Session,
} from '@inrupt/solid-client-authn-browser'
/**
* Auth session wiring.
*
* Takes the raw OIDC session from session.ts and layers on:
* - Login compatibility shim (normalises legacy call-site signatures
* and resolves the canonical issuer)
* - SessionEvents shim (legacy EventEmitter-style API)
* - Logout listener (emits 'logout' on session deactivation)
*
* Exports the fully assembled authSession.
*/

export const authSession = new Session()
import type { Session as OidcSession } from '@uvdsl/solid-oidc-client-browser/core'
import { _session } from './session'
import { resolveIssuerForLogin } from './issuer'
import { SessionEvents } from './events'

type SessionCompatibilityShape = {
webId?: string
isActive?: boolean
info?: {
webId?: string
isLoggedIn?: boolean
}
fetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>
authFetch?: (input: string | URL | Request, init?: RequestInit, dpopPayload?: any) => Promise<Response>
}

export type SessionWithLegacyEvents = OidcSession & SessionCompatibilityShape & { events: SessionEvents }

// ---------------------------------------------------------------------------
// Login compatibility shim
// ---------------------------------------------------------------------------
// Wraps _session.login() so that call sites with different calling
// conventions all work. The underlying session expects:
// login(issuer: string, redirectUrl: string)
//
// idpOrOptions can be:
// - a string (issuer URL) — passed through with less resolution
// - an options object with any of these field-name variants:
// issuer: oidcIssuer | idp | issuer
// redirect: redirectUrl | redirect_uri | redirectUri
// (all redirect field names map to the same value: the URL the IdP
// should send the browser back to after authentication)
// - anything else — passed through to the underlying session as-is
//
// In all cases the issuer is resolved through
// /.well-known/openid-configuration before redirect so the canonical
// issuer host is used.

const sessionAny = _session as any
const originalLogin = typeof sessionAny.login === 'function'
? sessionAny.login.bind(_session)
: undefined

if (originalLogin) {
sessionAny.login = async (idpOrOptions: any, redirectUri?: string) => {
if (idpOrOptions && typeof idpOrOptions === 'object' && !Array.isArray(idpOrOptions)) {
const oidcIssuer = idpOrOptions.oidcIssuer ?? idpOrOptions.idp ?? idpOrOptions.issuer
const redirectUrl = idpOrOptions.redirectUrl ?? idpOrOptions.redirect_uri ?? idpOrOptions.redirectUri
if (typeof oidcIssuer === 'string' && typeof redirectUrl === 'string') {
return originalLogin(await resolveIssuerForLogin(oidcIssuer), redirectUrl)
}
}
if (typeof idpOrOptions === 'string') {
return originalLogin(await resolveIssuerForLogin(idpOrOptions), redirectUri)
}
return originalLogin(idpOrOptions, redirectUri)
}
}

// ---------------------------------------------------------------------------
// Legacy event layer
// ---------------------------------------------------------------------------

const events = new SessionEvents()

// Emit the legacy 'logout' event when the session transitions from active to inactive.
// 'login' and 'sessionRestore' are emitted in SolidAuthnLogic.checkUser()
// because only that call site knows which path activated the session.
let _wasActive = (_session as any).isActive ?? Boolean((_session as any).webId)
if (typeof (_session as unknown as EventTarget).addEventListener === 'function') {
;(_session as unknown as EventTarget).addEventListener('sessionStateChange', () => {
const isNowActive = (_session as any).isActive ?? Boolean((_session as any).webId)
if (_wasActive && !isNowActive) {
events.emit('logout')
}
_wasActive = isNowActive
})
}

export const authSession: SessionWithLegacyEvents = Object.assign(_session, { events })

35 changes: 35 additions & 0 deletions src/authSession/events.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Legacy event compatibility layer.
*
* Pure EventEmitter-style shim — no side effects, no uvdsl dependencies.
* Wired into the auth session by authSession.ts.
*/

type LegacyEventName = 'login' | 'logout' | 'sessionRestore'
type LegacyEventHandler = (...args: unknown[]) => void

/**
* Minimal EventEmitter-style shim so that existing consumers using
* `authSession.events.on('login' | 'logout' | 'sessionRestore', handler)`
* continue working without modification.
*
* Events are emitted by SolidAuthnLogic.checkUser() (login/sessionRestore)
* and by the sessionStateChange listener in authSession.ts (logout).
*/
export class SessionEvents {
private readonly listeners: Map<string, Set<LegacyEventHandler>> = new Map()

on (event: LegacyEventName, handler: LegacyEventHandler): void {
if (!this.listeners.has(event)) this.listeners.set(event, new Set())
this.listeners.get(event)!.add(handler)
}

off (event: LegacyEventName, handler: LegacyEventHandler): void {
this.listeners.get(event)?.delete(handler)
}

emit (event: LegacyEventName, ...args: unknown[]): void {
this.listeners.get(event)?.forEach(h => h(...args))
}
}

36 changes: 36 additions & 0 deletions src/authSession/issuer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Issuer discovery utilities.
*
* Resolves OIDC issuer endpoints from /.well-known/openid-configuration
* so that login can use the canonical issuer host.
*/

async function discoverIssuerFromWellKnown (issuer: string): Promise<string | null> {
try {
const issuerUrl = new URL(issuer)
const wellKnownUrl = new URL('/.well-known/openid-configuration', issuerUrl.origin)
const wellKnownResponse = await fetch(wellKnownUrl.toString(), { credentials: 'include' })
if (!wellKnownResponse.ok) {
return null
}

const wellKnownPayload = await wellKnownResponse.json()
if (typeof wellKnownPayload?.issuer !== 'string' || !wellKnownPayload.issuer) {
return null
}

return wellKnownPayload.issuer.replace(/\/$/, '')
} catch (_err) {
return null
}
}

export async function resolveIssuerForLogin (issuer: string): Promise<string> {
// Prefer the issuer advertised by discovery; if app and issuer hosts still differ,
// redirecting to the canonical issuer host is cleaner than rewriting the issuer here.
const discoveredIssuer = await discoverIssuerFromWellKnown(issuer)
if (discoveredIssuer) {
return discoveredIssuer
}
return issuer
}
Loading
Loading