-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extract server util to secsync-server
- Loading branch information
Showing
24 changed files
with
268 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [Unreleased] | ||
|
||
## [0.3.0] - 2024-06-01 | ||
|
||
### Added | ||
|
||
- Initial version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
presets: [ | ||
["@babel/preset-env", { targets: { node: "current" } }], | ||
"@babel/preset-typescript", | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const fs = require("fs"); | ||
const data = fs.readFileSync("./package.json", { encoding: "utf8", flag: "r" }); | ||
|
||
// Display the file data | ||
const dataJson = JSON.parse(data); | ||
|
||
dataJson.module = "index.mjs"; | ||
dataJson.types = "index.d.ts"; | ||
dataJson.main = "index.js"; | ||
dataJson.browser = "index.mjs"; | ||
|
||
fs.writeFileSync("./dist/package.json", JSON.stringify(dataJson, null, 2)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"name": "secsync-server", | ||
"version": "0.3.0", | ||
"main": "src/index", | ||
"types": "src/index", | ||
"scripts": { | ||
"build": "pnpm build:xstate-types && pnpm tsup && pnpm build:package-json", | ||
"build:xstate-types": "xstate typegen \"./src/**/*.ts?(x)\"", | ||
"build:package-json": "node package-json-build-script.js", | ||
"prepublishOnly": "pnpm run build", | ||
"test": "jest", | ||
"ts:check": "pnpm tsc --noEmit", | ||
"lint": "echo \"No linting configured\"" | ||
}, | ||
"dependencies": { | ||
"canonicalize": "^2.0.0", | ||
"libsodium-wrappers": "^0.7.13" | ||
}, | ||
"peerDependencies": { | ||
"secsync": "*" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.24.4", | ||
"@babel/preset-env": "^7.24.4", | ||
"@babel/preset-typescript": "^7.24.1", | ||
"@types/jest": "^29.5.12", | ||
"@types/libsodium-wrappers": "^0.7.14", | ||
"@types/ws": "^8.5.10", | ||
"jest": "^29.7.0", | ||
"mock-socket": "^9.3.1" | ||
}, | ||
"jest": { | ||
"setupFilesAfterEnv": [ | ||
"<rootDir>/test/config/jestTestSetup.ts" | ||
] | ||
}, | ||
"publishConfig": { | ||
"directory": "dist", | ||
"linkDirectory": false | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/serenity-kit/secsync.git" | ||
} | ||
} |
File renamed without changes.
26 changes: 12 additions & 14 deletions
26
...c/src/server/createWebSocketConnection.ts → ...c-server/src/createWebSocketConnection.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./createWebSocketConnection"; |
2 changes: 1 addition & 1 deletion
2
packages/secsync/src/server/store.ts → packages/secsync-server/src/store.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
packages/secsync-server/src/utils/canonicalizeAndToBase64.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import canonicalize from "canonicalize"; | ||
|
||
export const canonicalizeAndToBase64 = ( | ||
input: unknown, | ||
sodium: typeof import("libsodium-wrappers") | ||
): string => { | ||
const canonicalized = canonicalize(input); | ||
if (!canonicalized) { | ||
throw new Error("Failed to canonicalize input"); | ||
} | ||
return sodium.to_base64(canonicalized); | ||
}; |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import sodium from "libsodium-wrappers"; | ||
import { WebSocket } from "mock-socket"; | ||
|
||
// @ts-expect-error | ||
global.setImmediate = jest.useRealTimers; | ||
global.WebSocket = WebSocket; | ||
|
||
jest.setTimeout(5000); | ||
|
||
beforeEach(async () => { | ||
await sodium.ready; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
|
||
"compilerOptions": { | ||
"outDir": "./dist", | ||
"types": ["jest"] | ||
}, | ||
|
||
"include": ["src/**/*"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { defineConfig } from "tsup"; | ||
|
||
export default defineConfig({ | ||
entry: ["src/index.ts"], | ||
clean: true, | ||
dts: true, | ||
format: ["cjs", "esm"], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.