wip bsky client for the web & android
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: oauth for mobile

vi 7654dd38 e784ab23

+34 -31
+4 -4
public/oauth-client-metadata.json
··· 1 1 { 2 - "client_id": "http://localhost:5173/oauth-client-metadata.json", 2 + "client_id": "https://bbell.vt3e.cat/oauth-client-metadata.json", 3 3 "client_name": "Bluebell", 4 - "client_uri": "http://localhost:5173", 5 - "logo_uri": "http://localhost:5173/favicon.ico", 6 - "redirect_uris": ["http://localhost:5173/oauth/callback"], 4 + "client_uri": "https://bbell.vt3e.cat", 5 + "logo_uri": "https://bbell.vt3e.cat/favicon.ico", 6 + "redirect_uris": ["https://bbell.vt3e.cat/oauth/callback"], 7 7 "scope": "atproto transition:generic", 8 8 "grant_types": ["authorization_code", "refresh_token"], 9 9 "response_types": ["code"],
+11 -5
src/App.vue
··· 67 67 }) 68 68 69 69 App.addListener('appUrlOpen', function (event: URLOpenListenerEvent) { 70 - const slug = event.url.split('https://bbell.vt3e.cat').pop() 71 - console.log(slug, window.location.href, event) 72 - if (!slug) return 73 - if (slug.startsWith('/oauth/callback')) isCallback.value = true 74 - else nav.navigateToUrl(slug) 70 + const url = new URL(event.url) 71 + const path = url.pathname 72 + const hash = url.hash 73 + 74 + if (!path) return 75 + if (path.startsWith('/oauth/callback')) { 76 + auth._hash = hash 77 + isCallback.value = true 78 + } else { 79 + nav.navigateToUrl(path) 80 + } 75 81 }) 76 82 77 83 theme.init()
+2 -1
src/components/Navigation/PageLayout.vue
··· 104 104 -webkit-overflow-scrolling: touch; 105 105 height: 100%; 106 106 overflow-y: scroll; 107 + padding-top: calc(var(--inset-top, 0) + 4.5rem); 107 108 108 109 display: flex; 109 110 flex-direction: column; ··· 157 158 158 159 .no-padding { 159 160 .page-content { 160 - padding-top: calc(var(--safe-area-inset-top, 3.5rem)); 161 + padding-top: calc(var(--inset-top, 0) + 4.5rem); 161 162 } 162 163 .content-container { 163 164 padding: 0;
+15 -2
src/stores/auth.ts
··· 1 1 import { defineStore } from 'pinia' 2 2 import { ref, computed, markRaw } from 'vue' 3 + import { Capacitor } from '@capacitor/core' 3 4 import { 4 5 configureOAuth, 5 6 createAuthorizationUrl, ··· 30 31 const isLoading = ref(true) 31 32 const isProcessingCallback = ref(false) 32 33 const error = ref<string | null>(null) 34 + const _hash = ref<string | null>(null) 33 35 34 36 const isAuthenticated = computed(() => !!session.value) 35 37 const activeDid = ref<string | null>(localStorage.getItem(KEYS.ACTIVE_DID)) ··· 120 122 } 121 123 } 122 124 123 - window.location.assign(authUrl) 125 + if (Capacitor.isNativePlatform()) { 126 + const a = document.createElement('a') 127 + a.href = authUrl.toString() 128 + a.target = '_blank' 129 + a.rel = 'noopener' 130 + document.body.appendChild(a) 131 + a.click() 132 + document.body.removeChild(a) 133 + } else { 134 + window.location.assign(authUrl) 135 + } 124 136 } catch (err) { 125 137 isLoading.value = false 126 138 error.value = err instanceof Error ? err.message : 'Failed to start login' ··· 147 159 if (session.value) return true 148 160 if (isProcessingCallback.value) return true 149 161 150 - const hash = window.location.hash 162 + const hash = window.location.hash !== '' ? window.location.hash : _hash.value 151 163 if (!hash || hash.length < 2) { 152 164 return false 153 165 } ··· 212 224 logout, 213 225 getRpc, 214 226 agent, 227 + _hash, 215 228 profile, 216 229 fetchProfile, 217 230 }
+2 -19
src/stores/navigation.ts
··· 263 263 stack[0].props = props 264 264 updateHistory('replace', activeTab.value, stack[0]) 265 265 } else { 266 - // deep links - we open these in the home tab. 267 - activeTab.value = 'home' 268 - 269 - const stack = stacks.value['home'] 270 - const rootEntry = stack[0] 271 - if (!rootEntry) return 272 - 273 - const subPageEntry: StackEntry = { 274 - id: generateId(page), 275 - page: page as PageKey, 276 - props, 277 - } 278 - 279 - stacks.value['home'] = [rootEntry, subPageEntry] 280 - updateHistory('replace', 'home', rootEntry) 281 - updateHistory('push', 'home', subPageEntry) 266 + navigateToUrl(window.location.pathname + window.location.search) 282 267 } 283 268 284 269 window.addEventListener('popstate', handlePopState) ··· 286 271 } 287 272 288 273 function navigateToUrl(path: string) { 289 - const { page, root, props } = parseUrl(path) 290 - 291 - console.log(page, root, props) 274 + const { page, props } = parseUrl(path) 292 275 activeTab.value = 'home' 293 276 294 277 const stack = stacks.value['home']