Compare commits
3 Commits
61082d32e7
...
v1.0.1
| Author | SHA1 | Date | |
|---|---|---|---|
| 22999c34f9 | |||
| 61b7c50868 | |||
| 15fa2b1608 |
52
.drone.yml
52
.drone.yml
@@ -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
57
.gitea/workflows/ci..yml
Normal 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
|
||||||
10651
package-lock.json
generated
10651
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
21
package.json
21
package.json
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "bennc-js",
|
"name": "@3t/bennc",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "A TypeScript/Javascript BENNC implementation.",
|
"description": "A TypeScript/Javascript BENNC implementation.",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
@@ -13,17 +13,13 @@
|
|||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"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",
|
"author": "Butlersaurus",
|
||||||
"license": "ISC",
|
"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": {
|
"jest": {
|
||||||
"verbose": true,
|
"verbose": true,
|
||||||
"transform": {
|
"transform": {
|
||||||
@@ -34,5 +30,12 @@
|
|||||||
"@3t/romulus": "^1.0.2",
|
"@3t/romulus": "^1.0.2",
|
||||||
"@types/color": "^3.0.3",
|
"@types/color": "^3.0.3",
|
||||||
"color": "^4.2.0"
|
"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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { encrypt, decrypt } from "romulus-js";
|
import { encrypt, decrypt } from "@3t/romulus";
|
||||||
import { DEFAULT_KEY, MessageTypes } from "../common";
|
import { DEFAULT_KEY, MessageTypes } from "../common";
|
||||||
import { numberToUint16BE } from "../utilities/number";
|
import { numberToUint16BE } from "../utilities/number";
|
||||||
import { packOutgoingPacket } from "./packet";
|
import { packOutgoingPacket } from "./packet";
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export interface OutgoingPacket {
|
|||||||
export function packOutgoingPacket(outgoingPacket: OutgoingPacket): Uint8Array {
|
export function packOutgoingPacket(outgoingPacket: OutgoingPacket): Uint8Array {
|
||||||
// Default to empty data if not provided
|
// Default to empty data if not provided
|
||||||
const data = outgoingPacket.data ?? new Uint8Array(0);
|
const data = outgoingPacket.data ?? new Uint8Array(0);
|
||||||
|
|
||||||
// Verify that the data does not exceed the maximum data length.
|
// Verify that the data does not exceed the maximum data length.
|
||||||
if (data.length > MAX_DATA_LENGTH) {
|
if (data.length > MAX_DATA_LENGTH) {
|
||||||
throw RangeError(
|
throw RangeError(
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import Color from "color";
|
import Color from "color";
|
||||||
import { encrypt } from "romulus-js";
|
import { encrypt } from "@3t/romulus";
|
||||||
import { DEFAULT_KEY, MessageTypes } from "../common";
|
import { DEFAULT_KEY, MessageTypes } from "../common";
|
||||||
import { numberToUint16BE } from "../utilities/number";
|
import { numberToUint16BE } from "../utilities/number";
|
||||||
import { SmartBuffer } from "../utilities/smart-buffer";
|
import { SmartBuffer } from "../utilities/smart-buffer";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import Color from "color";
|
import Color from "color";
|
||||||
import { encrypt } from "romulus-js";
|
import { encrypt } from "@3t/romulus";
|
||||||
import { DEFAULT_KEY, MessageTypes } from "../common";
|
import { DEFAULT_KEY, MessageTypes } from "../common";
|
||||||
import { numberToUint16BE } from "../utilities/number";
|
import { numberToUint16BE } from "../utilities/number";
|
||||||
import { SmartBuffer } from "../utilities/smart-buffer";
|
import { SmartBuffer } from "../utilities/smart-buffer";
|
||||||
|
|||||||
@@ -26,12 +26,17 @@ test("Create a basic message (0x0001) packet.", () => {
|
|||||||
|
|
||||||
test("Parse a basic message (0x0001).", () => {
|
test("Parse a basic message (0x0001).", () => {
|
||||||
// Given
|
// 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
|
// When
|
||||||
const unpackedPacket = unpackers[MessageTypes.Basic](data);
|
const unpackedMessage = unpackers[MessageTypes.Basic](dataOnly, KEY);
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
expect(unpackedPacket);
|
expect(unpackedMessage).toEqual(originalMessage);
|
||||||
expect(unpackedPacket).toMatchObject(data);
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user