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

refactor(websocket): update websocket server to yrs-warp #786

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
aed9fdf
refactor(websocket): update websocket server to yrs-warp
kasugamirai Jan 21, 2025
06b4d61
feat(websocket): add Docker configuration
kasugamirai Jan 21, 2025
b10b4c9
Update docker config
kasugamirai Jan 21, 2025
1a8a95c
Update toml file
kasugamirai Jan 21, 2025
4f29e51
Update websocket server port from 8080 to 8000
kasugamirai Jan 21, 2025
63a7c41
feat(websocket): update dependencies, add authentication configuratio…
kasugamirai Jan 22, 2025
d6a28c2
feat(auth): add VerifyAuth endpoint for token validation and update r…
kasugamirai Jan 22, 2025
c5a9ed6
feat(auth): implement JWT middleware for new auth routes and remove V…
kasugamirai Jan 22, 2025
12b3499
refactor(auth): simplify token verification by removing doc_id parame…
kasugamirai Jan 22, 2025
022646a
refactor(websocket): update configuration handling to use .env file, …
kasugamirai Jan 22, 2025
a865d9a
chore(websocket): add .env file for environment variables and update …
kasugamirai Jan 22, 2025
1097d2a
refactor(auth): update JWT provider configuration and enhance WebSock…
kasugamirai Jan 23, 2025
b83729d
refactor(auth): update WebSocket token verification route and adjust …
kasugamirai Jan 23, 2025
83ba487
fix(auth): change WebSocket token verification route from GET to POST
kasugamirai Jan 23, 2025
d617fdb
refactor(auth): restore dynamic JWT provider configuration from config
kasugamirai Jan 23, 2025
a7d4f6f
refactor(websocket): reorganize broadcast module and update module im…
kasugamirai Jan 25, 2025
6517b34
refactor(auth): simplify auth middleware configuration and route setup
kasugamirai Jan 27, 2025
4b558bb
chore(deps): update Rust dependencies to latest versions
kasugamirai Jan 27, 2025
2ab5684
fix(websocket): enable default features in Dockerfile build
kasugamirai Jan 30, 2025
266a055
chore(auth): add commented-out example JWT provider configuration
kasugamirai Jan 30, 2025
cdc9985
chore(docker): remove version specification from docker-compose files
kasugamirai Jan 30, 2025
86ad707
Bump Version
kasugamirai Feb 5, 2025
11bc0de
fix(ui): correct indentation in WebSocket sync logic
kasugamirai Feb 5, 2025
959a23b
refactor(config): improve configuration loading with builder pattern …
kasugamirai Feb 6, 2025
ab8e2ec
chore(websocket): remove entire websocket module implementation
kasugamirai Feb 6, 2025
eb590e6
fix(websocket): improve GCS bucket initialization error handling
kasugamirai Feb 6, 2025
809444c
fix(websocket): improve WebSocket stream message handling
kasugamirai Feb 6, 2025
d4ceb40
fix(websocket): improve broadcast group connection cleanup logic
kasugamirai Feb 6, 2025
b18b0e7
fix(websocket): improve document group creation and key parsing error…
kasugamirai Feb 6, 2025
8f065c1
feat(websocket): add endpoint to retrieve latest document state
kasugamirai Feb 7, 2025
708271a
refactor(websocket): update document retrieval logic with improved tr…
kasugamirai Feb 7, 2025
662aabd
feat(websocket): add document history retrieval endpoint with robust …
kasugamirai Feb 8, 2025
bd6459e
feat(websocket): add document history retrieval endpoint with robust …
kasugamirai Feb 8, 2025
777680c
fix(websocket): improve GCS list objects error handling
kasugamirai Feb 10, 2025
602e7e4
feat(websocket): enhance document history tracking with timestamps an…
kasugamirai Feb 10, 2025
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
1 change: 0 additions & 1 deletion api/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3"
services:
reearth-flow-api:
image: reearth/reearth-flow:latest
Expand Down
4 changes: 4 additions & 0 deletions api/internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func initEcho(ctx context.Context, cfg *ServerConfig) *echo.Echo {

// auth config
authConfig := cfg.Config.JWTProviders()

log.Infof("auth: config: %#v", authConfig)
authMiddleware := echo.WrapMiddleware(lo.Must(appx.AuthMiddleware(authConfig, adapter.ContextAuthInfo, true)))

Expand Down Expand Up @@ -94,6 +95,9 @@ func initEcho(ctx context.Context, cfg *ServerConfig) *echo.Echo {
apiPrivate.Use(authMiddleware, attachOpMiddleware(cfg))
apiPrivate.POST("/graphql", GraphqlAPI(cfg.Config.GraphQL, gqldev))
apiPrivate.POST("/signup", Signup())
apiPrivate.POST("/verify/ws-token", func(c echo.Context) error {
return c.JSON(http.StatusOK, echo.Map{"authorized": true})
})
kasugamirai marked this conversation as resolved.
Show resolved Hide resolved

if !cfg.Config.AuthSrv.Disabled {
apiPrivate.POST("/signup/verify", StartSignupVerify())
Expand Down
26 changes: 18 additions & 8 deletions ui/src/lib/yjs/useYjsSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { WebsocketProvider } from "y-websocket";
import * as Y from "yjs";

import { useAuth } from "@flow/lib/auth";

Check warning on line 6 in ui/src/lib/yjs/useYjsSetup.ts

View workflow job for this annotation

GitHub Actions / ci-ui / ci

`@flow/lib/auth` import should occur after import of `@flow/global-constants`
import { config } from "@flow/config";
import { DEFAULT_ENTRY_GRAPH_ID } from "@flow/global-constants";

Expand All @@ -13,6 +14,7 @@
const { projectId }: { projectId: string } = useParams({
strict: false,
});
const { getAccessToken } = useAuth();
kasugamirai marked this conversation as resolved.
Show resolved Hide resolved

const [undoManager, setUndoManager] = useState<Y.UndoManager | null>(null);

Expand All @@ -31,11 +33,18 @@
let yWebSocketProvider: WebsocketProvider | null = null;

if (workflowId && websocket && projectId) {
yWebSocketProvider = new WebsocketProvider(
websocket,
`${projectId}:${workflowId}`,
yDoc,
);
(async () => {
const token = await getAccessToken();
yWebSocketProvider = new WebsocketProvider(
websocket,
`${projectId}:${workflowId}`,
yDoc,
{
params: {
token,
},
},
);

yWebSocketProvider.once("sync", () => {
if (yWorkflows.length === 0) {
Expand All @@ -48,8 +57,9 @@
});
}

setIsSynced(true); // Mark as synced
});
setIsSynced(true); // Mark as synced
});
})();
}

