UNPKG

bc-webclient-mcp

Version:

Model Context Protocol (MCP) server for Microsoft Dynamics 365 Business Central via WebUI protocol. Enables AI assistants to interact with BC through the web client protocol, supporting Card, List, and Document pages with full line item support and server

83 lines 2.42 kB
/** * BC Authentication Service * * Handles HTTP login to BC Web Client to obtain session cookies and CSRF token. * * Extracted from BCRawWebSocketClient (lines 108-195). * * Responsibilities: * - HTTP login via web form * - Session cookie management * - CSRF token extraction from Antiforgery cookie * * Usage: * ```ts * const auth = new BCAuthenticationService({ * baseUrl: 'http://localhost/BC', * username: 'admin', * password: 'pass', * tenantId: 'default' * }); * * await auth.authenticateWeb(); * * const cookies = auth.getSessionCookies(); // For WebSocket connection * const csrf = auth.getCsrfToken(); // For RPC requests * ``` */ import type { IBCAuthenticationService } from '../interfaces.js'; import type { BCConfig } from '../../types.js'; /** * Authentication service for BC Web Client login. * * Authenticates via HTTP form submission to get session cookies and CSRF token. * These are then used for WebSocket connection and JSON-RPC requests. */ export declare class BCAuthenticationService implements IBCAuthenticationService { private config; private username; private password; private tenantId; private sessionCookies; private csrfToken; private authenticated; constructor(params: { config: BCConfig; username: string; password: string; tenantId?: string; }); /** * Authenticate via web login to get session cookies and CSRF token. * * Two-step process: * 1. GET /SignIn - Extract CSRF token from login form * 2. POST /SignIn - Submit credentials and get session cookies * * @throws {AuthenticationError} If login fails */ authenticateWeb(): Promise<void>; /** * Get current session cookies. * * Used by WebSocket manager to establish authenticated connection. * * @returns Array of cookie strings in "name=value" format */ getSessionCookies(): string[]; /** * Get CSRF token for WebSocket connection. * * Extracted from .AspNetCore.Antiforgery.* cookie during login. * * @returns CSRF token or null if not available */ getCsrfToken(): string | null; /** * Check if authenticated. * * @returns true if authenticateWeb() completed successfully */ isAuthenticated(): boolean; } //# sourceMappingURL=BCAuthenticationService.d.ts.map