Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions src/pages/bluesky-redirect-to-cyd-dev.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import React, { useEffect } from 'react';
import React, { useEffect, useState } from 'react';
import Layout from '@theme/Layout';

// The URL Cyd Dev registers with the operating system to receive a finished
// Bluesky authorization. A private-use URI scheme has no naming authority, so
// exactly one slash follows the colon (RFC 8252 section 7.1). This must match
// what Cyd handles: see blueskyOAuthCallbackURL() in the cyd repo.
const CYD_URL = 'social.cyd.dev-api:/atproto-oauth-callback/';

export default function BlueskyRedirectToCydDev(): React.JSX.Element {
// The query string carries an authorization code, which is account-control
// material, so it is never logged. It is only ever handed straight to Cyd.
const [cydURL, setCydURL] = useState('');

useEffect(() => {
const protocol = window.location.href.includes('redirect-to-cyd-dev') ? 'cyd-dev' : 'cyd';
const url = `${protocol}://bluesky-oauth/${window.location.search}`;
console.log('Redirecting to', url);
const url = `${CYD_URL}${window.location.search}`;
setCydURL(url);
window.location.href = url;
}, []);

Expand All @@ -19,9 +28,14 @@ export default function BlueskyRedirectToCydDev(): React.JSX.Element {
<div className="col col--8 col--offset-2">
<h1>Redirecting to Cyd Dev to finish Bluesky authentication...</h1>
<noscript>
<p>Logging into your Bluesky account within Cyd requires JavaScript.</p>
<p>Logging into your Bluesky account within Cyd Dev requires JavaScript.</p>
</noscript>
<p>If your browser asks you if you want to open Cyd, say yes.</p>
<p>If your browser asks you if you want to open Cyd Dev, say yes.</p>
{cydURL && (
<p>
If nothing happened, <a href={cydURL}>open Cyd Dev</a>.
</p>
)}
</div>
</div>
</div>
Expand Down
24 changes: 19 additions & 5 deletions src/pages/bluesky-redirect-to-cyd.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import React, { useEffect } from 'react';
import React, { useEffect, useState } from 'react';
import Layout from '@theme/Layout';

export default function BlueskyRedirectToCydDev(): React.JSX.Element {
// The URL Cyd registers with the operating system to receive a finished
// Bluesky authorization. A private-use URI scheme has no naming authority, so
// exactly one slash follows the colon (RFC 8252 section 7.1). This must match
// what Cyd handles: see blueskyOAuthCallbackURL() in the cyd repo.
const CYD_URL = 'social.cyd.api:/atproto-oauth-callback/';

export default function BlueskyRedirectToCyd(): React.JSX.Element {
// The query string carries an authorization code, which is account-control
// material, so it is never logged. It is only ever handed straight to Cyd.
const [cydURL, setCydURL] = useState('');

useEffect(() => {
const protocol = window.location.href.includes('redirect-to-cyd-dev') ? 'cyd-dev' : 'cyd';
const url = `${protocol}://bluesky-oauth/${window.location.search}`;
console.log('Redirecting to', url);
const url = `${CYD_URL}${window.location.search}`;
setCydURL(url);
window.location.href = url;
}, []);

Expand All @@ -22,6 +31,11 @@ export default function BlueskyRedirectToCydDev(): React.JSX.Element {
<p>Logging into your Bluesky account within Cyd requires JavaScript.</p>
</noscript>
<p>If your browser asks you if you want to open Cyd, say yes.</p>
{cydURL && (
<p>
If nothing happened, <a href={cydURL}>open Cyd</a>.
</p>
)}
</div>
</div>
</div>
Expand Down