Skip to content

Add account system and server list #47

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

Merged
merged 22 commits into from
Jun 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
69 changes: 55 additions & 14 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
workflow_dispatch:

jobs:
build:
build-docs:
runs-on: ubuntu-latest
defaults:
run:
Expand All @@ -35,14 +35,14 @@ jobs:
SFTP_HOST: ${{ secrets.SFTP_HOST }}
SFTP_USERNAME: ${{ secrets.SFTP_USERNAME }}
SFTP_KEY: ${{ secrets.SFTP_KEY }}
SFTP_KNOWN_HOSTS: ${{secrets.SFTP_KNOWN_HOSTS}}
SFTP_KNOWN_HOSTS: ${{ secrets.SFTP_KNOWN_HOSTS }}
run: |
echo "$SFTP_KEY" > sftp_key
chmod 600 sftp_key
echo "$SFTP_KNOWN_HOSTS" > known_hosts
chmod 600 known_hosts
rsync -avz --delete -e "ssh -i sftp_key -o UserKnownHostsFile=known_hosts" dist/ $SFTP_USERNAME@$SFTP_HOST:/var/www/www.setonix
doc:
build-doc-api:
runs-on: ubuntu-24.04
defaults:
run:
Expand All @@ -54,12 +54,10 @@ jobs:
with:
flutter-version-file: app/pubspec.yaml
- name: Install dependencies
run: |
flutter pub get
run: flutter pub get
- name: Generate documentation
run: |
dart doc
- name: Deploy to SFTP
run: dart doc
- name: Deploy API docs via SFTP
if: github.ref == 'refs/heads/develop'
env:
SFTP_HOST: ${{ secrets.SFTP_HOST }}
Expand All @@ -72,7 +70,7 @@ jobs:
echo "$SFTP_KNOWN_HOSTS" > known_hosts
chmod 600 known_hosts
rsync -avz --delete -e "ssh -i sftp_key -o UserKnownHostsFile=known_hosts" doc/api/ $SFTP_USERNAME@$SFTP_HOST:/var/www/api.setonix
web:
build-web:
runs-on: ubuntu-24.04
defaults:
run:
Expand All @@ -84,9 +82,8 @@ jobs:
with:
flutter-version-file: app/pubspec.yaml
- name: Install dependencies
run: |
flutter pub get
- name: Generate
run: flutter pub get
- name: Generate code
run: |
cd ../tools
dart pub get
Expand All @@ -104,16 +101,60 @@ jobs:
echo "WEB_DIR=web" >> $GITHUB_ENV
- name: Build
run: flutter build web --wasm --release --no-web-resources-cdn --dart-define=flavor=$SETONIX_FLAVOR
- name: Deploy to SFTP
- name: Deploy Flutter web via SFTP
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main'
env:
SFTP_HOST: ${{ secrets.SFTP_HOST }}
SFTP_USERNAME: ${{ secrets.SFTP_USERNAME }}
SFTP_KEY: ${{ secrets.SFTP_KEY }}
SFTP_KNOWN_HOSTS: ${{secrets.SFTP_KNOWN_HOSTS}}
SFTP_KNOWN_HOSTS: ${{ secrets.SFTP_KNOWN_HOSTS }}
run: |
echo "$SFTP_KEY" > sftp_key
chmod 600 sftp_key
echo "$SFTP_KNOWN_HOSTS" > known_hosts
chmod 600 known_hosts
rsync -avz --delete -e "ssh -i sftp_key -o UserKnownHostsFile=known_hosts" build/web/ $SFTP_USERNAME@$SFTP_HOST:/var/www/$WEB_DIR.setonix
build-servers:
runs-on: ubuntu-latest
defaults:
run:
working-directory: servers
steps:
- uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
package_json_file: docs/package.json
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 24
cache: "pnpm"
cache-dependency-path: docs/pnpm-lock.yaml
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm build
- name: Setup SSH Agent
if: github.ref == 'refs/heads/develop'
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Add SSH Known Hosts
if: github.ref == 'refs/heads/develop'
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_KNOWN_HOSTS }}" > ~/.ssh/known_hosts

- name: Deploy SSR build via rsync
if: github.ref == 'refs/heads/develop'
run: |
rsync -avz --delete ./dist/ ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }}:/var/www/servers.setonix

- name: Restart SSR application
if: github.ref == 'refs/heads/develop'
run: |
ssh ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} << 'EOF'
pm2 stop astro-servers || true
PORT=${{ secrets.SERVERS_PORT }} pm2 start dist/server/entry.mjs --name astro-servers --update-env
EOF
1 change: 1 addition & 0 deletions api/lib/helpers.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'src/helpers/crypto.dart';
2 changes: 2 additions & 0 deletions api/lib/services.dart
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export 'src/services/asset.dart';
export 'src/services/challenge.dart';
export 'src/services/network.dart';
export 'src/services/user.dart';
1 change: 1 addition & 0 deletions api/lib/setonix_api.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// The Linwood Setonix API
library;

export 'helpers.dart';
export 'models.dart';
export 'event.dart';
export 'services.dart';
28 changes: 28 additions & 0 deletions api/lib/src/event/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,31 @@ final class ModeChangeRequest extends ClientWorldEvent
ModeChangeRequest(this.location);
ModeChangeRequest.plain() : location = null;
}

@MappableClass(includeCustomMappers: [Base64Uint8ListHook()])
final class AuthenticateRequest extends ClientWorldEvent
with AuthenticateRequestMappable {
final Uint8List signature;
final Uint8List publicKey;

static final _generator = Ed25519();

AuthenticateRequest(this.signature, this.publicKey);

static Future<AuthenticateRequest> build(
AuthenticatedRequested request, SetonixAccount account) async {
final challenge = request.challenge;
final keyPair = account.keyPair;
final signature = await _generator.sign(challenge, keyPair: keyPair);
return AuthenticateRequest(
Uint8List.fromList(signature.bytes),
account.publicKey,
);
}

Future<bool> verify(Uint8List challenge) => _generator.verify(
challenge,
signature: Signature(signature,
publicKey: SimplePublicKey(publicKey, type: KeyPairType.ed25519)),
);
}
1 change: 1 addition & 0 deletions api/lib/src/event/event.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:convert';

import 'package:cryptography_plus/cryptography_plus.dart';
import 'package:dart_mappable/dart_mappable.dart';
import 'package:networker/networker.dart';
import 'package:setonix_api/event.dart';
Expand Down
Loading