'use strict'; // The chat view's page: a fixed skeleton with a strict Content-Security-Policy. Nothing a model // or a server writes is ever part of this text; it reaches the page as messages and is drawn // with `textContent`. No `vscode` here. /** * @param {{ cspSource: string, nonce: string, scriptUri: string, styleUri: string, logoUri?: string }} o */ function chatHtml(o) { // VS Code / VSCodium's `webview.cspSource` may list multiple space-separated origins // (e.g. "vscode-resource: https://*.vscode-cdn.net"); forbid quotes, angle brackets, semicolons and newlines. if (typeof o.cspSource !== 'string' || !o.cspSource.trim() || /["<>;\r\n]/.test(o.cspSource)) { throw new Error('unsafe cspSource for the chat page'); } const uris = [o.nonce, o.scriptUri, o.styleUri]; if (o.logoUri !== undefined && o.logoUri !== '') uris.push(o.logoUri); for (const v of uris) { if (typeof v !== 'string' || !v || /["<>\s]/.test(v)) throw new Error('unsafe value for the chat page'); } const csp = [ "default-src 'none'", `img-src ${o.cspSource}`, `style-src ${o.cspSource}`, `script-src 'nonce-${o.nonce}'`, "base-uri 'none'", "form-action 'none'", ].join('; '); const brandImg = o.logoUri ? `` : ''; const heroImg = o.logoUri ? `` : ''; return ` LLeMbas
${brandImg} LLeMbas
${heroImg}
LLeMbas
Waybread for the code ahead.
@file /command Alt+\ complete
`; } module.exports = { chatHtml };