14 Commits
1.1.6 ... 1.2.2

Author SHA1 Message Date
bb7118242b Fix sessionManager type errors
All checks were successful
Setup testing environment and test the code / build (push) Successful in 26s
Publish to NPM / build-and-publish (release) Successful in 17s
2026-04-18 13:22:33 +02:00
d3a295d598 Hotfixes for updateSession in sessionManager.ts
All checks were successful
Setup testing environment and test the code / build (push) Successful in 26s
Publish to NPM / build-and-publish (release) Successful in 17s
2026-04-18 13:10:50 +02:00
d97abc00e2 Fix version number
All checks were successful
Setup testing environment and test the code / build (push) Successful in 24s
Publish to NPM / build-and-publish (release) Successful in 26s
2026-04-17 16:27:31 +02:00
cada5487bf Merge remote-tracking branch 'origin/main'
Some checks failed
Setup testing environment and test the code / build (push) Successful in 33s
Publish to NPM / build-and-publish (release) Failing after 15s
# Conflicts:
#	package.json
2026-04-17 16:25:28 +02:00
2f9c65512b Added network permissions as constants and a permission calculator in permissions.ts 2026-04-17 16:25:03 +02:00
edd87375c3 Update package.json
Some checks failed
Setup testing environment and test the code / build (push) Has been cancelled
Publish to NPM / build-and-publish (release) Successful in 17s
2026-04-16 18:15:30 +02:00
b2d5b84435 Update package.json
Some checks failed
Setup testing environment and test the code / build (push) Has been cancelled
2026-04-16 18:13:06 +02:00
c460dc5385 Updated networkService.ts to use new /v2/ endpoint for uploading new network pictures
All checks were successful
Setup testing environment and test the code / build (push) Successful in 26s
Publish to NPM / build-and-publish (release) Successful in 37s
2026-04-16 16:55:48 +02:00
f54e76ab72 Updated extraMetadata to allow any type of data
All checks were successful
Setup testing environment and test the code / build (push) Successful in 26s
Publish to NPM / build-and-publish (release) Successful in 18s
2026-04-15 16:11:01 +02:00
fb1555338d Update WS
Some checks failed
Publish to NPM / build-and-publish (release) Successful in 27s
Setup testing environment and test the code / build (push) Has been cancelled
2026-04-14 16:44:27 +02:00
c98c917594 Update WS 2026-04-14 16:44:19 +02:00
cfb72d1772 Fixed types in getQuick functions
All checks were successful
Setup testing environment and test the code / build (push) Successful in 1m48s
Publish to NPM / build-and-publish (release) Successful in 27s
2026-04-14 16:05:09 +02:00
01d07d65d1 WebSocket Hotfix
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-11 17:25:10 +02:00
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
9 changed files with 69 additions and 21 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@chatenium/chatenium-sdk",
"version": "1.1.6",
"version": "1.2.2",
"description": "A library for interacting with the Chatenium API",
"type": "module",
"main": "dist/index.js",

32
src/core/permissions.ts Normal file
View File

@@ -0,0 +1,32 @@
export const permissions = {
createAndEditCategories: 2,
deleteCategories: 4,
createAndEditChannels: 8,
deleteChannels: 16,
deleteAnyMessage: 32,
pinMessages: 64,
createAndEditRanks: 128,
deleteRanks: 256,
changeNetworkNamePictureAndVisibility: 512,
createEmojis: 1024,
deleteEmojis: 2048,
manageEmbed: 4096,
createWebhooks: 8192,
deleteWebhooks: 16384,
createInvites: 32768,
deleteInvites: 65536,
sendMessages: 131072,
seeChannels: 262144,
banMembers: 524288,
kickMembers: 1048576,
unAndAssignRanksToMember: 2097152,
}
/**
* Determines whether the set of permissions includes the permission. Note that network owners have regular permissions just like the other members, so if the userid matches with the network's creator ID, then the permission is automatically granted. This logic is not included in this function.
* @param permissions
* @param permission
*/
export function permissionGranted(permissions: number, permission: number): Boolean {
return (permissions & permission) === permission;
}

