@hyxf/pairdrop 0.0.0-stage → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,67 @@
1
+ import crypto from 'crypto';
2
+ export const hasher = (() => {
3
+ let password;
4
+ return {
5
+ hashCodeSalted(salt) {
6
+ if (!password) {
7
+ // password is created on first call.
8
+ password = randomizer.getRandomString(128);
9
+ }
10
+ return crypto
11
+ .createHash('sha3-512')
12
+ .update(password)
13
+ .update(crypto.createHash('sha3-512').update(salt, 'utf8').digest('hex'))
14
+ .digest('hex');
15
+ },
16
+ };
17
+ })();
18
+ export const randomizer = (() => {
19
+ const charCodeLettersOnly = (r) => 65 <= r && r <= 90;
20
+ const charCodeAllPrintableChars = (r) => r === 45 ||
21
+ (47 <= r && r <= 57) ||
22
+ (64 <= r && r <= 90) ||
23
+ (97 <= r && r <= 122);
24
+ return {
25
+ getRandomString(length, lettersOnly = false) {
26
+ const charCodeCondition = lettersOnly
27
+ ? charCodeLettersOnly
28
+ : charCodeAllPrintableChars;
29
+ let string = '';
30
+ while (string.length < length) {
31
+ const values = new Uint16Array(length);
32
+ crypto.webcrypto.getRandomValues(values);
33
+ let arr = Array.from(values);
34
+ arr = arr.map(function (r) {
35
+ return r % 128;
36
+ });
37
+ arr = arr.filter(function (r) {
38
+ /* strip non-printables: if we transform into desirable range we have a probability bias, so I suppose we better skip this character */
39
+ return charCodeCondition(r);
40
+ });
41
+ string += String.fromCharCode(...arr);
42
+ }
43
+ return string.substring(0, length);
44
+ },
45
+ };
46
+ })();
47
+ /*
48
+ cyrb53 (c) 2018 bryc (github.com/bryc)
49
+ A fast and simple hash function with decent collision resistance.
50
+ Largely inspired by MurmurHash2/3, but with a focus on speed/simplicity.
51
+ Public domain. Attribution appreciated.
52
+ */
53
+ export const cyrb53 = function (str, seed = 0) {
54
+ let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
55
+ for (let i = 0, ch; i < str.length; i++) {
56
+ ch = str.charCodeAt(i);
57
+ h1 = Math.imul(h1 ^ ch, 2654435761);
58
+ h2 = Math.imul(h2 ^ ch, 1597334677);
59
+ }
60
+ h1 =
61
+ Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^
62
+ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
63
+ h2 =
64
+ Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^
65
+ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
66
+ return 4294967296 * (2097151 & h2) + (h1 >>> 0);
67
+ };
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,68 @@
1
1
  {
2
2
  "name": "@hyxf/pairdrop",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "description": "A simple file sharing app for local networks",
4
+ "version": "0.0.6",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "engines": {
8
+ "node": ">=22.0.0"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/hyxf/pairdrop.git"
13
+ },
14
+ "bin": {
15
+ "pairdrop": "./bin/pairdrop.js"
16
+ },
17
+ "files": [
18
+ "bin",
19
+ "dist",
20
+ "dist-server"
21
+ ],
22
+ "scripts": {
23
+ "dev:c": "vite",
24
+ "dev:s": "tsx watch server/index.ts",
25
+ "typecheck": "tsc -b --noEmit",
26
+ "build": "tsc -b && node scripts/clean-server-build.js && tsc -p tsconfig.server.build.json && vite build",
27
+ "prepack": "yarn build",
28
+ "pairdrop": "node ./bin/pairdrop.js",
29
+ "start": "node ./bin/pairdrop.js",
30
+ "preview": "vite preview",
31
+ "lint": "eslint .",
32
+ "format": "prettier --write \"src/**/*.{ts,tsx,css}\" \"server/**/*.{ts,js,json,md}\" \"*.{json,js,ts,html,md}\"",
33
+ "format:check": "prettier --check \"src/**/*.{ts,tsx,css}\" \"server/**/*.{ts,js,json,md}\" \"*.{json,js,ts,html,md}\""
34
+ },
35
+ "dependencies": {
36
+ "@fastify/rate-limit": "^11.2.1",
37
+ "@fastify/static": "^10.1.6",
38
+ "commander": "^14.0.0",
39
+ "fastify": "^5.12.7",
40
+ "ua-parser-js": "^1.0.37",
41
+ "unique-names-generator": "^4.3.0",
42
+ "ws": "^8.16.0"
43
+ },
44
+ "devDependencies": {
45
+ "@eslint/js": "^10.0.1",
46
+ "@tailwindcss/vite": "^4.3.3",
47
+ "@types/node": "^24.19.2",
48
+ "@types/react": "^19.3.0",
49
+ "@types/react-dom": "^19.3.0",
50
+ "@types/ws": "^8.18.2",
51
+ "@vitejs/plugin-react": "^6.1.2",
52
+ "eslint": "^10.13.0",
53
+ "eslint-plugin-react-hooks": "^7.1.1",
54
+ "eslint-plugin-react-refresh": "^0.5.7",
55
+ "globals": "^17.13.0",
56
+ "lucide-react": "^1.60.0",
57
+ "prettier": "^3.9.10",
58
+ "qrcode.react": "^4.2.0",
59
+ "react": "^19.3.1",
60
+ "react-dom": "^19.3.1",
61
+ "tailwindcss": "^4.3.3",
62
+ "tsx": "^4.23.15",
63
+ "typescript": "~6.0.3",
64
+ "typescript-eslint": "^8.71.2",
65
+ "vite": "^8.3.4",
66
+ "zustand": "^5.0.15"
67
+ }
68
+ }