-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/bootloader #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ylebre
wants to merge
9
commits into
main
Choose a base branch
from
feature/bootloader
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d76fea7
add webId to redirect, add bootloader in dashboard
ylebre 5108f3e
add bootloader
ylebre 4d39237
fix redirect url
ylebre df844ac
update frontend
ylebre e6b6180
set the preferences on the webId instead of #me#me
ylebre b86af95
allow trusted apps by default
ylebre dd24325
redirect to autologin
ylebre f6be6c9
update bootloader
ylebre b618572
add trusted apps
ylebre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,214 @@ | ||
| <!DOCTYPE HTML> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <!-- Component CSS --> | ||
| <style> | ||
|
|
||
| </style> | ||
| <!-- /Component CSS --> | ||
| <!-- Page CSS --> | ||
| <style> | ||
|
|
||
| </style> | ||
| <!-- /Page CSS --> | ||
| <!-- Head HTML --> | ||
| <!-- metro (baseComponent/metro) --> | ||
| <script src="https://cdn.jsdelivr.net/npm/@muze-nl/metro@0.6.19/dist/browser.js"></script> | ||
| <script src="https://cdn.jsdelivr.net/npm/@muze-nl/oldm@0.3.6/dist/oldm.js"></script> | ||
| <script src="https://cdn.jsdelivr.net/npm/@muze-nl/metro-oauth2@0.7.4/dist/browser.js"></script> | ||
| <script src="https://cdn.jsdelivr.net/npm/@muze-nl/metro-oidc@0.5.3/dist/browser.js"></script> | ||
| <!-- /Head HTML --> | ||
| <script> | ||
| var simplyDataApi = {}; | ||
| var simplyApp = {}; | ||
| window.addEventListener("simply-content-loaded", function() { | ||
| simply.bind = false; | ||
| /* Raw API */ | ||
| var simplyRawApi = { | ||
|
|
||
| }; | ||
| /* End of Raw API */ | ||
| /* Data API */ | ||
| simplyDataApi = { | ||
| // component/solid-preferences | ||
| "getPreferences" : async function(webID){ | ||
|
|
||
| let issuer = "" | ||
| let profileTurtle | ||
|
|
||
| const context = oldm.context({ | ||
| prefixes: { | ||
| 'ldp': 'http://www.w3.org/ns/ldp#', | ||
| 'rdf': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', | ||
| 'dct': 'http://purl.org/dc/terms/', | ||
| 'stat': 'http://www.w3.org/ns/posix/stat#', | ||
| 'turtle': 'http://www.w3.org/ns/iana/media-types/text/turtle#', | ||
| 'schem': 'https://schema.org/', | ||
| 'solid': 'http://www.w3.org/ns/solid/terms#', | ||
| 'acl': 'http://www.w3.org/ns/auth/acl#', | ||
| 'pims': 'http://www.w3.org/ns/pim/space#', | ||
| 'vcard': 'http://www.w3.org/2006/vcard/ns#', | ||
| 'foaf': 'http://xmlns.com/foaf/0.1/' | ||
| }, | ||
| parser: oldm.n3Parser, | ||
| writer: oldm.n3Writer | ||
| }) | ||
|
|
||
| //fetch profile to retrieve issuer | ||
| const profileURL = webID; | ||
| try { | ||
| const responseProfile = await fetch(profileURL); | ||
| if (!responseProfile.ok) { | ||
| throw new Error(`Response status: ${responseProfile.status}`); | ||
| } | ||
| profileTurtle = await responseProfile.text(); | ||
| } catch (error) { | ||
| console.error(error.message); | ||
| } | ||
|
|
||
| let podContent = context.parse(profileTurtle, webID, 'text/turtle') | ||
|
|
||
| issuer = podContent.primary?.solid$oidcIssuer?.id | ||
| let preferenceFileURL = podContent.primary?.pims$preferencesFile?.id | ||
|
|
||
| const oidcOptions = { | ||
| // authorize_callback: metro.oauth2.authorizePopup, | ||
| force_authorization: true, | ||
| client_info: { | ||
| client_name: 'Solid Bootloader', | ||
| redirect_uris: [ | ||
| window.location.origin + window.location.pathname | ||
| ] | ||
| }, | ||
| issuer: issuer | ||
| } | ||
| if (window.location.protocol !== "https") { | ||
| // needed to allow app.simplyapp:// as redirect uri | ||
| oidcOptions['client_info']['application_type'] = 'native'; | ||
| } | ||
|
|
||
| let client = metro.client().with(metro.oidc.oidcmw(oidcOptions)) | ||
|
|
||
| let preferenceResponse = await client.get(preferenceFileURL) | ||
|
|
||
| if (!preferenceResponse.ok) { | ||
| throw new Error(preferenceResponse.status+':'+preferenceResponse.statusText) | ||
| } | ||
|
|
||
| const preferenceTurtle = await preferenceResponse.text() | ||
| let preferenceOLDM = context.parse(preferenceTurtle, preferenceFileURL, 'text/turtle') | ||
|
|
||
| return preferenceOLDM | ||
|
|
||
| }, | ||
| // component/bootloader | ||
| "appLocation" : async function(webID){ | ||
| let preferenceOLDM = await simplyDataApi.getPreferences(webID) | ||
| if ( | ||
| preferenceOLDM.subjects[webID] && | ||
| preferenceOLDM.subjects[webID].solid$launcher | ||
| ) { | ||
| return preferenceOLDM.subjects[webID].solid$launcher.id | ||
| } else { | ||
| return "https://solid-launcher.dev.muze.nl/" | ||
| } | ||
| } | ||
| }; | ||
| /* End of Data API */ | ||
| simplyApp = simply.app({ | ||
| /* Actions */ | ||
| actions: { | ||
| // component/bootloader | ||
| "getLauncherLocation" : async function (webID){ | ||
| let appLauncherPath = await simplyDataApi.appLocation(webID) | ||
| return appLauncherPath | ||
| } | ||
| }, | ||
| /* /Actions */ | ||
| /* Commands */ | ||
| commands: { | ||
|
|
||
| }, | ||
| /* /Commands */ | ||
| /* Keyboard shortcuts */ | ||
| keyboard: { | ||
|
|
||
| }, | ||
| /* /Keyboard shortcuts */ | ||
| /* Routes */ | ||
| routes: { | ||
| // page/home | ||
| "#autologin/:webID" : async function(params) { | ||
| let webID = params.webID | ||
| webID = decodeURIComponent(webID) | ||
| localStorage['bootloader:webID'] = webID | ||
| let appLauncherPath = await simplyApp.actions.getLauncherLocation(webID) | ||
| document.location.href = appLauncherPath + "#autologin/" + encodeURIComponent(webID) | ||
| }, | ||
| // page/home | ||
| "/" : async function() { | ||
| if ( | ||
| document.location.search.match("code") || | ||
| document.location.search.match("state") | ||
| ) { | ||
| let webID = localStorage['bootloader:webID'] | ||
| let appLauncherPath = await simplyApp.actions.getLauncherLocation(webID) | ||
| document.location.href = appLauncherPath + "#autologin/" + encodeURIComponent(webID) | ||
| } | ||
| } | ||
| } | ||
| /* /Routes */ | ||
| }); | ||
| }); | ||
| function clone(ob) { | ||
| return JSON.parse(JSON.stringify(ob)); | ||
| } | ||
| function updateDataSource(name) { | ||
| document.querySelectorAll('[data-simply-data="'+name+'"]').forEach(function(list) { | ||
| editor.list.applyDataSource(list, name); | ||
| list.dataBindingPaused = 0; | ||
| }); | ||
| } | ||
| </script> | ||
| </head> | ||
| <body> | ||
| <!-- Body HTML --> | ||
|
|
||
| <!-- /Body HTML --> | ||
| <!-- Component HTML templates --> | ||
|
|
||
| <!-- /Component HTML templates --> | ||
| <div class="main" data-simply-field="page" data-simply-content="template"> | ||
| <!-- Page HTML templates --> | ||
|
|
||
| <!-- /Page HTML templates --> | ||
| </div> | ||
| <script src="https://unpkg.com/simplyview@3.5.5/dist/simply.everything.js"></script> | ||
| <script src="https://canary.simplyedit.io/1/simply-edit.js" data-simply-storage="none" data-api-key="simply-edit-0011"></script> | ||
| <script> | ||
| /* Transformers */ | ||
| editor.transformers = { | ||
|
|
||
| }; | ||
| /* /Transformers */ | ||
| </script> | ||
| <script> | ||
| /* Sorters */ | ||
| editor.sorters = { | ||
|
|
||
| }; | ||
| /* /Sorters */ | ||
| </script> | ||
| <script> | ||
| window.addEventListener("simply-content-loaded", function() { | ||
| /* Data sources */ | ||
|
|
||
| /* /Data sources */ | ||
| }); | ||
| </script> | ||
| <!-- Foot HTML --> | ||
|
|
||
| <!-- /Foot HTML --> | ||
| </body> | ||
| </html> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks when there are more than one issuer configured for a WebId, as
solid$oidcIssueris an array in such a case.(For an example of such a thing, see https://id.inrupt.com/potherca.ttl)