Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: complete server sections #33

Merged
merged 1 commit into from
Aug 12, 2024
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
2 changes: 1 addition & 1 deletion docs/.astro/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"_variables": {
"lastUpdateCheck": 1721221209150
"lastUpdateCheck": 1723148542874
}
}
14 changes: 14 additions & 0 deletions docs/.astro/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,20 @@ declare module 'astro:content' {
collection: "docs";
data: InferEntrySchema<"docs">
} & { render(): Render[".md"] };
"server/tmp.md": {
id: "server/tmp.md";
slug: "server/tmp";
body: string;
collection: "docs";
data: InferEntrySchema<"docs">
} & { render(): Render[".md"] };
"server/tmp2.md": {
id: "server/tmp2.md";
slug: "server/tmp2";
body: string;
collection: "docs";
data: InferEntrySchema<"docs">
} & { render(): Render[".md"] };
};

};
Expand Down
8 changes: 0 additions & 8 deletions docs/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ export default defineConfig({
items: [{
label: "Introduction",
link: "/server/introduction",
badge: {
text: "WIP",
variant: "caution"
}
},
{
label: "Running locally",
Expand All @@ -74,10 +70,6 @@ export default defineConfig({
{
label: "Integrations",
link: "/server/integrations",
badge: {
text: "WIP",
variant: "caution"
}
},
...openAPISidebarGroups,
]
Expand Down
156 changes: 117 additions & 39 deletions docs/src/content/docs/server/integrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,43 @@ title: "Server: Integrations"
sidebar:
order: 3
label: 'Integrations'
badge:
text: "WIP"
variant: caution
next: false
---

### NGINX

The official Docker image supports ENV variable substitution in the template folder.
Add your distribution to the container under `/usr/share/nginx/html`
Make sure to configure a `LIQUID_API_HOST` ENV variable that points to your deployed Liquid Auth API.

```nginx
///etc/nginx/template/default.conf.template

server {
listen 80;
listen [::]:80;
server_name localhost;

root /usr/share/nginx/html;

location / {
index index.html index.htm;
expires -1;
try_files $uri $uri/ @fallback;
}

location @fallback {
proxy_set_header Host ${LIQUID_API_HOST};
proxy_set_header X-Real-IP $remote_addr;
proxy_ssl_server_name on;
proxy_pass https://${LIQUID_API_HOST};
}
}

```

### Vite
> We recommend running a proxy server like Nginx in production. This will work for local development

```typescript
//vite.config.ts
Expand All @@ -32,59 +62,107 @@ export default defineConfig({
})
```

### Nest.js[WIP]
### Next.js
> We recommend running a proxy server like Nginx in production. This will work in a pinch or to test locally.

Deploy the service to a platform like Render or AWS then configure the Proxy in `next.config.js`.

```typescript
//next.config.js
/** @type {import('next').NextConfig} */

const serverURL = "https://my-liquid-service.com";

const nextConfig = {
trailingSlash: true,
async rewrites() {
return [
{
source: '/auth/:path*',
destination: `${serverURL}/auth/:path*`,
},
{
source: '/.well-known/:path*',
destination: `${serverURL}/.well-known/:path*`,
},
{
source: '/attestation/:path*',
destination: `${serverURL}/attestation/:path*`,
},

```javascript
//server.js
// import {AppModule} from '@algorandfoundation/liquid-auth-api'
{
source: '/assertion/:path*',
destination: `${serverURL}/assertion/:path*`,
},
{
source: '/socket.io/',
destination: `${serverURL}/socket.io/`,
},
{
source: '/socket.io',
destination: `${serverURL}/socket.io/`,
},
]
},
};

export default nextConfig;
```

### Next.js[WIP]
### Nest.js[WIP]
> Warning, the Service package is not available publicly.
> Please contact if you are interested in mounting the server

```javascript
//next.config.js
// module.exports = {
// async rewrites() {
// return [
// {
// source: '/blog',
// destination: 'https://acme.com/blog',
// },
// ]
// },
// }
See the [Demo Express](https://github.com/algorandfoundation/liquid-auth/blob/develop/sites/express-dapp/src/main.ts) app for an example of how to mount the server.

```shell
npm install @algorandfoundation/liquid-server --save
```

### Express.js[WIP]
```typescript
//src/main.ts
import { AppModule, RedisIoAdapter } from '@algorandfoundation/liquid-server';

```javascript
//server.js
// import {AppModule} from '@algorandfoundation/liquid-auth-api'
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.useWebSocketAdapter(new RedisIoAdapter(app));
await app.listen(3000);
}
```

### Vercel[WIP]
### Vercel
> We recommend running a proxy server like Nginx in production. This will work in a pinch

```json
//vercel.json
{
"rewrites": [
{
"source": "/blog",
"destination": "https://acme.com/blog"
"source": "/auth/:path*",
"destination": "${serverURL}/auth/:path*"
},
{
"source": "/.well-known/:path*",
"destination": "${serverURL}/.well-known/:path*"
},
{
"source": "/attestation/:path*",
"destination": "/attestation/:path*"
},

{
"source": "/assertion/:path*",
"destination": "${serverURL}/assertion/:path*"
},
{
"source": "/socket.io/",
"destination": "${serverURL}/socket.io/"
},
{
"source": "/socket.io",
"destination": "${serverURL}/socket.io/"
}
]
}
```

### Cloudflare[WIP]

```toml
#wrangler.toml

```

### NGINX [WIP]
```nginx
//default.conf
#todo Add Nginx proxy configuration
```
9 changes: 6 additions & 3 deletions docs/src/content/docs/server/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ prev: false
sidebar:
order: 0
label: 'Introduction'
badge:
text: "WIP"
variant: caution
---

Liquid Auth is a self-hosted authentication service that provides a simple way to associate Passkeys to KeyPair(s) commonly found in cryptocurrencies.
Expand All @@ -17,3 +14,9 @@ It is built using the [NestJS](https://nestjs.com/) framework
and uses [mongoose](https://docs.nestjs.com/techniques/mongodb) to interact with MongoDB.
Signaling is handled using [Socket.IO](https://docs.nestjs.com/websockets/gateways)
backed by a [Redis Adapter](https://socket.io/docs/v4/redis-adapter/).

The service request to be running on the same origin as the dApp.
We recommend configuring your frontend service to proxy requests to the authentication service.



Loading