Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
@adil.sudo/webshare
Advanced tools
### share files in web using peer to peer connection. #### Peer connection is being handled in this library, if you intended to use existing connection, contribute to this library.
import { Sender, Receiver, humanFileSize } from "@adil/webshare";
const labelInfo = document.getElementById("label:info")!;
const labelError = document.getElementById("label:error")!;
const btnSend = document.getElementById("btn:send")!;
const btnReceive = document.getElementById("btn:receive")!;
const input = document.getElementById("input:file") as HTMLInputElement;
const labelProgress = document.getElementById("label:progress")!;
const labelRate = document.getElementById("label:rate")!;
const peerConfig = {
host: "192.168.43.155",
port: 4112
};
let file: File;
input.addEventListener("change", (e) => {
if (!input.files) {
return;
}
file = input.files[0];
sendfile(input.files[0]);
});
const generateId = () => (new Date()).getTime().toString();
let sender: Sender;
const sendfile = (file: File) => {
const id = "sender";
sender = new Sender(peerConfig, file, id);
sender.on("open", (id) => {
labelInfo.innerText = `Connection opened at ${id}`
});
sender.on("connected", connection => {
labelInfo.innerText = `Connection with connection id ${connection.label}`;
});
sender.on("disconnected", () => {
labelInfo.innerText = `Disconnected`;
});
sender.on("error", err => {
labelError.innerText = err.message;
});
sender.on("transferrate", rate => {
labelRate.innerText = humanFileSize(rate);
});
sender.on("progress", (f, byte) => {
labelProgress.innerText = `${humanFileSize(byte)} / ${humanFileSize(f.size)}`;
})
sender.on("completed", () => {
labelInfo.innerText = "File has been sent successfully";
})
}
let receiver: Receiver;
const receiveFile = () => {
const id = prompt("Enter connection id");
if (!id) {
labelError.innerText = "Connection id is required";
return;
}
receiver = new Receiver(peerConfig, id);
receiver.on("open", rId => {
labelInfo.innerText = `Receiver is open on ${rId}`;
});
receiver.on("connected", connection => {
labelInfo.innerText = `Receiver is connected ${connection.label}`;
labelError.innerText = "";
});
receiver.on("disconnected", () => {
labelError.innerText = `Connection disconnected`;
});
receiver.on("close", () => {
labelError.innerText = "Closed connection";
})
receiver.on("error", err => {
labelError.innerText = err.message;
});
receiver.on("progress", (f, byte) => {
labelProgress.innerText = `${humanFileSize(byte)} / ${humanFileSize(f.size)}`;
})
receiver.on("completed", file => {
console.log(file)
receiver.download(file);
});
receiver.on("transferrate", byte => {
labelRate.innerText = humanFileSize(byte);
});
}
const handleClose = () => {
receiver && receiver.close();
sender && sender.close();
}
btnReceive.addEventListener("click", receiveFile);
document.getElementById("btn:close")!.addEventListener("click", handleClose);
``
FAQs
### share files in web using peer to peer connection. #### Peer connection is being handled in this library, if you intended to use existing connection, contribute to this library.
The npm package @adil.sudo/webshare receives a total of 1 weekly downloads. As such, @adil.sudo/webshare popularity was classified as not popular.
We found that @adil.sudo/webshare demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.