// Initial state setup
Expand All @@ -63,7 +73,7 @@
return () => {
yWebSocketProvider?.destroy(); // Cleanup on unmount
};
}, [projectId, workflowId]);
}, [projectId, workflowId, getAccessToken]);

const { yDoc, yWorkflows, undoTrackerActionWrapper } = state || {};

Expand Down
Binary file removed websocket/.DS_Store
Binary file not shown.
9 changes: 0 additions & 9 deletions websocket/.dockerignore

This file was deleted.

8 changes: 8 additions & 0 deletions websocket/.env-sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
REEARTH_FLOW_REDIS_URL=redis://redis:6379
REEARTH_FLOW_REDIS_TTL=3600
REEARTH_FLOW_GCS_BUCKET_NAME=yrs-dev
REEARTH_FLOW_GCS_ENDPOINT=http://fake-gcs:4443
REEARTH_FLOW_AUTH_URL=http://localhost:8080/api/verify/ws-token
REEARTH_FLOW_AUTH_TIMEOUT_MS=5000
REEARTH_FLOW_APP_ENV=development
REEARTH_FLOW_ORIGINS=http://localhost:3000,https://flow.test.reearth.dev,https://*.netlify.app
20 changes: 2 additions & 18 deletions websocket/.gitignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,2 @@
# Generated by Cargo
# will have compiled files and executables
debug/
target/

# These are backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

out/
out.json
.idea
.vscode
.idea
local_storage/
.DS_Store
/target/
/output/
16 changes: 0 additions & 16 deletions websocket/.taplo.toml

This file was deleted.

Loading
Loading