Skip to content

Commit

Permalink
Implement socketAdmin
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox committed Feb 7, 2025
1 parent 336e45e commit 2e45ca2
Show file tree
Hide file tree
Showing 13 changed files with 134 additions and 126 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ Unsubscribe from file changes in ioBroker DB
-->
## Changelog
### 2.0.2 (2025-02-07)
### **WORK IN PROGRESS**
* (@GermanBluefox) Code migrated to TypeScript
### 1.6.2 (2024-12-01)
Expand Down
6 changes: 3 additions & 3 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import passport from 'passport';
import cookieParser from 'cookie-parser';
export { SocketCommandsAdmin } from './lib/socketCommandsAdmin';
export { SocketCommands, type SupportedFeature } from './lib/socketCommands';
export { SocketCommon } from './lib/socketCommon';
export { SocketCommon, type Server } from './lib/socketCommon';
export { SocketAdmin } from './lib/socketAdmin';
import { authorize as passportSocket, type PassportHttpRequest } from './lib/passportSocket';
export { passport, cookieParser, passportSocket, type PassportHttpRequest };
import { authorize as passportSocket, type PassportHttpRequest, type Store } from './lib/passportSocket';
export { passport, cookieParser, passportSocket, type PassportHttpRequest, type Store };
2 changes: 1 addition & 1 deletion dist/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 16 additions & 6 deletions dist/lib/passportSocket.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,35 @@ export interface PassportHttpRequest extends IncomingMessage {
sessionID: string;
user: {
logged_in: boolean;
user?: string;
};
}
export interface Store {
get: (key: string, cb: (err: Error, session: Record<string, {
user: {
logged_in: boolean;
get: (sessionId: string, cb: (err: Error, session: {
cookie: {
originalMaxAge: number;
expires: string;
httpOnly: boolean;
path: string;
};
}>) => void) => void;
passport: {
user: string;
};
}) => void) => void;
}
export declare function authorize(options: {
export declare function authorize(auth: {
passport: passport.PassportStatic & {
_key: string;
};
cookieParser: (secret: string | null, options?: {
cookieParser: (secret: string | string[] | undefined, options?: {
decode?(val: string): string;
}) => express.RequestHandler;
checkUser?: (user: string, pass: string, cb: (error: Error | null, result?: {
logged_in: boolean;
}) => void) => void;
fail: (data: PassportHttpRequest, message: string, critical: boolean, accept: (err: boolean) => void) => void;
success: (data: PassportHttpRequest, accept: (err: boolean) => void) => void;
secret?: string;
store?: Store;
userProperty?: string;
}): (req: IncomingMessage, accept: (err: boolean) => void) => void;
44 changes: 25 additions & 19 deletions dist/lib/passportSocket.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/lib/passportSocket.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions dist/lib/socketAdmin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export declare class SocketAdmin extends SocketCommon {
__getIsNoDisconnect(): boolean;
__initAuthentication(authOptions: {
store: Store;
userKey: string;
secret: string;
}): void;
__getUserFromSocket(socket: WebSocketClient, callback: (error: string | null, user?: string) => void): void;
Expand All @@ -38,5 +37,5 @@ export declare class SocketAdmin extends SocketCommon {
subscribe(type: SocketSubscribeTypes, pattern: string): void;
subscribeFile(id: string, patternFile: string): void;
sendCommand(obj: ioBroker.Message): void;
updateRatings(uuid: string, isAutoUpdate?: boolean): Promise<Ratings | null>;
updateRatings(uuid?: string, isAutoUpdate?: boolean): Promise<Ratings | null>;
}
47 changes: 7 additions & 40 deletions dist/lib/socketAdmin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2e45ca2

Please sign in to comment.