-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get Bluesky auth working on Cloudflare - this involved a bit of a redesign of the client metadata system. Also unify storacha and bluesky auth experiences on the homepage.
- Loading branch information
Showing
14 changed files
with
114 additions
and
100 deletions.
There are no files selected for viewing
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,7 @@ | ||
import { setupDevPlatform } from '@cloudflare/next-on-pages/next-dev'; | ||
|
||
const nextConfig = { | ||
/* config options here */ | ||
}; | ||
|
||
export default nextConfig; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { blueskyClientMetadata } from "@/lib/bluesky"; | ||
|
||
export const runtime = 'edge' | ||
|
||
export async function GET() { | ||
return Response.json(blueskyClientMetadata) | ||
} |
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,41 +1,16 @@ | ||
"use client"; | ||
|
||
import { useBskyAuthContext } from "@/contexts/bluesky"; | ||
import { useCallback, useState } from "react"; | ||
|
||
export default function Home() { | ||
const { authenticated, bskyAuthClient } = useBskyAuthContext(); | ||
|
||
const [handle, setHandle] = useState<string>(""); | ||
|
||
const signIn = useCallback(async () => { | ||
if (!bskyAuthClient) return; | ||
try { | ||
await bskyAuthClient.signIn(handle, { | ||
scope: "atproto transition:generic", | ||
}); | ||
} catch (err) { | ||
console.log(err); | ||
} | ||
}, [handle, bskyAuthClient]); | ||
import BlueskyAuthenticator from "@/components/BlueskyAuthenticator"; | ||
import StorachaAuthenticator from "@/components/StorachaAuthenticator"; | ||
|
||
export default function Home () { | ||
return ( | ||
<> | ||
<h1>Blusky Backup Webapp</h1> | ||
<div> | ||
<h1>Bluesky Backup Webapp</h1> | ||
<p>Lets get started</p> | ||
<div> | ||
<h4>Bluesky Auth</h4> | ||
<div>{authenticated ? "Auth" : "Not auth"}</div> | ||
<input | ||
onChange={(e) => { | ||
e.preventDefault(); | ||
setHandle(e.target.value); | ||
}} | ||
value={handle} | ||
placeholder="Handler" | ||
/> | ||
<button onClick={signIn}>#</button> | ||
</div> | ||
</> | ||
); | ||
<h4>Bluesky Auth</h4> | ||
<BlueskyAuthenticator /> | ||
|
||
<h4>Storacha Auth</h4> | ||
<StorachaAuthenticator /> | ||
</div> | ||
) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
"use client"; | ||
|
||
import { useBskyAuthContext } from "@/contexts/bluesky"; | ||
import { useCallback, useState } from "react"; | ||
|
||
export default function BlueskyAuthenticator () { | ||
const { authenticated, bskyAuthClient } = useBskyAuthContext(); | ||
|
||
const [handle, setHandle] = useState<string>(""); | ||
|
||
const signIn = useCallback(async () => { | ||
if (!bskyAuthClient) return; | ||
try { | ||
await bskyAuthClient.signIn(handle, { | ||
scope: "atproto transition:generic", | ||
}); | ||
} catch (err) { | ||
console.log(err); | ||
} | ||
}, [handle, bskyAuthClient]); | ||
|
||
return ( | ||
<div> | ||
{authenticated ? ( | ||
<div>Authenticated to Bluesky!</div> | ||
) : ( | ||
<div> | ||
<input | ||
onChange={(e) => { | ||
e.preventDefault(); | ||
setHandle(e.target.value); | ||
}} | ||
value={handle} | ||
placeholder="Bluesky Handle" | ||
/> | ||
<button onClick={signIn}>#</button> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
} |
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,9 +1,9 @@ | ||
import { Provider as W3UIProvider } from '@w3ui/react' | ||
import { Provider } from '@w3ui/react' | ||
|
||
export default function Provider({ children }: { children: React.ReactNode }) { | ||
export default function W3UIProvider({ children }: { children: React.ReactNode }) { | ||
return ( | ||
<W3UIProvider> | ||
<Provider> | ||
{children} | ||
</W3UIProvider> | ||
</Provider> | ||
) | ||
} |
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,17 @@ | ||
import { OAuthClientMetadataInput } from "@atproto/oauth-client-browser"; | ||
|
||
export const blueskyClientUri = process.env.NEXT_PUBLIC_BLUESKY_CLIENT_URI || "https://localhost:3000/" | ||
|
||
export const blueskyClientMetadata: OAuthClientMetadataInput = { | ||
"client_id": `${blueskyClientUri}bluesky-client-metadata`, | ||
"client_name": "Local Dev App", | ||
"client_uri": blueskyClientUri, | ||
"application_type": "web", | ||
"grant_types": ["authorization_code", "refresh_token"], | ||
"response_types": ["code"], | ||
"redirect_uris": [blueskyClientUri], | ||
"token_endpoint_auth_method": "none", | ||
"scope": "atproto transition:generic", | ||
"dpop_bound_access_tokens": true | ||
|
||
} |
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,4 +1,4 @@ | ||
name = "bluesky-backup-webapp" | ||
compatibility_date = "2024-07-29" | ||
name = "bluesky-backup-dev" | ||
compatibility_date = "2024-09-23" | ||
compatibility_flags = ["nodejs_compat"] | ||
pages_build_output_dir = ".vercel/output/static" |