Skip to content

Commit

Permalink
Big rewrite
Browse files Browse the repository at this point in the history
- two way encrypted comms in realtime file transfers
- download/upload storage file transfers
- download/upload realtime transfers
  • Loading branch information
robinkarlberg committed Apr 17, 2024
1 parent d2cefd1 commit 57937a5
Show file tree
Hide file tree
Showing 18 changed files with 793 additions and 420 deletions.
4 changes: 2 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ services:
signaling-server:
build: signaling-server
restart: unless-stopped
# ports:
# - 127.0.0.1:9002:8001
ports:
- 127.0.0.1:9002:8001
3 changes: 3 additions & 0 deletions signaling-server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,16 @@ function handleMessage(conn, message) {
} else if (data.type == 3) { // candidate
// console.log("candidate", conn._session.id + " -> " + data.recipientId, data);
if (!data.candidate) return closeConnWithReason(conn, "[candidate] Didn't specify candidate");
if (!data.sessionId) return closeConnWithReason(conn, "[candidate] Didn't specify sessionId");
if (!sessions.get(data.sessionId)) return closeConnWithReason(conn, "[candidate] Specified sessionId does not exist")

let recipientConn;
if ((recipientConn = sessions.get(data.recipientId))) {
recipientConn.send(JSON.stringify({
type: 13, // answer type
targetId: data.recipientId,
candidate: data.candidate,
callerId: data.sessionId
}));
return conn.send(JSON.stringify({
targetId: data.sessionId, success: true, type: data.type,
Expand Down
55 changes: 33 additions & 22 deletions web-server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions web-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"@zip.js/zip.js": "^2.7.41",
"bootstrap": "^5.3.2",
"bootstrap-icons": "^1.11.3",
"react": "^18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion web-server/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import IntentDescription from "./components/IntentDescription"
import AddContactModal from "./components/modals/AddContactModal";
import Adsense from "./components/Adsense";
import SideBar from "./components/app/SideBar";
import { ApiProvider } from "./providers/ApiProvider";
import { AuthProvider } from "./providers/AuthProvider";

function App() {
const { setShowContacts } = useContext(ApplicationContext)
Expand Down
2 changes: 2 additions & 0 deletions web-server/src/api/Api.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,12 @@ export async function deleteTransferFile(transferId, fileId) {
}

export async function getDownload(secretCode) {
if(secretCode[0] == "r") throw "can't download a realtime transfer"
return await get(`/download/${secretCode}`)
}

export async function downloadAll(secretCode) {
if(secretCode[0] == "r") throw "can't download a realtime transfer"
// return await get(`/transfers/${transferId}/files/${fileId}/download`)
window.location.href = `${API_URL}/download/${secretCode}/zip`
}
6 changes: 3 additions & 3 deletions web-server/src/components/app/FilesList.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { forwardRef, useContext } from "react";
import { Dropdown } from "react-bootstrap";

import * as Api from "../../api/Api"
import { ApiContext } from "../../providers/ApiProvider";
import { AuthContext } from "../../providers/AuthProvider";

export default function FilesList({ files, onFileChange }) {
const { refreshTransfers } = useContext(ApiContext)
const { refreshTransfers } = useContext(AuthContext)

const CustomToggle = forwardRef(({ children, onClick }, ref) => (
<button className="btn" ref={ref} onClick={(e) => { e.preventDefault(); onClick(e) }}>
Expand Down Expand Up @@ -58,7 +58,7 @@ export default function FilesList({ files, onFileChange }) {
</tr>
)
}

console.log(files)
return (
<div className="FilesList" style={{ maxWidth: "800px" }}>

Expand Down
12 changes: 6 additions & 6 deletions web-server/src/components/app/TransfersList.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ import { Dropdown } from "react-bootstrap";
import { Link } from "react-router-dom"

import * as Api from "../../api/Api"
import { ApiContext } from "../../providers/ApiProvider";
// import { AuthContext } from "../../providers/AuthProvider";

import { copyTransferLink } from "../../utils"
import { ApplicationContext } from "../../providers/ApplicationProvider";

export default function TransfersList({ transfers }) {
const { refreshTransfers } = useContext(ApiContext)
const { removeTransfer } = useContext(ApplicationContext)

const CustomToggle = forwardRef(({ children, onClick }, ref) => (
<button className="btn" ref={ref} onClick={(e) => { e.preventDefault(); onClick(e) }}>
<i className="bi bi-three-dots-vertical"></i>
</button>
))

const onDeleteTransfer = async (transferId) => {
await Api.deleteTransfer(transferId)
await refreshTransfers()
const onDeleteTransfer = (transfer) => {
removeTransfer(transfer)
}

const TransfersListEntry = ({ transfer }) => {
Expand All @@ -41,7 +41,7 @@ export default function TransfersList({ transfers }) {
<Dropdown.Menu className="text-small shadow">
<Dropdown.Item onClick={() => copyTransferLink(transfer)}>Copy link</Dropdown.Item>
<Dropdown.Divider></Dropdown.Divider>
<Dropdown.Item className="text-danger" onClick={() => onDeleteTransfer(transfer.id)}>
<Dropdown.Item className="text-danger" onClick={() => onDeleteTransfer(transfer)}>
Delete
</Dropdown.Item>
</Dropdown.Menu>
Expand Down
Loading

0 comments on commit 57937a5

Please sign in to comment.