From 17d990fe27d5d88a5c4f69b0ffbc359f84f0f2c5 Mon Sep 17 00:00:00 2001 From: Michael Feher Date: Thu, 8 Aug 2024 16:24:47 -0400 Subject: [PATCH] docs: complete server sections --- docs/.astro/settings.json | 2 +- docs/.astro/types.d.ts | 14 ++ docs/astro.config.mjs | 8 - docs/src/content/docs/server/integrations.md | 156 ++++++++++++++----- docs/src/content/docs/server/introduction.md | 9 +- 5 files changed, 138 insertions(+), 51 deletions(-) diff --git a/docs/.astro/settings.json b/docs/.astro/settings.json index 189bbef..6dd781d 100644 --- a/docs/.astro/settings.json +++ b/docs/.astro/settings.json @@ -1,5 +1,5 @@ { "_variables": { - "lastUpdateCheck": 1721221209150 + "lastUpdateCheck": 1723148542874 } } \ No newline at end of file diff --git a/docs/.astro/types.d.ts b/docs/.astro/types.d.ts index 2a117a1..d9f7f9f 100644 --- a/docs/.astro/types.d.ts +++ b/docs/.astro/types.d.ts @@ -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"] }; }; }; diff --git a/docs/astro.config.mjs b/docs/astro.config.mjs index 10f915a..b338b39 100644 --- a/docs/astro.config.mjs +++ b/docs/astro.config.mjs @@ -58,10 +58,6 @@ export default defineConfig({ items: [{ label: "Introduction", link: "/server/introduction", - badge: { - text: "WIP", - variant: "caution" - } }, { label: "Running locally", @@ -74,10 +70,6 @@ export default defineConfig({ { label: "Integrations", link: "/server/integrations", - badge: { - text: "WIP", - variant: "caution" - } }, ...openAPISidebarGroups, ] diff --git a/docs/src/content/docs/server/integrations.md b/docs/src/content/docs/server/integrations.md index cbe7dfc..7178e12 100644 --- a/docs/src/content/docs/server/integrations.md +++ b/docs/src/content/docs/server/integrations.md @@ -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 @@ -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 -``` diff --git a/docs/src/content/docs/server/introduction.md b/docs/src/content/docs/server/introduction.md index 5c2be42..5bf6b03 100644 --- a/docs/src/content/docs/server/introduction.md +++ b/docs/src/content/docs/server/introduction.md @@ -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. @@ -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. + + +