mirror of
https://github.com/litruv/lit.ruv.wtf.git
synced 2026-11-29 18:05:46 +11:00
feat: add MxjsClient for lightweight Matrix client functionality
- Implemented core methods for user authentication (register, login, logout). - Added room management features (createRoom, joinRoom, leaveRoom, inviteUser). - Included message handling capabilities (sendMessage, editMessage, redactEvent). - Introduced user moderation actions (kickUser, banUser, unbanUser). - Implemented profile management (getProfile, setDisplayName, setAvatarUrl). - Added support for media uploads and fetching messages from room timelines. - Included event handling with emit and on methods for custom event listeners. - Sanitization of HTML content and mention handling in messages.
This commit is contained in:
1 parent
6d7ee1db71
commit
df10268a83
7 files changed
+2755
-554
No files matched your search
Generated
+8
-2
@@ -9,9 +9,9 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@litruv/mxjs-lite": "^1.0.1",
|
||||||
"jimp": "^1.6.0"
|
"jimp": "^1.6.0"
|
||||||
},
|
}
|
||||||
"devDependencies": {}
|
|
||||||
},
|
},
|
||||||
"node_modules/@jimp/core": {
|
"node_modules/@jimp/core": {
|
||||||
"version": "1.6.0",
|
"version": "1.6.0",
|
||||||
@@ -425,6 +425,12 @@
|
|||||||
"node": ">=18"
|
"node": ">=18"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@litruv/mxjs-lite": {
|
||||||
|
"version": "1.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@litruv/mxjs-lite/-/mxjs-lite-1.1.2.tgz",
|
||||||
|
"integrity": "sha512-kEL/MZdezhibPNQFiQWUWRBPRxfjWTUNnDNpqxmDyLFFG8iLXMQy2mJAMYPBgxw6D+NXARiMcABp5pEWezfC9w==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/@tokenizer/token": {
|
"node_modules/@tokenizer/token": {
|
||||||
"version": "0.3.0",
|
"version": "0.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/@tokenizer/token/-/token-0.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/@tokenizer/token/-/token-0.3.0.tgz",
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
"author": "Max Litruv Boonzaayer",
|
"author": "Max Litruv Boonzaayer",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@litruv/mxjs-lite": "^1.0.1",
|
||||||
"jimp": "^1.6.0"
|
"jimp": "^1.6.0"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
+354
-545
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -253,13 +253,9 @@ class NumberMatchGame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wrap-around horizontal (end of one row to start of next)
|
// Wrap-around: scan reading order across row boundaries (right to end of row,
|
||||||
if (rowEnd === rowStart + 1 && colStart === this.width - 1 && colEnd === 0) {
|
// down to next row, left-to-right until reaching the second tile)
|
||||||
// Adjacent via wrap
|
if (rowStart !== rowEnd && this.isSegmentClear(start, end, 1)) {
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (diff === 1 || diff === this.width) {
|
|
||||||
// Directly adjacent
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import samsayCmd from './scripts/commands/samsay.js';
|
|||||||
// Import Matrix client
|
// Import Matrix client
|
||||||
import {
|
import {
|
||||||
initMatrixClient,
|
initMatrixClient,
|
||||||
|
updateClientSession,
|
||||||
chatMode,
|
chatMode,
|
||||||
matrixApi,
|
matrixApi,
|
||||||
fetchPublicLastMessage,
|
fetchPublicLastMessage,
|
||||||
@@ -581,6 +582,14 @@ const commands = {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sync session to mxClient if exists
|
||||||
|
if (window.matrixSession.accessToken && window.matrixSession.userId) {
|
||||||
|
updateClientSession({
|
||||||
|
accessToken: window.matrixSession.accessToken,
|
||||||
|
userId: window.matrixSession.userId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Register/login user if not logged in
|
// Register/login user if not logged in
|
||||||
if (!window.matrixSession.accessToken) {
|
if (!window.matrixSession.accessToken) {
|
||||||
try {
|
try {
|
||||||
@@ -627,6 +636,8 @@ const commands = {
|
|||||||
localStorage.setItem('matrix_username', username);
|
localStorage.setItem('matrix_username', username);
|
||||||
localStorage.setItem('matrix_password', password);
|
localStorage.setItem('matrix_password', password);
|
||||||
|
|
||||||
|
updateClientSession({ accessToken: regData.access_token, userId: regData.user_id });
|
||||||
|
|
||||||
term.writeln(` Registered as: ${regData.user_id}\r\n`);
|
term.writeln(` Registered as: ${regData.user_id}\r\n`);
|
||||||
} else if (regData.errcode === 'M_USER_IN_USE') {
|
} else if (regData.errcode === 'M_USER_IN_USE') {
|
||||||
// Username exists, try to login
|
// Username exists, try to login
|
||||||
@@ -653,6 +664,8 @@ const commands = {
|
|||||||
localStorage.setItem('matrix_username', username);
|
localStorage.setItem('matrix_username', username);
|
||||||
localStorage.setItem('matrix_password', password);
|
localStorage.setItem('matrix_password', password);
|
||||||
|
|
||||||
|
updateClientSession({ accessToken: loginData.access_token, userId: loginData.user_id });
|
||||||
|
|
||||||
term.writeln(` Logged in as: ${loginData.user_id}\r\n`);
|
term.writeln(` Logged in as: ${loginData.user_id}\r\n`);
|
||||||
} else {
|
} else {
|
||||||
return ` Error: Failed to login - ${loginData.error || loginData.errcode || 'Unknown error'}`;
|
return ` Error: Failed to login - ${loginData.error || loginData.errcode || 'Unknown error'}`;
|
||||||
|
|||||||
Reference in new issue
Block a user