UNPKG

@atlas-kitchen/atlas-mcp

Version:

Model Context Protocol server for Atlas restaurant management system - enables Claude to interact with restaurant orders, menus, and reports

78 lines 2.16 kB
import { v4 as uuidv4 } from 'uuid'; export class AuthManager { tokens = null; merchantId = null; outletId = null; brandId = null; clientUuid; pinToken = null; constructor() { // Generate a persistent client UUID for this session this.clientUuid = uuidv4(); } setTokens(tokens) { this.tokens = tokens; } getTokens() { return this.tokens; } getAccessToken() { return this.tokens?.accessToken || null; } setPinToken(pinToken) { this.pinToken = pinToken; } getPinToken() { return this.pinToken; } setMerchantContext(merchantId, outletId, brandId) { this.merchantId = merchantId; this.outletId = outletId || null; this.brandId = brandId || null; } getMerchantId() { return this.merchantId; } getOutletId() { return this.outletId; } getBrandId() { return this.brandId; } getClientUuid() { return this.clientUuid; } getHeaders() { const headers = { 'Content-Type': 'application/json', }; // Add authorization header if (this.tokens?.accessToken) { headers['Authorization'] = `Bearer ${this.tokens.accessToken}`; } // Add merchant context headers if (this.merchantId) { headers['X-Merchant-ID'] = this.merchantId; } if (this.outletId) { headers['X-Outlet-ID'] = this.outletId; } // Add client identification headers (matching restaurant-web format) headers['X-Client-UUID'] = this.clientUuid; headers['X-Client-Name'] = process.env.ATLAS_CLIENT_NAME || 'atlas-mcp-1.0.0'; return headers; } clear() { this.tokens = null; this.merchantId = null; this.outletId = null; this.brandId = null; this.pinToken = null; // Generate new client UUID on clear this.clientUuid = uuidv4(); } isAuthenticated() { return this.tokens !== null && this.tokens.accessToken !== null; } } //# sourceMappingURL=auth.js.map