Skip to content

Commit

Permalink
feat: V1 docs
Browse files Browse the repository at this point in the history
Updates the docs for Celest V1. Improves the file structure and naming conventions of items as well.
  • Loading branch information
dnys1 committed Oct 14, 2024
1 parent 115cb75 commit c391ed4
Show file tree
Hide file tree
Showing 29 changed files with 2,339 additions and 1,970 deletions.
8 changes: 6 additions & 2 deletions components/icons.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { FingerprintIcon, FlowerIcon, LayersIcon, ShieldIcon, WebhookIcon } from "lucide-react";
import { DatabaseIcon, FingerprintIcon, GlobeIcon, LayersIcon, ShieldIcon } from "lucide-react";

export const FunctionsIcon = LayersIcon;

export const AuthIcon = FingerprintIcon;

export const DataIcon = FlowerIcon; // OrigamiIcon;
export const DataIcon = DatabaseIcon;

export const PoliciesIcon = ShieldIcon;

export const StorageIcon = LayersIcon;

export const WebsiteIcon = GlobeIcon
2 changes: 1 addition & 1 deletion components/landing/Newsletter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { cn } from "@/src/utils";

export default function Newsletter({
className,
header = "Celest Cloud is currently closed for sign ups",
header = "Celest Cloud is coming soon! 🚀",
}: {
header?: string;
} & React.ComponentProps<"section">) {
Expand Down
2 changes: 1 addition & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.
40 changes: 20 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,39 @@
},
"homepage": "https://www.celest.dev",
"dependencies": {
"@calcom/embed-react": "^1.5.0",
"@heroicons/react": "^2.1.3",
"@calcom/embed-react": "^1.5.1",
"@heroicons/react": "^2.1.5",
"@intercom/messenger-js-sdk": "^0.0.6",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-slot": "^1.0.2",
"@sentry/nextjs": "^8.2.1",
"@vercel/og": "^0.6.2",
"@vercel/speed-insights": "^1.0.10",
"@radix-ui/react-accordion": "^1.2.1",
"@radix-ui/react-dialog": "^1.1.2",
"@radix-ui/react-slot": "^1.1.0",
"@sentry/nextjs": "^8.34.0",
"@vercel/og": "^0.6.3",
"@vercel/speed-insights": "^1.0.12",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"embla-carousel-autoplay": "^8.1.3",
"embla-carousel-react": "^8.1.3",
"embla-carousel-autoplay": "^8.3.0",
"embla-carousel-react": "^8.3.0",
"lucide-react": "^0.378.0",
"next": "^14.2.3",
"next": "^14.2.15",
"nextra": "^2.13.4",
"nextra-theme-docs": "^2.13.4",
"posthog-js": "^1.131.4",
"posthog-js": "^1.167.1",
"react": "~18.2.0",
"react-dom": "~18.2.0",
"react-icons": "^5.2.1",
"sharp": "^0.33.4",
"shiki": "^0.14.3",
"tailwind-merge": "^2.3.0",
"react-icons": "^5.3.0",
"sharp": "^0.33.5",
"shiki": "^0.14.7",
"tailwind-merge": "^2.5.4",
"tailwindcss-animate": "^1.0.7"
},
"devDependencies": {
"@types/node": "18.11.10",
"@types/react": "~18.2.0",
"autoprefixer": "^10.4.19",
"@types/react": "~18.2.79",
"autoprefixer": "^10.4.20",
"next-sitemap": "^4.2.3",
"postcss": "^8.4.38",
"tailwindcss": "^3.4.3",
"postcss": "^8.4.47",
"tailwindcss": "^3.4.13",
"typescript": "^4.9.5"
}
}
7 changes: 5 additions & 2 deletions pages/docs/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,24 @@
"index": "Overview",
"download": "Download",
"get-started": "Get Started",
"--widgets": {
"title": "Cloud Widgets",
"--celest": {
"title": "Celest",
"type": "separator"
},
"functions": "Functions",
"auth": "Auth",
"data": "Data",
"--hosting": {
"title": "Hosting",
"type": "separator"
},
"cloud": "Celest Cloud",
"self-hosting": "Self-Hosting",
"--reference": {
"title": "Reference",
"type": "separator"
},
"folder-structure": "Folder Structure",
"api-reference": {
"title": "API Reference",
"href": "https://pub.dev/documentation/celest/latest/",
Expand Down
57 changes: 14 additions & 43 deletions pages/docs/auth.mdx
Original file line number Diff line number Diff line change
@@ -1,52 +1,23 @@
---
title: Celest Auth
title: Auth
description: Learn how to add authentication to your Celest project.
---

import { Callout } from 'nextra-theme-docs'
# Auth

# Celest Auth
Celest comes with built-in auth support via our [Cloud Auth](https://github.com/celest-dev/celest/tree/main/services/celest_cloud_auth) package: an open-source, Dart-native service for
authenticating and authorizing users in any Dart backend.

Celest currently supports email-based authentication via one-time passcodes. This is a simple and secure way to authenticate users in your app without needing to worry about passwords.
<div className="flex flex-row justify-around items-center">
<img src="https://github.com/cedar-policy/.github/raw/main/profile/logo.svg" alt="Cedar Logo" className="h-full m-2 p-8 w-1/2" />
<img src="https://www.sqlite.org/images/sqlite370_banner.gif" alt="SQLite Logo" className="h-full m-2 p-8 w-1/2" />
</div>

<Callout>
We are working on adding social sign-in and passkeys in future releases. If you have a specific use case you'd like to see, please let us know by creating an [issue](https://github.com/celest-dev/celest/issues/new/choose).
</Callout>
Cloud Auth is built on top of the [Cedar](https://www.cedarpolicy.com/en) policy engine and [SQLite](https://www.sqlite.org/) to both manage user accounts
and enforce consistent access controls in a single Dart package. The Celest CLI will automatically integrate Cloud Auth into your project when
using Celest Auth, but the service is exposed as a Shelf router and middleware which can be used in any Dart project.

Adding Auth to your Celest project takes 5 lines of code. In your `project.dart` file, add the following code:
To get started with Cloud Auth, continue to the next page to see how to add it to your Celest project 🚀

```dart copy filename="celest/project.dart"
import 'package:celest/celest.dart';
const project = /* .. */;
const auth = Auth(
providers: [
AuthProvider.email(),
],
);
```

That's it! When you run `celest start`, Celest will automatically generate an Auth client for you to use in your Flutter app.

## Signing In

To sign in a user, you can use the `authenticate` method on the `celest.auth` object. It's called `authenticate` because there is no longer a distinction between signing in or signing up!
If the user doesn't exist, they will be created.

```dart
final flow = await celest.auth.email.authenticate(
email: '[email protected]',
);
// Prompt user for OTP code sent to the email
final user = await flow.verify(otpCode: '123456');
print('User signed in: ${user.id}');
```

A full example of a typical auth flow can be found in our [repo](https://github.com/celest-dev/celest/tree/main/packages/celest_auth/example).

## Authorizing your functions

Once a user is signed in, they can access functions marked `@authenticated`. To learn more about authorizing your functions, check out [Authorizing functions](/docs/functions/authorizing-functions).
> Celest Auth also suppors integrating [Supabase](./auth/supabase-auth.mdx) and [Firebase](./auth/firebase-auth.mdx) for cases where you
> already have an existing user base.
10 changes: 10 additions & 0 deletions pages/docs/auth/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"celest-auth": "Celest Auth",
"using-the-auth-client": "Using the Auth client",
"--external": {
"title": "External Providers",
"type": "separator"
},
"firebase-auth": "Firebase Auth",
"supabase-auth": "Supabase Auth"
}
26 changes: 26 additions & 0 deletions pages/docs/auth/celest-auth.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
title: Celest Auth
description: Learn how to use Celest's built-in Cloud Auth for authenticating users in your Celest project.
---

import { Callout } from 'nextra-theme-docs'

# Celest Auth

Adding Auth to your Celest project takes 5 lines of code. In your `project.dart` file, add the following code:

```dart copy filename="celest/lib/src/project.dart"
import 'package:celest/celest.dart';
const project = Project(name: 'my-project');
const auth = Auth(
providers: [
AuthProvider.email(),
],
);
```

That's it! When you run `celest start`, Celest will automatically integrate our open-source Auth backend
[Cloud Auth](https://github.com/celest-dev/celest/tree/main/services/celest_cloud_auth) and generate an Auth
client for you to use in your Flutter app.
57 changes: 57 additions & 0 deletions pages/docs/auth/firebase-auth.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
title: Firebase Auth
description: Learn how to use Firebase Auth for authenticating users in your Celest project.
---

import { Callout } from 'nextra-theme-docs'

# Firebase Auth

If you're migrating to Celest from another framework, chances are you already have a user base that you'd like to use.

As of Celest V1, Firebase can be used as your auth provider in Celest. And doing so is just as easy as with Celest's built-in auth.

## In your Celest project

To use Firebase as your auth provider, add the following code to your `project.dart` file:

```dart copy filename="celest/lib/src/project.dart"
import 'package:celest/celest.dart';
const project = Project(name: 'firebase');
const auth = Auth(
providers: [
ExternalAuthProvider.firebase(),
],
);
```

Verifying users with Firebase requires knowing your Firebase project ID. When you run `celest start`, Celest will automatically search your environment for
any available Firebase projects. If it can't figure out which project to use, you'll be prompted to enter it manually.

Celest will securely store your Firebase project ID for future use so it doesn't need to prompt you again.

## In your Flutter app

In your Flutter app, Celest will listen for changes to Firebase's auth state and update the Celest state accordingly so that
calls to your Cloud Functions are authenticated appropriately.

To do so, it needs access to your Firebase client, which you pass into the `celest.init` call in your `main` function.

```dart copy filename="lib/main.dart"
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:my_project_client/my_project_client.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
celest.init(
externalAuth: ExternalAuth.firebase(FirebaseAuth.instance),
);
runApp(const MyApp());
}
```

58 changes: 58 additions & 0 deletions pages/docs/auth/supabase-auth.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
title: Supabase Auth
description: Learn how to use Supabase Auth for authenticating users in your Celest project.
---

import { Callout } from 'nextra-theme-docs'

# Supabase Auth

If you're migrating to Celest from another framework, chances are you already have a user base that you'd like to use.

As of Celest V1, Supabase can be used as your auth provider in Celest. And doing so is just as easy as with Celest's built-in auth.

## In your Celest project

To use Supabase as your auth provider, add the following code to your `project.dart` file:

```dart copy filename="celest/lib/src/project.dart"
import 'package:celest/celest.dart';
const project = Project(name: 'supabase');
const auth = Auth(
providers: [
ExternalAuthProvider.supabase(),
],
);
```

Verifying users with Supabase requires knowing your Supabase project's URL. When you run `celest start`, Celest will automatically search your environment for
any available Supabase projects. If it can't figure out which project to use, you'll be prompted to enter it manually.

Celest will securely store your Supabase project URL for future use so it doesn't need to prompt you again.

## In your Flutter app

In your Flutter app, Celest will listen for changes to Supabase's auth state and update the Celest state accordingly so that
calls to your Cloud Functions are authenticated appropriately.

To do so, it needs access to your Supabase client, which you pass into the `celest.init` call in your `main` function.

```dart copy filename="lib/main.dart"
import 'package:flutter/material.dart';
import 'package:my_project_client/my_project_client.dart';
import 'package:supabase_flutter/supabase_flutter.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
final supabase = await Supabase.initialize(
url: 'YOUR_SUPABASE_URL',
anonKey: 'YOUR_SUPABASE_ANON_KEY',
);
celest.init(
externalAuth: ExternalAuth.supabase(supabase.client.auth),
);
runApp(const MyApp());
}
```
Loading

0 comments on commit c391ed4

Please sign in to comment.