View File

@@ -43,6 +43,13 @@ export class WebSocketHandler {
this.connection = new WebSocket(`${environment.get().wsUrl}/v2/ws?userid=${userid}&access_token=${resp.data.token}`)
console.log("Connected to websocket successfully")
this.startListening()
this.connection.onclose = () => {
console.error("The WebSocket connection was closed unexpectedly. Reconnecting...")
setTimeout(() => {
this.connect(userid, token)
}, 3000)
}
return
} catch (e) {
console.log(e)

View File

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

View File

@@ -208,9 +208,11 @@ export interface GetMembersReq {
}
export interface UploadNewPictureReq {
picId: string
userid: string
networkId: string
data: string
isImage: boolean
monogramColors: RGB | null
}
export interface ChangeVisibilityReq {

View File

@@ -58,7 +58,7 @@ export class ChatService {
}
}
async getQuick(): Promise<Message[]> {
async getQuick(): Promise<Chat[]> {
const chats = await this.database.get("chats", this.userid)
if (chats) {
return JSON.parse(chats)

View File

@@ -108,7 +108,7 @@ export class NetworkService {
}
}
async getQuick(): Promise<Message[]> {
async getQuick(): Promise<Network[]> {
const networks = await this.database.get("networks", this.userid)
if (networks) {
return JSON.parse(networks)
@@ -711,14 +711,18 @@ export class NetworkService {
/**
* Uploads a new network picture
* @param picId
* @param isImage
* @param image
* @param colors
*/
async uploadNewPic(picId: string): Promise<void> {
async uploadNewPic(isImage: boolean, image: string | null, colors: RGB | null): Promise<void> {
try {
await this.client.patch<PublicUserData[]>("network/uploadNewPic", <UploadNewPictureReq>{
await this.client.patch<PublicUserData[]>("v2/network/uploadNewPic", <UploadNewPictureReq>{
userid: this.userid,
networkId: this.networkId,
picId: picId,
data: image,
isImage: isImage,
monogramColors: colors
});
return
} catch (e) {

View File

@@ -100,21 +100,23 @@ export class SessionManager {
* Validates and updates all sessions and returns with a new session list
* @param sessions
*/
updateSessions(sessions: Session[]): Session[] {
sessions.forEach(async session => {
const index = sessions.indexOf(session)
async updateSessions(sessions: Session[]): Promise<Session[]> {
const activeSessions: Session[] = [];
for (const session of sessions) {
if (!await this.validateSession(session.token)) {
this.database.delete("sessions", session.userData.userid)
this.keyring.delete(session.userData.userid)
sessions.splice(index, 1)
this.database.delete("sessions", session.userData.userid);
this.keyring.delete(session.userData.userid);
console.warn(`Validating session for user ${session.userData.userid} failed. Deleting session...`)
continue;
}
const updatedUserData = await this.updateUserData(session)
this.database.set("sessions", session.userData.userid, updatedUserData)
sessions[index] = updatedUserData
})
const updatedUserData = await this.updateUserData(session);
this.database.set("sessions", session.userData.userid, JSON.stringify(updatedUserData.userData));
activeSessions.push(updatedUserData);
}
return sessions
return activeSessions;
}
private async validateSession(token: string): Promise<boolean> {

View File

@@ -48,6 +48,7 @@ export class TextChannelServiceService {
private onNewConnId(newConnId: string) {
console.log("NetworkService: New connection id")
this.client.defaults.headers["X-WS-ID"] = newConnId;
this.joinWebSocketRoom().then()
}
/**
@@ -263,7 +264,7 @@ export class TextChannelServiceService {
*/
async joinWebSocketRoom(): Promise<void> {
try {
const resp = await this.client.patch("v2/network/channel/joinWebSocketRoom", <JoinWsRoomReq>{
const resp = await this.client.post("v2/network/channel/joinWebSocketRoom", <JoinWsRoomReq>{
networkId: this.networkId,
channelId: this.channelId,
categoryId: this.categoryId,