Skip to content

Commit a78c032

Browse files
haetae-bithaetae
andauthored
update readme (#11)
* add additional example with atproto creating records * Update README.md with links * add class customization to login component in authproto * turn status page into component * modify readme and add screenshots * fix merge * remove old example * remove unneeded deps in auth-only example * update readme * fix callouts and edit codeblocks * add deno note * clarify example commented out some parts but reordered some things to flow better in example readme --------- Co-authored-by: haetae <haetae@32bit.cafe>
1 parent 5a1c0ce commit a78c032

6 files changed

Lines changed: 61 additions & 596 deletions

File tree

astro-authproto/README.md

Lines changed: 41 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<!-- banner -->
44

5-
ATproto authentication for your Astro site. Free and Easy™!
5+
ATproto authentication for your [Astro](https://docs.astro.build/en/concepts/why-astro/) site. Free and Easy™!
66

77
<!-- badges -->
88

@@ -31,8 +31,8 @@ In this package, you'll find:
3131
- `@fujocoded/authproto/components`, which includes:
3232
- A basic login/logout component to get started quickly
3333
- `@fujocoded/authproto/helpers`,
34-
- `getPdsAgent` etc.?
35-
- `friendsOnly` function (or similar)
34+
- `getPdsAgent` authorizes a logged in user to post, update, or delete data from ATProto
35+
- `friendsOnly` finds mutuals from your [Bluesky](https://bsky.app/) account
3636

3737
## What can you do with `@fujocoded/authproto`?
3838

@@ -55,6 +55,7 @@ In this package, you'll find:
5555
- Make your _own_ ATproto app that shares data with the rest of the network
5656

5757
<!-- replace this with a fancier display -->
58+
<!-- link to atproto explainer -->
5859

5960
## Built with Authproto
6061

@@ -68,53 +69,50 @@ In this package, you'll find:
6869
- Node
6970
- NPM/pnpm/yarn
7071
- Terminal
72+
- [Server adapter](https://docs.astro.build/en/guides/on-demand-rendering/#server-adapters) to set up sessions
73+
- (Optional) [session driver](https://docs.astro.build/en/reference/configuration-reference/#sessiondriver) to allow users to log in or log out
7174

7275
> [!IMPORTANT]
7376
> `deno` requires a workaround due to a CJS/ESM import issue within
74-
> `@atproto/oauth-client-node`.
77+
> `@atproto/oauth-client-node`. For now, avoid using `deno` and use other package managers.
7578
76-
// TODO: we can move this in a details tab
79+
> [!IMPORTANT]
80+
> Using either `localStorage` or `sessionStorage` will result in a ["Session storage could not be initialized." error](https://docs.astro.build/en/reference/errors/session-storage-init-error/) (and is considered insecure for handling sessions anyway). Consider other options, like a database.
7781
7882
Requires some familiarity with Astro, but if you want to jump in head first:
7983

80-
1. Install Astro by [following their official
81-
tutorial](https://docs.astro.build/en/install-and-setup/#install-from-the-cli-wizard).
82-
Once you do, [set your Astro site to server
83-
mode](https://docs.astro.build/en/guides/on-demand-rendering/#server-mode).
84-
2. Install [any of the
85-
adapters](https://docs.astro.build/en/guides/on-demand-rendering/#server-adapters).
86-
87-
- You can start out with
88-
[Node](https://docs.astro.build/en/guides/integrations-guide/node/), since
89-
that's a widely supported runtime.
84+
### Automatic Installation
9085

91-
3. Run the following command:
92-
93-
```bash
94-
npm install @fujocoded/authproto
95-
```
86+
1. Run the following command:
9687

9788
```bash
9889
npx astro add @fujocoded/authproto
9990
```
10091

101-
4. Add the integration to your `astro.config.mjs` file, like this:
92+
This will automatically install `@fujocoded/authproto` and add the integration to your `astro.config.mjs` file.
93+
94+
> [!TIP]
95+
>
96+
> You can take a look at all the [possible configuration options below](#configuration-options).
10297
103-
// TODO: add a note that this requires a server and an adapter that supports //
104-
some type of storage...? I'm unsure how it works on e.g. netlify for the //
105-
various session handlers
98+
### Manual Installation
10699

107-
// TODO: we might also want to make sure people do not set certain adapters //
108-
or even better just disallow the ones they shouldn't.
100+
1. Run the following command:
109101

110-
```typescript
102+
```bash
103+
npm add @fujocoded/authproto
104+
```
105+
106+
2. Add the integration to your `astro.config.mjs` file, like this:
107+
108+
```js
111109
import { defineConfig } from "astro/config";
112-
+ import node from "@astrojs/node";
110+
import node from "@astrojs/node";
113111
+ import authproto from "@fujocoded/authproto";
114112

115113
export default defineConfig({
116-
output: "server",
117-
+ adapter: node({ mode: "standalone" }), // ... or whichever adapter you're using!
114+
output: "server", // you can read up more how this works here: https://docs.astro.build/en/guides/on-demand-rendering/
115+
adapter: node({ mode: "standalone" }), // ... or whichever adapter you're using!
118116
+ integrations: [
119117
+ authproto({
120118
+ // config options here
@@ -123,12 +121,15 @@ export default defineConfig({
123121
});
124122
```
125123

126-
> [!TIP] You can take a look at all the [possible configuration options
127-
> below](#configuration-options).
124+
> [!TIP]
125+
>
126+
> You can take a look at all the [possible configuration options below](#configuration-options).
128127
129-
5. Add the `<Login />` component to your site, like this:
128+
# Using `@fujocoded/authproto`
130129

131-
```
130+
Add the `<Login />` component to your site, like this:
131+
132+
```jsx
132133
// src/pages/index.astro
133134
---
134135
import { Login } from "@fujocoded/authproto/components";
@@ -137,17 +138,17 @@ import { Login } from "@fujocoded/authproto/components";
137138
<Login />
138139
```
139140

140-
> [!TIP] You might run into a naming collision issue if you also have a page
141-
> named `login`. You can fix this by replacing `{ Login }` with `{ Login as
142-
LoginComponent }`.
141+
> [!TIP]
142+
>
143+
> You might run into a naming collision issue if you also have a page named `login`. You can fix this by replacing `{ Login }` with `{ Login as LoginComponent }`.
143144
144145
It'll look like a plain form:
145146

146147
<!-- screenshot -->
147148

148149
To make a page only visible to logged in users:
149150

150-
```ts
151+
```jsx
151152
// src/pages/secret.astro
152153
---
153154
const loggedInUser = Astro.locals.loggedInUser;
@@ -168,10 +169,7 @@ if (!loggedInUser) {
168169

169170
# Okay how do I _actually_ do stuff with this?
170171

171-
Check out the example sites included:
172-
173-
- [`__example__`](./__example__) shows you how to set up a login flow.
174-
- `__example_status__` has some examples of creating new records on a PDS.
172+
Check out the example sites included under the [examples folder](./__examples__/).
175173

176174
# Configuration options
177175

@@ -182,18 +180,12 @@ Check out the example sites included:
182180
- `defaultDevUser`, optional. The default handle that gets filled out in the
183181
`<Login />` component during development.
184182
- `driver`, optional. The driver used to store data about OAuth sessions. This
185-
takes Astro's [session driver
186-
options](https://docs.astro.build/en/reference/configuration-reference/#sessiondriver).
183+
takes Astro's [session driver options](https://docs.astro.build/en/reference/configuration-reference/#sessiondriver).
187184
You can also set this with `name: "astro:db"` to utilize [Astro's DB
188185
integration](https://docs.astro.build/en/guides/integrations-guide/db/) for
189186
OAuth sessions. This will set up tables for sessions in your database.
190187
- NOTE: The default driver is `memory`. This is fine for development, but it's
191188
recommended that you switch to a more reliable solution for production.
192-
- NOTE: Using either `localStorage` or `sessionStorage` will result in a
193-
["Session storage could not be initialized."
194-
error](https://docs.astro.build/en/reference/errors/session-storage-init-error/)
195-
(and is considered insecure for handling sessions anyway). Consider other
196-
options, like a database.
197189
- `scopes`, optional. By default, only the `"atproto"` scope is added. This
198190
scope is included with any other scope that's enabled. See [ATproto's
199191
documentation for OAuth
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// @ts-check
22
import { defineConfig } from "astro/config";
33
import authProto from "@fujocoded/authproto";
4-
import db from "@astrojs/db";
54

65
// https://astro.build/config
76
export default defineConfig({
@@ -11,9 +10,6 @@ export default defineConfig({
1110
},
1211
integrations: [
1312
authProto({
14-
// driver: {
15-
// name: "astro:db",
16-
// },
1713
applicationName: "Authproto test",
1814
applicationDomain: "fujocoded.com",
1915
defaultDevUser: "essentialrandom.bsky.social",
@@ -23,6 +19,5 @@ export default defineConfig({
2319
additionalScopes: ["transition:generic"],
2420
},
2521
}),
26-
// db(),
2722
],
2823
});

0 commit comments

Comments
 (0)