Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e0e6074
commit d3d0047
Showing
13 changed files
with
2,983 additions
and
804 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 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 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 |
---|---|---|
@@ -1,12 +1,16 @@ | ||
import Vue from 'vue'; | ||
|
||
import App from './App.vue'; | ||
import App from '@/App.vue'; | ||
|
||
import './plugins/vuetify'; | ||
import './plugins/registerServiceWorker'; | ||
import Auth from '@/services/Auth'; | ||
|
||
import '@/plugins/vuetify'; | ||
import '@/plugins/registerServiceWorker'; | ||
|
||
Vue.config.productionTip = false; | ||
|
||
Vue.prototype.$auth = Auth; | ||
|
||
new Vue({ | ||
render: h => h(App), | ||
}).$mount('#app'); |
This file contains 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,51 @@ | ||
<template> | ||
<div class="bg-background w-screen h-screen flex flex-col items-center justify-center"> | ||
<div class="fixed pin-r pin-t m-4"> | ||
<a @click="$auth.logout()">Logout</a> | ||
</div> | ||
<h1 class="text-4xl">Focus 省</h1> | ||
<v-form class="w-4/5" @submit.prevent="createTask"> | ||
<div class="flex"> | ||
<v-text-field v-model="newTask" /> | ||
<v-btn color="primary" @click="createTask">Add</v-btn> | ||
</div> | ||
</v-form> | ||
<v-list class="w-4/5"> | ||
<template v-for="(task, index) of tasks"> | ||
<v-list-tile :key="index"> | ||
{{ task }} | ||
</v-list-tile> | ||
<v-divider v-if="index !== tasks.length -1" :key="`divider-${index}`" /> | ||
</template> | ||
<v-list-tile v-if="tasks.length === 0" class="text-grey-darker"> | ||
No tasks | ||
</v-list-tile> | ||
</v-list> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from 'vue'; | ||
interface ComponentData { | ||
newTask: string; | ||
tasks: string[]; | ||
} | ||
export default Vue.extend({ | ||
data(): ComponentData { | ||
return { | ||
newTask: '', | ||
tasks: [], | ||
}; | ||
}, | ||
methods: { | ||
createTask() { | ||
if (this.newTask) { | ||
this.tasks.push(this.newTask); | ||
this.newTask = ''; | ||
} | ||
}, | ||
}, | ||
}); | ||
</script> |
This file contains 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,30 @@ | ||
<template> | ||
<div class="bg-background w-screen h-screen flex flex-col items-center justify-center"> | ||
<h1 class="text-4xl">Focus 省</h1> | ||
<v-form class="w-4/5" @submit.prevent="login"> | ||
<div class="flex"> | ||
<v-text-field v-model="idp" /> | ||
<v-btn color="primary" @click="login">Login</v-btn> | ||
</div> | ||
</v-form> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from 'vue'; | ||
export default Vue.extend({ | ||
data() { | ||
return { | ||
idp: '', | ||
}; | ||
}, | ||
methods: { | ||
login() { | ||
// TODO show loading | ||
// TODO handle errors | ||
this.$auth.login(this.idp); | ||
}, | ||
}, | ||
}); | ||
</script> |
This file contains 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,10 @@ | ||
<template> | ||
<div class="bg-background w-screen h-screen flex flex-col items-center justify-center"> | ||
<h1>Loading...</h1> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
}; | ||
</script> |
This file contains 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,51 @@ | ||
import SolidAuthClient from 'solid-auth-client'; | ||
|
||
import Reactive from '@/utils/Reactive'; | ||
|
||
interface Data { | ||
webId: string | null; | ||
idp: string | null; | ||
} | ||
|
||
class Auth { | ||
|
||
private data: Data = Reactive.object({ | ||
webId: null, | ||
idp: null, | ||
}); | ||
|
||
public get loggedIn(): boolean { | ||
return this.data.webId !== null; | ||
} | ||
|
||
public get webId(): string { | ||
return this.data.webId as string; | ||
} | ||
|
||
public get idp(): string { | ||
return this.data.idp as string; | ||
} | ||
|
||
public async init(): Promise<void> { | ||
return SolidAuthClient.trackSession(session => { | ||
if (session) { | ||
this.data.webId = session.webId; | ||
this.data.idp = session.idp; | ||
} else { | ||
this.data.webId = null; | ||
this.data.idp = null; | ||
} | ||
}); | ||
} | ||
|
||
public async login(idp: string): Promise<void> { | ||
await SolidAuthClient.login(idp); | ||
} | ||
|
||
public async logout(): Promise<void> { | ||
await SolidAuthClient.logout(); | ||
} | ||
|
||
} | ||
|
||
export default new Auth(); |
This file contains 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,39 @@ | ||
declare module 'solid-auth-client' { | ||
|
||
import { EventEmitter } from 'events'; | ||
|
||
type AsyncStorage = any; | ||
|
||
type loginOptions = { | ||
callbackUri?: string, | ||
popupUri?: string, | ||
storage?: AsyncStorage, | ||
}; | ||
|
||
type Session = { | ||
idp: string, | ||
webId: string, | ||
accessToken: string, | ||
idToken: string, | ||
clientId: string, | ||
sessionKey: string, | ||
}; | ||
|
||
class SolidAuthClient extends EventEmitter { | ||
public fetch(input: RequestInfo, options?: Object): Promise<Response>; | ||
|
||
public login(idp: string, options?: loginOptions): Promise<Session | void>; | ||
|
||
public popupLogin(options: loginOptions): Promise<Session | void>; | ||
|
||
public currentSession(storage?: AsyncStorage): Promise<Session | void>; | ||
|
||
public trackSession(callback: (session?: Session) => void): Promise<void>; | ||
|
||
public logout(storage?: AsyncStorage): Promise<void>; | ||
} | ||
|
||
const auth: SolidAuthClient; | ||
|
||
export default auth; | ||
} |
This file contains 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,7 @@ | ||
import Auth from '@/services/Auth'; | ||
|
||
declare module 'vue/types/vue' { | ||
interface Vue { | ||
$auth: typeof Auth; | ||
} | ||
} |
This file contains 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,9 @@ | ||
import Vue from 'vue'; | ||
|
||
export default class Reactive { | ||
|
||
public static object<T>(data: T): T { | ||
return new Vue({ data }); | ||
} | ||
|
||
} |
This file contains 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 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,11 @@ | ||
module.exports = { | ||
configureWebpack: { | ||
externals: { | ||
'node-fetch': 'fetch', | ||
'text-encoding': 'TextEncoder', | ||
'whatwg-url': 'window', | ||
'isomorphic-fetch': 'fetch', | ||
'@trust/webcrypto': 'crypto' | ||
}, | ||
}, | ||
}; |