FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
solid-oidc/example.html at gh-pages · JavaScriptSolidServer/solid-oidc · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
JavaScriptSolidServer
/
solid-oidc
Public
Notifications
You must be signed in to change notification settings
Fork
1
Star
3
Code
Issues
3
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
solid-oidc
/
example.html
Copy path
More file actions
More file actions
Latest commit
History
History
History
213 lines (193 loc) · 6.11 KB
Breadcrumbs
solid-oidc
/
example.html
Copy path
File metadata and controls
213 lines (193 loc) · 6.11 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<!DOCTYPE html
>
<
html
lang
="
en
"
>
<
head
>
<
meta
charset
="
UTF-8
"
>
<
meta
name
="
viewport
"
content
="
width=device-width, initial-scale=1.0
"
>
<
title
>
Solid-OIDC Demo
</
title
>
<
style
>
*
{
box-sizing
:
border-box; }
body
{
font-family
:
-apple-system
,
BlinkMacSystemFont
,
'Segoe UI'
,
Roboto
,
sans-serif;
max-width
:
600
px
;
margin
:
2
rem
auto;
padding
:
1
rem
;
line-height
:
1.6
;
}
h1
{
color
:
#
7c4dff
; }
.
card
{
background
:
#
f5f5f5
;
border-radius
:
8
px
;
padding
:
1.5
rem
;
margin
:
1
rem
0
;
}
.
status
{
display
:
inline-block;
padding
:
0.25
rem
0.75
rem
;
border-radius
:
999
px
;
font-size
:
0.875
rem
;
font-weight
:
500
;
}
.
status
.
active
{
background
:
#
c8e6c9
;
color
:
#
2e7d32
; }
.
status
.
inactive
{
background
:
#
ffcdd2
;
color
:
#
c62828
; }
button
{
background
:
#
7c4dff
;
color
:
white;
border
:
none;
padding
:
0.75
rem
1.5
rem
;
border-radius
:
6
px
;
font-size
:
1
rem
;
cursor
:
pointer;
margin
:
0.25
rem
;
}
button
:
hover
{
background
:
#
651fff
; }
button
:
disabled
{
background
:
#
ccc
;
cursor
:
not-allowed; }
button
.
secondary
{
background
:
#
757575
; }
button
.
secondary
:
hover
{
background
:
#
616161
; }
input
,
select
{
width
:
100
%
;
padding
:
0.75
rem
;
border
:
1
px
solid
#
ddd
;
border-radius
:
6
px
;
font-size
:
1
rem
;
margin
:
0.5
rem
0
;
}
pre
{
background
:
#
263238
;
color
:
#
aed581
;
padding
:
1
rem
;
border-radius
:
6
px
;
overflow-x
:
auto;
font-size
:
0.875
rem
;
}
.
webid
{
word-break
:
break-all;
color
:
#
7c4dff
; }
label
{
font-weight
:
500
;
display
:
block;
margin-top
:
1
rem
; }
</
style
>
</
head
>
<
body
>
<
h1
>
Solid-OIDC Demo
</
h1
>
<
p
style
="
margin-top:-0.5rem;font-size:0.875rem;opacity:0.7
"
>
<
a
href
="
https://github.com/JavaScriptSolidServer/solid-oidc
"
style
="
color:inherit
"
>
View on GitHub
</
a
>
</
p
>
<
div
class
="
card
"
>
<
p
>
Status:
<
span
id
="
status
"
class
="
status inactive
"
>
Not logged in
</
span
>
</
p
>
<
p
id
="
webid-display
"
hidden
>
WebID:
<
span
id
="
webid
"
class
="
webid
"
>
</
span
>
</
p
>
</
div
>
<
div
id
="
login-form
"
class
="
card
"
>
<
label
for
="
idp
"
>
Identity Provider
</
label
>
<
select
id
="
idp
"
>
<
option
value
="
https://solidcommunity.net
"
>
solidcommunity.net
</
option
>
<
option
value
="
https://solidweb.org
"
>
solidweb.org
</
option
>
<
option
value
="
https://solidweb.me
"
>
solidweb.me
</
option
>
<
option
value
="
custom
"
>
Custom...
</
option
>
</
select
>
<
input
type
="
url
"
id
="
custom-idp
"
placeholder
="
https://your-provider.example
"
hidden
>
<
br
>
<
button
id
="
login-btn
"
>
Login with Solid
</
button
>
</
div
>
<
div
id
="
session-controls
"
class
="
card
"
hidden
>
<
button
id
="
fetch-btn
"
>
Fetch Profile
</
button
>
<
button
id
="
logout-btn
"
class
="
secondary
"
>
Logout
</
button
>
</
div
>
<
div
id
="
output-section
"
hidden
>
<
h3
>
Response
</
h3
>
<
pre
id
="
output
"
>
</
pre
>
</
div
>
<
script
type
="
module
"
>
// Import from local file (or use CDN: https://esm.sh/gh/JavaScriptSolidServer/solid-oidc/solid-oidc.js)
import
{
Session
}
from
'./solid-oidc.js'
// DOM elements
const
statusEl
=
document
.
getElementById
(
'status'
)
const
webidEl
=
document
.
getElementById
(
'webid'
)
const
webidDisplay
=
document
.
getElementById
(
'webid-display'
)
const
loginForm
=
document
.
getElementById
(
'login-form'
)
const
sessionControls
=
document
.
getElementById
(
'session-controls'
)
const
outputSection
=
document
.
getElementById
(
'output-section'
)
const
outputEl
=
document
.
getElementById
(
'output'
)
const
idpSelect
=
document
.
getElementById
(
'idp'
)
const
customIdp
=
document
.
getElementById
(
'custom-idp'
)
// Create session
const
session
=
new
Session
(
{
onStateChange
:
(
event
)
=>
{
const
{
isActive
,
webId
}
=
event
.
detail
updateUI
(
isActive
,
webId
)
}
}
)
// Update UI based on session state
function
updateUI
(
isActive
,
webId
)
{
statusEl
.
textContent
=
isActive
?
'Logged in'
:
'Not logged in'
statusEl
.
className
=
`status
${
isActive
?
'active'
:
'inactive'
}
`
webidEl
.
textContent
=
webId
||
''
webidDisplay
.
hidden
=
!
isActive
loginForm
.
hidden
=
isActive
sessionControls
.
hidden
=
!
isActive
}
// Handle custom IDP selection
idpSelect
.
onchange
=
(
)
=>
{
customIdp
.
hidden
=
idpSelect
.
value
!==
'custom'
}
// Get selected IDP
function
getIdp
(
)
{
return
idpSelect
.
value
===
'custom'
?
customIdp
.
value
:
idpSelect
.
value
}
// Login button
document
.
getElementById
(
'login-btn'
)
.
onclick
=
async
(
)
=>
{
const
idp
=
getIdp
(
)
if
(
!
idp
)
{
alert
(
'Please enter an identity provider URL'
)
return
}
try
{
await
session
.
login
(
idp
,
window
.
location
.
href
)
}
catch
(
error
)
{
alert
(
`Login error:
${
error
.
message
}
`
)
}
}
// Logout button
document
.
getElementById
(
'logout-btn'
)
.
onclick
=
async
(
)
=>
{
await
session
.
logout
(
)
outputSection
.
hidden
=
true
}
// Fetch profile button
document
.
getElementById
(
'fetch-btn'
)
.
onclick
=
async
(
)
=>
{
try
{
outputEl
.
textContent
=
'Fetching...'
outputSection
.
hidden
=
false
const
response
=
await
session
.
authFetch
(
session
.
webId
,
{
headers
:
{
'Accept'
:
'text/turtle'
}
}
)
if
(
!
response
.
ok
)
{
throw
new
Error
(
`HTTP
${
response
.
status
}
:
${
response
.
statusText
}
`
)
}
const
data
=
await
response
.
text
(
)
outputEl
.
textContent
=
data
}
catch
(
error
)
{
outputEl
.
textContent
=
`Error:
${
error
.
message
}
`
}
}
// On page load: handle redirect and try restore
async
function
init
(
)
{
try
{
// Handle redirect from IDP
await
session
.
handleRedirectFromLogin
(
)
}
catch
(
error
)
{
console
.
error
(
'Redirect handling error:'
,
error
)
}
// Try to restore previous session
if
(
!
session
.
isActive
)
{
try
{
await
session
.
restore
(
)
}
catch
{
// No session to restore, that's fine
}
}
// Initial UI state
updateUI
(
session
.
isActive
,
session
.
webId
)
}
init
(
)
</
script
>
</
body
>
</
html
>
Back
|
FazBrowse Home
|
New Git URL