10 Commits

Author SHA1 Message Date
c6ad01b710 Fix textChannelService.ts websocket
All checks were successful
Setup testing environment and test the code / build (push) Successful in 1m1s
Publish to NPM / build-and-publish (release) Successful in 30s
2026-04-11 17:14:39 +02:00
113cff5512 Fix textChannelService.ts websocket
Some checks failed
Setup testing environment and test the code / build (push) Failing after 1s
Publish to NPM / build-and-publish (release) Successful in 40s
2026-04-11 17:03:19 +02:00
2c91b73a60 Fix textChannelService.ts websocket
Some checks failed
Setup testing environment and test the code / build (push) Has been cancelled
2026-04-11 17:02:53 +02:00
866c8a1838 Removed dotenv
All checks were successful
Setup testing environment and test the code / build (push) Successful in 1m22s
Publish to NPM / build-and-publish (release) Successful in 29s
2026-04-10 21:17:16 +02:00
926a28b7f9 SessionManager hotfix
All checks were successful
Setup testing environment and test the code / build (push) Successful in 2m37s
Publish to NPM / build-and-publish (release) Successful in 1m44s
2026-04-10 19:18:13 +02:00
9d6a18dda4 Updated Attachment type
All checks were successful
Setup testing environment and test the code / build (push) Successful in 2m42s
Publish to NPM / build-and-publish (release) Successful in 2m47s
2026-04-10 09:18:16 +02:00
76f573023f WebSocket onNewConnId scope hotfix
All checks were successful
Setup testing environment and test the code / build (push) Successful in 1m10s
Publish to NPM / build-and-publish (release) Successful in 32s
2026-04-10 08:14:47 +02:00
b217123b99 Fix tests
All checks were successful
Setup testing environment and test the code / build (push) Successful in 1m9s
Publish to NPM / build-and-publish (release) Successful in 32s
2026-04-10 08:01:11 +02:00
59f7e10dd7 Race-condition fix
Some checks failed
Setup testing environment and test the code / build (push) Failing after 1m9s
2026-04-10 07:59:45 +02:00
56a0167120 WebSocket update
Some checks failed
Setup testing environment and test the code / build (push) Failing after 1m26s
Publish to NPM / build-and-publish (release) Successful in 29s
2026-04-10 07:38:52 +02:00
16 changed files with 44 additions and 29 deletions

View File

@@ -45,13 +45,11 @@ jobs:
with:
node-version: '24'
- name: Create .env file
run: |
echo "API_URL=http://api:3000" >> .env
echo "CDN_URL=http://cdn:4000" >> .env
echo "WS_URL=ws://api:3000" >> .env
- name: Run Vitest
env:
API_URL: http://api:3000
CDN_URL: http://cdn:4000
WS_URL: ws://api:3000
run: |
npm install
npm test --experimental-websocket

View File

@@ -1,6 +1,6 @@
{
"name": "@chatenium/chatenium-sdk",
"version": "1.0.11",
"version": "1.1.7",
"description": "A library for interacting with the Chatenium API",
"type": "module",
"main": "dist/index.js",
@@ -39,7 +39,6 @@
"dependencies": {
"@faker-js/faker": "^10.4.0",
"axios": "^1.14.0",
"dotenv": "^17.4.0",
"msw": "^2.12.14",
"uuid": "^13.0.0"
}

View File

@@ -5,19 +5,12 @@ export interface SDKConfig {
}
declare const process: any;
declare const require: any;
const isNode =
typeof process !== 'undefined' &&
typeof process.versions !== 'undefined' &&
typeof process.versions.node !== 'undefined';
if (isNode) {
try {
require('dotenv').config();
} catch { }
}
const getEnv = (key: string): string | undefined => {
if (!isNode) return undefined;
return process.env?.[key];

View File

@@ -80,6 +80,9 @@ export class WebSocketHandler {
public registerService(service: WSListenerPipe) {
console.log("Registering service", service)
if (this.connId) {
service.onNewConnId(this.connId)
}
this.listeners.add(service);
}

View File

@@ -17,6 +17,7 @@ export interface JoinWebsocketRoomReq {
channelId: string
networkId: string
categoryId: string
disableAutoRemove: boolean
}
export interface StreamRegistry {

View File

@@ -24,4 +24,5 @@ export interface Attachment {
path: string
height: number
width: number
extraMetaData: Record<string, string> // Used by clients
}

View File

@@ -58,6 +58,7 @@ export interface JoinWsRoomReq {
connId: string
chatid: string
userid: string
disableAutoRemove: boolean
}
// Response schemas

View File

@@ -255,6 +255,7 @@ export interface JoinWebSocketRoomReq {
userid: string
connId: string
networkId: string
disableAutoRemove: boolean
}
export interface GetFromInviteReq {

View File

@@ -78,6 +78,7 @@ export interface JoinWsRoomReq {
networkId: string
categoryId: string
userid: string
disableAutoRemove: boolean
}
// Response schemas

View File

@@ -31,7 +31,7 @@ export class BroadcastChannelService {
})
WebSocketHandler.getInstance().registerService({
identifier: channelId,
onNewConnId: this.onNewConnId,
onNewConnId: newConnId => this.onNewConnId(newConnId),
onNewMessage: wsMessageListener,
})
}
@@ -81,6 +81,7 @@ export class BroadcastChannelService {
networkId: this.networkId,
connId: WebSocketHandler.getInstance().connId,
categoryId: this.categoryId,
disableAutoRemove: true
});
return
} catch (e) {

View File

@@ -32,7 +32,7 @@ export class ChatService {
})
WebSocketHandler.getInstance().registerService({
identifier: userid,
onNewConnId: this.onNewConnId,
onNewConnId: newConnId => this.onNewConnId(newConnId),
onNewMessage: wsMessageListener,
})
}

