···23try it here: http://flo-bit.dev/svelte-atproto-client-oauth/
45-this is a scaffold for how to get client side oauth working with sveltekit and atproto
6using the [`atcute`](https://github.com/mary-ext/atcute) libraries.
78-useful when you want people to login to your static sveltekit site.
910## how to install
11···31};
32```
33000034### or manually install in your own project
3536-1. copy the `src/lib/oauth` folder into your own project
37-2. also copy the `src/routes/oauth-client-metadata.json.json` folder into your project
383. initialize the client in your `src/routes/+layout.svelte`
3940```svelte
···68npm install @atcute/atproto @atcute/bluesky @atcute/identity-resolver @atcute/lexicons @atcute/oauth-browser-client @atcute/client
69```
7071-6. set your base in `svelte.config.js` (e.g. for github pages: `base: '/your-repo-name/'`) while keeping it as `''` in development.
07273```ts
74const config = {
···84};
85```
8600008788## how to use
8900000000000090### login flow
9192Either use the `LoginModal` component to render a login modal or use the `user` object to handle the login flow yourself.
···102user.logout();
103```
104105-LoginModal is a component that renders a login modal, add it for a quick login flow.
106-(copy the `src/lib/UI` folder into your projects `src/lib` folder)
107108```svelte
109<script>
···123import { user } from '$lib/oauth';
124125// make requests with the user.client object
0126const response = await user.client.get('app.bsky.feed.getActorLikes', {
127 params: {
128 actor: client.did,
···23try it here: http://flo-bit.dev/svelte-atproto-client-oauth/
45+this is a scaffold for how to get client side oauth working with sveltekit and atproto
6using the [`atcute`](https://github.com/mary-ext/atcute) libraries.
78+useful when you want people to login with atproto to your static sveltekit site.
910## how to install
11···31};
32```
3334+6. change the SITE in `$lib/atproto/settings.ts` to your website
35+36+7. setup the correct permissions (see below)
37+38### or manually install in your own project
3940+1. copy the `src/lib/atproto` folder into your own project
41+2. also copy the `src/routes/oauth-client-metadata.json` folder into your project
423. initialize the client in your `src/routes/+layout.svelte`
4344```svelte
···72npm install @atcute/atproto @atcute/bluesky @atcute/identity-resolver @atcute/lexicons @atcute/oauth-browser-client @atcute/client
73```
7475+6. (optionally) set your base in `svelte.config.js` (e.g. for github pages: `base: '/your-repo-name/'`) while keeping it as `''` in development.
76+7778```ts
79const config = {
···89};
90```
9192+6. change the SITE in `$lib/atproto/settings.ts` to your website
93+94+7. setup the correct permissions (see below)
95+9697## how to use
9899+### set permissions you request on sign-in in `$lib/atproto/settings.ts` (see commented out examples for more info)
100+101+- add collections to the collections array
102+- add rpcs to rpcCalls
103+- blobs for uploading blobs
104+105+### change sign up pds
106+107+If you want to allow sign-up, change the `signUpPDS` variable in `$lib/atproto/settings.ts` to a pds of your choice
108+109+ATTENTION: the current setting (pds.rip) is only for development, all accounts get deleted automatically after a week
110+111### login flow
112113Either use the `LoginModal` component to render a login modal or use the `user` object to handle the login flow yourself.
···123user.logout();
124```
125126+LoginModal is a component that renders a login modal, add it for a quick login flow (needs tailwind).
127+(copy the `src/lib/UI` folder into your projects `src/lib` folder, add the `src/app.css` content to your `app.css`)
128129```svelte
130<script>
···144import { user } from '$lib/oauth';
145146// make requests with the user.client object
147+// this example needs the getActorLikes rpc permission, set permissions
148const response = await user.client.get('app.bsky.feed.getActorLikes', {
149 params: {
150 actor: client.did,
···1export const SITE = 'https://flo-bit.dev';
23+// optionally add action=create/update/delete to only allow those actions for a collection
4export const collections: string[] = ['xyz.statusphere.status'];
5+// example: only allow create and delete
6+// export const collections: string[] = ['xyz.statusphere.status?action=create&action=update'];
78export const rpcCalls: Record<string, string | string[]> = {
9+ // example: allow authenticated proxying to bsky appview to get a users liked posts
10+ //'did:web:api.bsky.app#bsky_appview': ['app.bsky.feed.getActorLikes']
11+ // https://docs.bsky.app/docs/api/app-bsky-feed-get-actor-likes
12};
1314+export const blobs = [] as string | string[] | undefined;
15+16+// example: allowing video and html uploads
17+// export const blobs = ['video/*', 'text/html'] as string | string[] | undefined;
1819+// example: allowing all blob types
20+// export const blobs = ['*/*'] as string | string[] | undefined;
21+22+// which PDS to use for signup
23+// ATTENTION: pds.rip is only for development, all accounts get deleted automatically after a week
24export const signUpPDS = 'https://pds.rip/';