Skip to content

Commit d2215c6

Browse files
authored
Merge pull request SolidOS#420 from solid/auth-upgrade
[WIP] Auth Upgrade
2 parents 98411c8 + d62955c commit d2215c6

64 files changed

Lines changed: 9900 additions & 7044 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/header/index.html

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta charset='UTF-8'>
66
<title>solid-ui UI.widgets.header examples page</title>
77
<script type="text/javascript" src="../../lib/webpack-bundle.js"></script>
8-
<script src="https://solid.github.io/solid-auth-client/dist/solid-auth-client.bundle.js"></script>
8+
<script type="text/javascript" src="../../lib/authn/authn.js"></script>
99
<script>
1010
const $ = document.querySelector.bind(document)
1111
function showSource(widgetName) {
@@ -17,33 +17,28 @@
1717
.replace(/'/g, "&#039;")
1818
}
1919
</script>
20-
<style>
21-
.loginButton {
22-
border-radius: 0.2em;
23-
margin: 1em;
24-
font-size: 85%;
25-
background-color: #fff;
26-
border-style: .01em solid #7C4DFF;
27-
color: #7C4DFF;
28-
}
29-
30-
.loginButton:hover {
31-
background-color: #7C4DFF;
32-
color: #fff;
33-
}
34-
</style>
3520
</head>
3621

3722
<body>
3823

3924
<h2 id="header"><a href="#header">Header</a>
40-
<button class="loginButton" onclick="login('https://solidcommunity.net')">Login</button>
25+
<div id="webId"></div>
26+
<div id="loginBanner"></div>
4127
<script>
42-
async function login(idp) {
43-
const session = await solid.auth.currentSession();
44-
if (!session)
45-
await solid.auth.login(idp);
28+
loginBanner.appendChild(authn.loginStatusBox(document, null, {}));
29+
30+
async function finishLogin() {
31+
await authn.authSession.handleIncomingRedirect();
32+
const session = authn.authSession;
33+
if (session.info.isLoggedIn) {
34+
// Update the page with the status.
35+
webId.innerHTML = "Logged in as: " + authn.currentUser().uri;
36+
} else {
37+
webId.innerHTML = "";
38+
}
4639
}
40+
41+
finishLogin();
4742
</script>
4843
</h2>
4944
<p>This example demonstrates how to use the header component. The header has a different view depending

jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module.exports = {
22
verbose: true,
3+
testEnvironment: 'jsdom',
34
setupFilesAfterEnv: [
45
'./test/helpers/setup.ts'
56
]

package-lock.json

Lines changed: 9405 additions & 6651 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "solid-ui",
3-
"version": "2.4.8",
3+
"version": "2.4.9-beta",
44
"description": "UI library for writing Solid read-write-web applications",
55
"main": "./lib/index.js",
66
"types": "./lib/index.d.ts",
@@ -53,59 +53,58 @@
5353
},
5454
"homepage": "https://github.com/solid/solid-ui",
5555
"dependencies": {
56-
"@babel/runtime": "^7.14.0",
56+
"@babel/runtime": "^7.15.4",
57+
"@inrupt/solid-client-authn-browser": "^1.11.2",
5758
"crypto-browserify": "^3.12.0",
5859
"escape-html": "^1.0.3",
59-
"jss": "^10.6.0",
60-
"jss-preset-default": "^10.6.0",
61-
"mime-types": "^2.1.31",
60+
"jss": "^10.8.0",
61+
"jss-preset-default": "^10.8.0",
62+
"mime-types": "^2.1.33",
6263
"pane-registry": "^2.4.2",
6364
"path-browserify": "^1.0.1",
6465
"postcss-flexbugs-fixes": "^5.0.2",
65-
"rdflib": "^2.2.6",
66-
"solid-auth-client": "^2.5.6",
67-
"solid-logic": "^1.3.6",
66+
"rdflib": "^2.2.7",
67+
"solid-logic": "^1.3.7-alpha",
6868
"solid-namespace": "^0.5.1",
6969
"stream-browserify": "^3.0.0",
7070
"uuid": "^8.3.2"
7171
},
7272
"devDependencies": {
73-
"@babel/cli": "^7.12.10",
74-
"@babel/core": "^7.12.10",
75-
"@babel/plugin-proposal-class-properties": "^7.12.1",
76-
"@babel/plugin-proposal-optional-chaining": "^7.12.7",
77-
"@babel/plugin-transform-async-to-generator": "^7.12.1",
78-
"@babel/plugin-transform-runtime": "^7.12.10",
79-
"@babel/preset-env": "^7.12.11",
80-
"@babel/preset-typescript": "^7.12.7",
81-
"@storybook/addon-actions": "^6.1.15",
82-
"@storybook/addon-essentials": "^6.1.20",
83-
"@storybook/addon-links": "^6.1.15",
84-
"@storybook/html": "^6.1.20",
85-
"@testing-library/dom": "^7.31.0",
86-
"@testing-library/user-event": "^13.1.9",
87-
"@types/jest": "^26.0.20",
88-
"@types/jsdom": "^16.2.6",
89-
"@types/node": "^14.14.22",
90-
"@typescript-eslint/eslint-plugin": "^4.14.1",
91-
"@typescript-eslint/parser": "^4.14.1",
92-
"autoprefixer": "^10.2.6",
73+
"@babel/cli": "^7.15.7",
74+
"@babel/core": "^7.15.8",
75+
"@babel/plugin-proposal-class-properties": "^7.14.5",
76+
"@babel/plugin-proposal-optional-chaining": "^7.14.5",
77+
"@babel/plugin-transform-async-to-generator": "^7.14.5",
78+
"@babel/plugin-transform-runtime": "^7.15.8",
79+
"@babel/preset-env": "^7.15.8",
80+
"@babel/preset-typescript": "^7.15.0",
81+
"@storybook/addon-actions": "^6.3.11",
82+
"@storybook/addon-essentials": "^6.3.11",
83+
"@storybook/addon-links": "^6.3.11",
84+
"@storybook/html": "^6.3.11",
85+
"@testing-library/dom": "^8.7.2",
86+
"@testing-library/user-event": "^13.3.0",
87+
"@types/jest": "^27.0.2",
88+
"@types/jsdom": "^16.2.13",
89+
"@types/node": "^16.10.5",
90+
"@typescript-eslint/eslint-plugin": "^5.0.0",
91+
"@typescript-eslint/parser": "^5.0.0",
92+
"autoprefixer": "^10.3.7",
9393
"babel-loader": "^8.2.2",
94-
"eslint": "^7.18.0",
95-
"eslint-plugin-jest": "^24.1.3",
96-
"husky": "^4.3.8",
97-
"jest": "^26.6.3",
98-
"jsdom": "^16.4.0",
99-
"lint-staged": "^10.5.3",
100-
"nock": "^13.0.11",
94+
"eslint": "^7.32.0",
95+
"eslint-plugin-jest": "^25.0.5",
96+
"husky": "^7.0.2",
97+
"jest": "^27.2.5",
98+
"jsdom": "^18.0.0",
99+
"lint-staged": "^11.2.3",
100+
"nock": "^13.1.3",
101101
"postcss-flexbugs-fixes": "^5.0.2",
102102
"raw-loader": "^4.0.2",
103-
"react-is": "^17.0.1",
104-
"solid-auth-cli": "^1.0.15",
105-
"standard": "^16.0.3",
106-
"ts-jest": "^26.4.4",
107-
"typedoc": "^0.21.1",
108-
"typescript": "^4.3.4",
103+
"react-is": "^17.0.2",
104+
"standard": "^16.0.4",
105+
"ts-jest": "^27.0.5",
106+
"typedoc": "^0.22.5",
107+
"typescript": "^4.4.4",
109108
"webpack": "^4.46.0",
110109
"webpack-cli": "^3.3.12"
111110
},

src/authn/authSession.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import {
2+
Session,
3+
getClientAuthenticationWithDependencies
4+
} from '@inrupt/solid-client-authn-browser'
5+
6+
let authSession: Session
7+
// @ts-ignore
8+
if (!window.authSession) {
9+
authSession = new Session(
10+
{
11+
clientAuthentication: getClientAuthenticationWithDependencies({})
12+
},
13+
'mySession'
14+
)
15+
// @ts-ignore
16+
window.authSession = authSession
17+
} else {
18+
// @ts-ignore
19+
authSession = window.authSession
20+
}
21+
22+
export default authSession

0 commit comments

Comments
 (0)