mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix: express session
This commit is contained in:
@@ -20,6 +20,7 @@ import {
|
||||
import { LoggerService } from '@/logger/logger.service';
|
||||
import { SettingService } from '@/setting/services/setting.service';
|
||||
import { Extension } from '@/utils/generics/extension';
|
||||
import { HyphenToUnderscore } from '@/utils/types/extension';
|
||||
import { SocketRequest } from '@/websocket/utils/socket-request';
|
||||
import { SocketResponse } from '@/websocket/utils/socket-response';
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
import { SettingCreateDto } from '@/setting/dto/setting.dto';
|
||||
import { HyphenToUnderscore } from '@/utils/types/extension';
|
||||
|
||||
export type ChannelName = `${string}-channel`;
|
||||
|
||||
|
||||
@@ -299,7 +299,7 @@ export default abstract class BaseWebChannelHandler<
|
||||
*/
|
||||
private async verifyToken(verificationToken: string) {
|
||||
const settings =
|
||||
(await this.getSettings()) as Settings[typeof WEB_CHANNEL_NAMESPACE];
|
||||
(await this.getSettings()) as unknown as Settings[typeof WEB_CHANNEL_NAMESPACE];
|
||||
const verifyToken = settings.verification_token;
|
||||
|
||||
if (!verifyToken) {
|
||||
|
||||
36
api/src/index.d.ts → api/src/global.d.ts
vendored
36
api/src/index.d.ts → api/src/global.d.ts
vendored
@@ -6,42 +6,6 @@
|
||||
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
||||
*/
|
||||
|
||||
import 'mongoose';
|
||||
import { SubscriberStub } from './chat/schemas/subscriber.schema';
|
||||
|
||||
declare module 'express-session' {
|
||||
interface SessionUser {
|
||||
id?: string;
|
||||
first_name?: string;
|
||||
last_name?: string;
|
||||
}
|
||||
|
||||
interface SessionData<T extends SubscriberStub> {
|
||||
passport?: {
|
||||
user?: SessionUser;
|
||||
};
|
||||
web?: {
|
||||
profile?: T;
|
||||
isSocket: boolean;
|
||||
messageQueue: any[];
|
||||
polling: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
interface Session {
|
||||
csrfSecret?: string;
|
||||
passport?: {
|
||||
user?: SessionUser;
|
||||
};
|
||||
web?: {
|
||||
profile?: SubscriberStub;
|
||||
isSocket: boolean;
|
||||
messageQueue: any[];
|
||||
polling: boolean;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
declare global {
|
||||
type HyphenToUnderscore<S extends string> = S extends `${infer P}-${infer Q}`
|
||||
? `${P}_${HyphenToUnderscore<Q>}`
|
||||
@@ -12,6 +12,7 @@ import { LoggerService, OnModuleInit } from '@nestjs/common';
|
||||
|
||||
import { SettingService } from '@/setting/services/setting.service';
|
||||
import { Extension } from '@/utils/generics/extension';
|
||||
import { HyphenToUnderscore } from '@/utils/types/extension';
|
||||
|
||||
import { HelperService } from '../helper.service';
|
||||
import { HelperName, HelperSetting, HelperType } from '../types';
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
import { SettingCreateDto } from '@/setting/dto/setting.dto';
|
||||
import { HyphenToUnderscore } from '@/utils/types/extension';
|
||||
|
||||
import BaseHelper from './lib/base-helper';
|
||||
import BaseLlmHelper from './lib/base-llm-helper';
|
||||
|
||||
@@ -13,7 +13,7 @@ import { OnModuleInit } from '@nestjs/common';
|
||||
import { I18nJsonLoader, I18nTranslation } from 'nestjs-i18n';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { ExtensionName } from '../types/extension';
|
||||
import { ExtensionName, HyphenToUnderscore } from '../types/extension';
|
||||
|
||||
export abstract class Extension implements OnModuleInit {
|
||||
private translations: I18nTranslation | Observable<I18nTranslation>;
|
||||
|
||||
@@ -11,3 +11,6 @@ import { HelperName } from '@/helper/types';
|
||||
import { PluginName } from '@/plugins/types';
|
||||
|
||||
export type ExtensionName = ChannelName | HelperName | PluginName;
|
||||
|
||||
export type HyphenToUnderscore<S extends string> =
|
||||
S extends `${infer P}-${infer Q}` ? `${P}_${HyphenToUnderscore<Q>}` : S;
|
||||
|
||||
Reference in New Issue
Block a user