4 Commits
1.1.1 ... 1.1.5

Author SHA1 Message Date
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
10 changed files with 30 additions and 27 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.1.1",
"version": "1.1.5",
"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

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

View File

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

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,
})
}

View File

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

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,
})
}