
- Complete NestJS TypeScript implementation with WebSocket support - Direct messaging (DM) and group chat functionality - End-to-end encryption with AES encryption and key pairs - Media file support (images, videos, audio, documents) up to 100MB - Push notifications with Firebase Cloud Messaging integration - Mention alerts and real-time typing indicators - User authentication with JWT and Passport - SQLite database with TypeORM entities and relationships - Comprehensive API documentation with Swagger/OpenAPI - File upload handling with secure access control - Online/offline status tracking and presence management - Message editing, deletion, and reply functionality - Notification management with automatic cleanup - Health check endpoint for monitoring - CORS configuration for cross-origin requests - Environment-based configuration management - Structured for Flutter SDK integration Features implemented: ✅ Real-time messaging with Socket.IO ✅ User registration and authentication ✅ Direct messages and group chats ✅ Media file uploads and management ✅ End-to-end encryption ✅ Push notifications ✅ Mention alerts ✅ Typing indicators ✅ Message read receipts ✅ Online status tracking ✅ File access control ✅ Comprehensive API documentation Ready for Flutter SDK development and production deployment.
131 lines
3.6 KiB
TypeScript
131 lines
3.6 KiB
TypeScript
import { Agent as HttpAgent } from 'http';
|
|
import { Agent as HttpsAgent } from 'https';
|
|
import type {Jwt, Secret} from 'jsonwebtoken'
|
|
import Express = require('express')
|
|
|
|
declare function JwksRsa(options: JwksRsa.Options): JwksRsa.JwksClient;
|
|
|
|
declare namespace JwksRsa {
|
|
class JwksClient {
|
|
constructor(options: Options);
|
|
|
|
getKeys(): Promise<unknown>;
|
|
getSigningKeys(): Promise<SigningKey[]>;
|
|
getSigningKey(kid?: string | null | undefined): Promise<SigningKey>;
|
|
getSigningKey(kid: string | null | undefined, cb: (err: Error | null, key?: SigningKey) => void): void;
|
|
}
|
|
|
|
interface Headers {
|
|
[key: string]: string;
|
|
}
|
|
|
|
interface Options {
|
|
jwksUri: string;
|
|
rateLimit?: boolean;
|
|
cache?: boolean;
|
|
cacheMaxEntries?: number;
|
|
cacheMaxAge?: number;
|
|
jwksRequestsPerMinute?: number;
|
|
proxy?: string;
|
|
requestHeaders?: Headers;
|
|
timeout?: number;
|
|
requestAgent?: HttpAgent | HttpsAgent;
|
|
fetcher?(jwksUri: string): Promise<{ keys: any }>;
|
|
getKeysInterceptor?(): Promise<JSONWebKey[]>;
|
|
}
|
|
|
|
interface JSONWebKey {
|
|
kid: string,
|
|
alg: string,
|
|
[key: string]: any
|
|
}
|
|
|
|
interface CertSigningKey {
|
|
kid: string;
|
|
alg: string;
|
|
getPublicKey(): string;
|
|
publicKey: string;
|
|
}
|
|
|
|
interface RsaSigningKey {
|
|
kid: string;
|
|
alg: string;
|
|
getPublicKey(): string;
|
|
rsaPublicKey: string;
|
|
}
|
|
|
|
type SigningKey = CertSigningKey | RsaSigningKey;
|
|
|
|
/**
|
|
* Types are duplicated from express-jwt@6/7
|
|
* due to numerous breaking changes in the lib's types
|
|
* whilst this lib supportd both <=6 & >=7 implementations
|
|
*
|
|
* express-jwt's installed version (or its @types)
|
|
* will be the types used at transpilation time
|
|
*/
|
|
|
|
/** Types from express-jwt@<=6 */
|
|
type secretType = string|Buffer;
|
|
type SecretCallbackLong = (req: unknown, header: any, payload: any, done: (err: any, secret?: secretType) => void) => void;
|
|
type SecretCallback = (req: unknown, payload: any, done: (err: any, secret?: secretType) => void) => void;
|
|
|
|
/** Types from express-jwt@>=7 */
|
|
type GetVerificationKey = (req: unknown, token: Jwt | undefined) => Secret | undefined | Promise<Secret | undefined>;
|
|
|
|
function expressJwtSecret(options: ExpressJwtOptions): SecretCallbackLong & GetVerificationKey;
|
|
|
|
function passportJwtSecret(options: ExpressJwtOptions): SecretCallback;
|
|
|
|
interface ExpressJwtOptions extends Options {
|
|
handleSigningKeyError?: (err: Error | null, cb: (err: Error | null) => void) => void;
|
|
}
|
|
|
|
function hapiJwt2Key(options: HapiJwtOptions): (decodedToken: DecodedToken, cb: HapiCallback) => void;
|
|
|
|
interface HapiJwtOptions extends Options {
|
|
handleSigningKeyError?: (err: Error | null, cb: HapiCallback) => void;
|
|
}
|
|
|
|
type HapiCallback = (err: Error | null, publicKey: string, signingKey: SigningKey) => void;
|
|
|
|
interface DecodedToken {
|
|
header: TokenHeader;
|
|
}
|
|
|
|
interface TokenHeader {
|
|
alg: string;
|
|
kid: string;
|
|
}
|
|
|
|
function hapiJwt2KeyAsync(options: HapiJwtOptions): (decodedToken: DecodedToken) => Promise<{ key: string }>;
|
|
|
|
function koaJwtSecret(options: KoaJwtOptions): (header: TokenHeader) => Promise<string>;
|
|
|
|
interface KoaJwtOptions extends Options {
|
|
handleSigningKeyError?(err: Error | null): Promise<void>;
|
|
}
|
|
|
|
class ArgumentError extends Error {
|
|
name: 'ArgumentError';
|
|
constructor(message: string);
|
|
}
|
|
|
|
class JwksError extends Error {
|
|
name: 'JwksError';
|
|
constructor(message: string);
|
|
}
|
|
|
|
class JwksRateLimitError extends Error {
|
|
name: 'JwksRateLimitError';
|
|
constructor(message: string);
|
|
}
|
|
|
|
class SigningKeyNotFoundError extends Error {
|
|
name: 'SigningKeyNotFoundError';
|
|
constructor(message: string);
|
|
}
|
|
}
|
|
|
|
export = JwksRsa;
|