mirror of
https://github.com/samuelthomas2774/nxapi.git
synced 2026-10-20 00:27:40 -05:00
Automatically renew token when znc responds with a token expired error
This commit is contained in:
@@ -10,6 +10,7 @@ import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js';
|
||||
import { initStorage } from '../../util/storage.js';
|
||||
import { getToken, SavedToken } from '../../common/auth/nso.js';
|
||||
import { NotificationManager, ZncNotifications } from '../../common/notify.js';
|
||||
import { AuthPolicy, AuthToken, ZncPresenceEventStreamEvent } from '../../api/znc-proxy.js';
|
||||
|
||||
declare global {
|
||||
namespace Express {
|
||||
@@ -24,26 +25,6 @@ declare global {
|
||||
}
|
||||
}
|
||||
|
||||
export interface AuthToken {
|
||||
user: string;
|
||||
policy?: AuthPolicy;
|
||||
created_at: number;
|
||||
}
|
||||
export interface AuthPolicy {
|
||||
announcements?: boolean;
|
||||
list_friends?: boolean;
|
||||
list_friends_presence?: boolean;
|
||||
friend?: boolean;
|
||||
friend_presence?: boolean;
|
||||
webservices?: boolean;
|
||||
activeevent?: boolean;
|
||||
current_user?: boolean;
|
||||
current_user_presence?: boolean;
|
||||
|
||||
friends?: string[];
|
||||
friends_presence?: string[];
|
||||
}
|
||||
|
||||
const debug = createDebug('cli:nso:http-server');
|
||||
|
||||
export const command = 'http-server';
|
||||
@@ -682,13 +663,6 @@ export async function handler(argv: ArgumentsCamelCase<Arguments>) {
|
||||
}
|
||||
}
|
||||
|
||||
export enum ZncPresenceEventStreamEvent {
|
||||
FRIEND_ONLINE = '0',
|
||||
FRIEND_OFFLINE = '1',
|
||||
FRIEND_TITLE_CHANGE = '2',
|
||||
FRIEND_TITLE_STATECHANGE = '3',
|
||||
}
|
||||
|
||||
class EventStreamNotificationManager extends NotificationManager {
|
||||
constructor(
|
||||
public req: express.Request,
|
||||
|
||||
@@ -3,7 +3,7 @@ import fetch from 'node-fetch';
|
||||
import Table from '../util/table.js';
|
||||
import type { Arguments as ParentArguments } from '../nso.js';
|
||||
import { getToken } from '../../common/auth/nso.js';
|
||||
import { AuthPolicy, AuthToken } from './http-server.js';
|
||||
import { AuthPolicy, AuthToken } from '../../api/znc-proxy.js';
|
||||
import { Argv } from '../../util/yargs.js';
|
||||
import { initStorage } from '../../util/storage.js';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user