View File

@@ -36,7 +36,7 @@ export class DMService {
})
WebSocketHandler.getInstance().registerService({
identifier: chatid,
onNewConnId: this.onNewConnId,
onNewConnId: newConnId => this.onNewConnId(newConnId),
onNewMessage: wsMessageListener,
})
}
@@ -246,10 +246,11 @@ export class DMService {
*/
async joinWebSocketRoom(): Promise<void> {
try {
await this.client.post("v2/chat/dm/joinWebSocketRoom", <JoinWsRoomReq>{
await this.client.post("v2/chat/dm/joinWebSocketRoom", <JoinWsRoomReq>{
chatid: this.chatid,
userid: this.userid,
connId: WebSocketHandler.getInstance().connId,
disableAutoRemove: true
});
return
} catch (e) {

View File

@@ -39,7 +39,7 @@ export class NetworkService {
})
WebSocketHandler.getInstance().registerService({
identifier: networkId,
onNewConnId: this.onNewConnId,
onNewConnId: newConnId => this.onNewConnId(newConnId),
onNewMessage: wsMessageListener,
})
}
@@ -863,6 +863,7 @@ export class NetworkService {
userid: this.userid,
networkId: this.networkId,
connId: connId,
disableAutoRemove: true
});
return
} catch (e) {

View File

@@ -36,14 +36,21 @@ export class SessionManager {
async loadSessions(): Promise<Session[]> {
const tokens = await this.keyring.getAll()
const sessions: Session[] = []
for (const tokenKey of tokens) {
const token = await this.keyring.get(tokenKey)
const userData = await this.database.get("sessions", tokenKey)
if (userData) {
sessions.push({
token: token,
userData: JSON.parse(userData)
})
try {
const token = await this.keyring.get(tokenKey)
const userData = await this.database.get("sessions", tokenKey)
if (userData && userData.trim().length > 0) {
sessions.push({
token: token,
userData: JSON.parse(userData)
})
}
} catch (e) {
console.error(`Failed to parse session for ${tokenKey}:`, e)
continue
}
}
@@ -70,6 +77,11 @@ export class SessionManager {
*/
async loadPreferredSession() {
const sessions = await this.loadSessions()
if (sessions.length == 0) {
throw new Error("No sessions found")
}
let preferredUser = await this.getPreferredUser()
if (preferredUser == "") {
preferredUser = sessions[0].userData.userid

View File

@@ -40,7 +40,7 @@ export class TextChannelServiceService {
})
WebSocketHandler.getInstance().registerService({
identifier: channelId,
onNewConnId: this.onNewConnId,
onNewConnId: newConnId => this.onNewConnId(newConnId),
onNewMessage: wsMessageListener,
})
}
@@ -263,12 +263,13 @@ export class TextChannelServiceService {
*/
async joinWebSocketRoom(): Promise<void> {
try {
const resp = await this.client.patch("network/channel/joinWebSocketRoom", <JoinWsRoomReq>{
const resp = await this.client.post("v2/network/channel/joinWebSocketRoom", <JoinWsRoomReq>{
networkId: this.networkId,
channelId: this.channelId,
categoryId: this.categoryId,
userid: this.userid,
connId: WebSocketHandler.getInstance().connId,
disableAutoRemove: true
});
return
} catch (e) {

View File

@@ -18,6 +18,7 @@ describe("FileUploadService Integration Testing", () => {
const service = new FileUploadService(FILE_UPL_SERVICE_TESTING_TOKEN);
await service.uploadFiles(
"",
FILE_UPL_SERVICE_TESTING_CHAT_ID,
FILE_UPL_SERVICE_TESTING_USER_ID,
[