typing(SessionManager): fetch method return cache

This commit is contained in:
Elysia
2025-07-11 23:25:13 +07:00
parent a427baa6d6
commit 9ea355a6e0
2 changed files with 10 additions and 14 deletions

View File

@@ -22,16 +22,12 @@ class SessionManager extends CachedManager {
* @returns {Promise<Collection<string, Session>>} * @returns {Promise<Collection<string, Session>>}
*/ */
fetch() { fetch() {
return this.client.api.auth.sessions return this.client.api.auth.sessions.get().then(data => {
.get()
.then(data => {
const allData = data.user_sessions; const allData = data.user_sessions;
this.cache.clear(); this.cache.clear();
for (const session of allData) { for (const session of allData) {
this._add(session, true, { id: session.id_hash }); this._add(session, true, { id: session.id_hash });
} }
return this.cache; return this.cache;
}); });
} }

4
typings/index.d.ts vendored
View File

@@ -72,7 +72,7 @@ import { AgentOptions } from 'node:https';
import { Response, ProxyAgent } from 'undici'; import { Response, ProxyAgent } from 'undici';
import { Readable, Writable, Stream } from 'node:stream'; import { Readable, Writable, Stream } from 'node:stream';
import { MessagePort, Worker } from 'node:worker_threads'; import { MessagePort, Worker } from 'node:worker_threads';
import { authenticator } from "otplib"; import { authenticator } from 'otplib';
import { CookieJar } from 'tough-cookie'; import { CookieJar } from 'tough-cookie';
import { RtpPacket } from 'werift-rtp'; import { RtpPacket } from 'werift-rtp';
import * as WebSocket from 'ws'; import * as WebSocket from 'ws';
@@ -2557,7 +2557,7 @@ export class WebEmbed {
export class SessionManager extends CachedManager<string, Session, any> { export class SessionManager extends CachedManager<string, Session, any> {
private constructor(client: Client, iterable: Iterable<any>); private constructor(client: Client, iterable: Iterable<any>);
public fetch(): Promise<this>; public fetch(): Promise<Collection<string, Session>>;
public logoutAllDevices(): Promise<void>; public logoutAllDevices(): Promise<void>;
} }