3 Commits

Author SHA1 Message Date
22999c34f9 style: remove unnecessary whitespace in packet.ts and basic.test.ts
All checks were successful
CI / build (push) Successful in 17s
CI / publish (push) Successful in 14s
2025-09-06 19:07:27 +01:00
61b7c50868 refactor: update romulus-js import path to @3t/romulus and adjust tests accordingly
Some checks failed
CI / build (push) Failing after 12s
CI / publish (push) Has been skipped
2025-09-06 19:06:08 +01:00
15fa2b1608 refactor: rename package to @3t/bennc and update repository URL
Some checks failed
CI / build (push) Failing after 10s
CI / publish (push) Has been skipped
- Changed package name from "bennc-js" to "@3t/bennc"
- Updated repository URL to point to the new location
- Added publishConfig for npm registry
- Updated devDependencies to newer versions
2025-09-06 19:03:04 +01:00
9 changed files with 3480 additions and 7322 deletions

View File

@@ -1,52 +0,0 @@
kind: pipeline
type: docker
name: build
steps:
- name: install
image: node:lts-alpine
commands:
- apk add git
- npm install
- name: lint
image: node:lts-alpine
commands:
- npm run lint
depends_on:
- install
- name: test
image: node:lts-alpine
commands:
- npm run test
depends_on:
- install
- name: build
image: node:lts-alpine
commands:
- apk add zip
- npm run build
- zip -r bennc-m.zip dist/
depends_on:
- install
- name: publish
image: plugins/gitea-release
depends_on:
- lint
- test
- build
when:
event:
- tag
settings:
base_url: https://git.jacknet.io
api_key:
from_secret: gitea_token
files:
- bennc-m.zip
checksum:
- md5
- sha256

57
.gitea/workflows/ci..yml Normal file
View File

@@ -0,0 +1,57 @@
name: CI
on:
push:
branches: [master]
tags: ["v*"]
pull_request:
branches: [master]
jobs:
build:
runs-on: ubuntu-latest
container: node:lts-alpine
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install dependencies
run: npm ci
- name: Run linter
run: npm run lint
- name: Run tests
run: npm run test
- name: Build project
run: npm run build
publish:
needs: build
runs-on: ubuntu-latest
container: node:lts-alpine
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install dependencies
run: npm ci
- name: Build project
run: npm run build
- name: Set version from git tag
run: |
VERSION=${GITHUB_REF#refs/tags/v}
npm version $VERSION --no-git-tag-version
- name: Setup npm for publishing
run: |
npm config set //git.3t.network/api/packages/3t.network/npm/:_authToken ${{ secrets.PUBLISH_TOKEN }}
- name: Publish to Gitea npm registry
run: npm publish

10665
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
{
"name": "bennc-js",
"name": "@3t/bennc",
"version": "1.0.0",
"description": "A TypeScript/Javascript BENNC implementation.",
"main": "dist/index.js",
@@ -13,17 +13,13 @@
},
"repository": {
"type": "git",
"url": "https://git.jacknet.io/TerribleCodeClub/bennc-js"
"url": "https://git.3t.network/3t.network/bennc"
},
"publishConfig": {
"registry": "https://git.3t.network/api/packages/3t.network/npm/"
},
"author": "Butlersaurus",
"license": "ISC",
"devDependencies": {
"@types/jest": "^27.4.0",
"jest": "^27.4.7",
"ts-jest": "^27.1.3",
"ts-standard": "^11.0.0",
"typescript": "^4.5.5"
},
"jest": {
"verbose": true,
"transform": {
@@ -34,5 +30,12 @@
"@3t/romulus": "^1.0.2",
"@types/color": "^3.0.3",
"color": "^4.2.0"
},
"devDependencies": {
"@types/jest": "^30.0.0",
"jest": "^30.1.3",
"prettier": "^3.6.2",
"ts-jest": "^29.4.1",
"typescript": "^5.9.2"
}
}

View File

@@ -1,4 +1,4 @@
import { encrypt, decrypt } from "romulus-js";
import { encrypt, decrypt } from "@3t/romulus";
import { DEFAULT_KEY, MessageTypes } from "../common";
import { numberToUint16BE } from "../utilities/number";
import { packOutgoingPacket } from "./packet";

View File

@@ -1,5 +1,5 @@
import Color from "color";
import { encrypt } from "romulus-js";
import { encrypt } from "@3t/romulus";
import { DEFAULT_KEY, MessageTypes } from "../common";
import { numberToUint16BE } from "../utilities/number";
import { SmartBuffer } from "../utilities/smart-buffer";

View File

@@ -1,5 +1,5 @@
import Color from "color";
import { encrypt } from "romulus-js";
import { encrypt } from "@3t/romulus";
import { DEFAULT_KEY, MessageTypes } from "../common";
import { numberToUint16BE } from "../utilities/number";
import { SmartBuffer } from "../utilities/smart-buffer";

View File

@@ -26,12 +26,17 @@ test("Create a basic message (0x0001) packet.", () => {
test("Parse a basic message (0x0001).", () => {
// Given
const data = new Uint8Array([1, 2, 3, 4]);
const encoder = new TextEncoder();
const originalMessage = encoder.encode("Test message");
// First encrypt the message to get valid encrypted data
const encryptedData = packers[MessageTypes.Basic](originalMessage, KEY);
// Extract just the data portion (skip the 4-byte header)
const dataOnly = encryptedData.slice(4);
// When
const unpackedPacket = unpackers[MessageTypes.Basic](data);
const unpackedMessage = unpackers[MessageTypes.Basic](dataOnly, KEY);
// Then
expect(unpackedPacket);
expect(unpackedPacket).toMatchObject(data);
expect(unpackedMessage).toEqual(originalMessage);
});