azurajs-scalar 2.1.2 → 2.1.3-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -30,109 +30,112 @@ function proxyMiddleware({
30
30
  apiSpecUrl,
31
31
  proxyUrlPath
32
32
  });
33
- return app.get(proxyUrlPath, async (req, res) => {
34
- debug("=== PROXY HIT ===");
35
- debug("Method:", req.method);
36
- debug("URL:", req.url);
37
- debug("Headers:", req.headers);
38
- try {
39
- if (!req.url || !req.method) {
40
- return res.status(400).json({ error: "Invalid request" });
41
- }
42
- logger("info", `[PROXY] ${req.method} ${req.url}`);
43
- const query = new URLSearchParams(req.url.split("?")[1] || "");
44
- const scalarUrl = query.get("scalar_url");
45
- const targetUrl = scalarUrl || apiSpecUrl;
46
- debug("Target URL:", targetUrl);
47
- const target = new URL(targetUrl);
48
- const apiBase = new URL(apiSpecUrl);
49
- const baseOrigin = new URL(baseUrl).origin;
50
- const allowed = target.origin === apiBase.origin || target.origin === baseOrigin;
51
- debug("Origin check:", {
52
- target: target.origin,
53
- apiSpec: apiBase.origin,
54
- base: baseOrigin,
55
- allowed
56
- });
57
- if (!allowed) {
58
- logger("warn", `[PROXY] Blocked cross-origin: ${targetUrl}`);
59
- return res.status(403).json({ error: "Cross-origin blocked" });
60
- }
61
- const headers = {};
62
- for (const [k, v] of Object.entries(req.headers)) {
63
- if (!v) continue;
64
- headers[k] = Array.isArray(v) ? v.join(", ") : v;
65
- }
66
- headers.host = apiBase.host;
67
- debug("Forward headers:", headers);
68
- const body = ["GET", "HEAD"].includes(req.method) ? void 0 : typeof req.body === "string" ? req.body : JSON.stringify(req.body);
69
- debug("Forward body type:", typeof body);
70
- debug("Forward body length:", body?.length ?? 0);
71
- const proxyRes = await fetch(targetUrl, {
72
- method: req.method,
73
- headers,
74
- body
75
- });
76
- debug("=== FETCH RESPONSE ===");
77
- debug("Status:", proxyRes.status);
78
- debug("StatusText:", proxyRes.statusText);
79
- debug("URL:", proxyRes.url);
80
- const headersObj = {};
81
- for (const [k, v] of proxyRes.headers.entries()) {
82
- headersObj[k] = v;
83
- }
84
- debug("Response headers:", headersObj);
85
- debug("content-type:", proxyRes.headers.get("content-type"));
86
- debug("content-encoding:", proxyRes.headers.get("content-encoding"));
87
- debug("transfer-encoding:", proxyRes.headers.get("transfer-encoding"));
88
- debug("content-length:", proxyRes.headers.get("content-length"));
89
- res.setHeader("Access-Control-Allow-Origin", "*");
90
- res.setHeader(
91
- "Access-Control-Allow-Methods",
92
- "GET,POST,PUT,PATCH,DELETE,OPTIONS,HEAD"
93
- );
94
- res.setHeader("Access-Control-Allow-Headers", "*");
95
- res.setHeader("Access-Control-Expose-Headers", "*");
96
- for (const [key, value] of proxyRes.headers.entries()) {
97
- const k = key.toLowerCase();
98
- if (k === "content-encoding") continue;
99
- if (k === "content-length") continue;
100
- if ([
101
- "connection",
102
- "keep-alive",
103
- "transfer-encoding",
104
- "te",
105
- "trailer",
106
- "upgrade",
107
- "host"
108
- ].includes(k))
109
- continue;
110
- res.setHeader(key, value);
111
- }
112
- if (req.method === "OPTIONS") {
113
- debug("OPTIONS request -> end");
114
- return res.end();
33
+ return app.use(
34
+ proxyUrlPath,
35
+ async (req, res) => {
36
+ debug("=== PROXY HIT ===");
37
+ debug("Method:", req.method);
38
+ debug("URL:", req.url);
39
+ debug("Headers:", req.headers);
40
+ try {
41
+ if (!req.url || !req.method) {
42
+ return res.status(400).json({ error: "Invalid request" });
43
+ }
44
+ logger("info", `[PROXY] ${req.method} ${req.url}`);
45
+ const query = new URLSearchParams(req.url.split("?")[1] || "");
46
+ const scalarUrl = query.get("scalar_url");
47
+ const targetUrl = scalarUrl || apiSpecUrl;
48
+ debug("Target URL:", targetUrl);
49
+ const target = new URL(targetUrl);
50
+ const apiBase = new URL(apiSpecUrl);
51
+ const baseOrigin = new URL(baseUrl).origin;
52
+ const allowed = target.origin === apiBase.origin || target.origin === baseOrigin;
53
+ debug("Origin check:", {
54
+ target: target.origin,
55
+ apiSpec: apiBase.origin,
56
+ base: baseOrigin,
57
+ allowed
58
+ });
59
+ if (!allowed) {
60
+ logger("warn", `[PROXY] Blocked cross-origin: ${targetUrl}`);
61
+ return res.status(403).json({ error: "Cross-origin blocked" });
62
+ }
63
+ const headers = {};
64
+ for (const [k, v] of Object.entries(req.headers)) {
65
+ if (!v) continue;
66
+ headers[k] = Array.isArray(v) ? v.join(", ") : v;
67
+ }
68
+ headers.host = apiBase.host;
69
+ debug("Forward headers:", headers);
70
+ const body = ["GET", "HEAD"].includes(req.method) ? void 0 : typeof req.body === "string" ? req.body : JSON.stringify(req.body);
71
+ debug("Forward body type:", typeof body);
72
+ debug("Forward body length:", body?.length ?? 0);
73
+ const proxyRes = await fetch(targetUrl, {
74
+ method: req.method,
75
+ headers,
76
+ body
77
+ });
78
+ debug("=== FETCH RESPONSE ===");
79
+ debug("Status:", proxyRes.status);
80
+ debug("StatusText:", proxyRes.statusText);
81
+ debug("URL:", proxyRes.url);
82
+ const headersObj = {};
83
+ for (const [k, v] of proxyRes.headers.entries()) {
84
+ headersObj[k] = v;
85
+ }
86
+ debug("Response headers:", headersObj);
87
+ debug("content-type:", proxyRes.headers.get("content-type"));
88
+ debug("content-encoding:", proxyRes.headers.get("content-encoding"));
89
+ debug("transfer-encoding:", proxyRes.headers.get("transfer-encoding"));
90
+ debug("content-length:", proxyRes.headers.get("content-length"));
91
+ res.setHeader("Access-Control-Allow-Origin", "*");
92
+ res.setHeader(
93
+ "Access-Control-Allow-Methods",
94
+ "GET,POST,PUT,PATCH,DELETE,OPTIONS,HEAD"
95
+ );
96
+ res.setHeader("Access-Control-Allow-Headers", "*");
97
+ res.setHeader("Access-Control-Expose-Headers", "*");
98
+ for (const [key, value] of proxyRes.headers.entries()) {
99
+ const k = key.toLowerCase();
100
+ if (k === "content-encoding") continue;
101
+ if (k === "content-length") continue;
102
+ if ([
103
+ "connection",
104
+ "keep-alive",
105
+ "transfer-encoding",
106
+ "te",
107
+ "trailer",
108
+ "upgrade",
109
+ "host"
110
+ ].includes(k))
111
+ continue;
112
+ res.setHeader(key, value);
113
+ }
114
+ if (req.method === "OPTIONS") {
115
+ debug("OPTIONS request -> end");
116
+ return res.end();
117
+ }
118
+ const arrayBuf = await proxyRes.arrayBuffer();
119
+ const buffer = Buffer.from(arrayBuf);
120
+ debug("=== BODY DEBUG ===");
121
+ debug("ArrayBuffer byteLength:", arrayBuf.byteLength);
122
+ debug("Buffer length:", buffer.length);
123
+ debug("Buffer empty:", buffer.length === 0);
124
+ debug("First 50 bytes (hex):", buffer.subarray(0, 50).toString("hex"));
125
+ debug(
126
+ "First 200 chars (utf8):",
127
+ buffer.subarray(0, 200).toString("utf8")
128
+ );
129
+ debug("=== END BODY DEBUG ===");
130
+ res.status(proxyRes.status).send(buffer);
131
+ } catch (err) {
132
+ debug("=== PROXY ERROR ===");
133
+ debug("Ocorreu um erro no proxy...", err);
134
+ logger("error", `[PROXY] Error: ${err}`);
135
+ res.status(500).json({ error: "Proxy error" });
115
136
  }
116
- const arrayBuf = await proxyRes.arrayBuffer();
117
- const buffer = Buffer.from(arrayBuf);
118
- debug("=== BODY DEBUG ===");
119
- debug("ArrayBuffer byteLength:", arrayBuf.byteLength);
120
- debug("Buffer length:", buffer.length);
121
- debug("Buffer empty:", buffer.length === 0);
122
- debug("First 50 bytes (hex):", buffer.subarray(0, 50).toString("hex"));
123
- debug(
124
- "First 200 chars (utf8):",
125
- buffer.subarray(0, 200).toString("utf8")
126
- );
127
- debug("=== END BODY DEBUG ===");
128
- res.status(proxyRes.status).send(buffer);
129
- } catch (err) {
130
- debug("=== PROXY ERROR ===");
131
- debug("Ocorreu um erro no proxy...", err);
132
- logger("error", `[PROXY] Error: ${err}`);
133
- res.status(500).json({ error: "Proxy error" });
134
137
  }
135
- });
138
+ );
136
139
  }
137
140
 
138
141
  // src/setupDocsRoute.ts
@@ -262,7 +265,7 @@ var Scalar = class {
262
265
  "apiSpecPath:",
263
266
  apiSpecPath
264
267
  );
265
- const proxyUrl = this.joinUrl(normalizedConfig.baseUrl, proxyPath);
268
+ const proxyUrl = normalizedConfig.proxyPath ? this.joinUrl(normalizedConfig.baseUrl, normalizedConfig.proxyPath) : "https://proxy.scalar.com";
266
269
  const docUrl = this.joinUrl(normalizedConfig.baseUrl, docPath);
267
270
  const apiSpecUrl = this.joinUrl(normalizedConfig.baseUrl, apiSpecPath);
268
271
  debug(
@@ -284,13 +287,15 @@ var Scalar = class {
284
287
  apiSpecUrl
285
288
  });
286
289
  debug("setupScalarDocs called");
287
- proxyMiddleware({
288
- apiSpecUrl,
289
- proxyUrlPath: proxyPath,
290
- app: normalizedConfig.app,
291
- baseUrl: normalizedConfig.baseUrl
292
- });
293
- debug("proxyMiddleware called");
290
+ if (normalizedConfig.proxyPath) {
291
+ proxyMiddleware({
292
+ apiSpecUrl,
293
+ proxyUrlPath: normalizedConfig.proxyPath,
294
+ app: normalizedConfig.app,
295
+ baseUrl: normalizedConfig.baseUrl
296
+ });
297
+ debug("proxyMiddleware called");
298
+ }
294
299
  }
295
300
  joinUrl(baseUrl, path2) {
296
301
  const normalizedBaseUrl = baseUrl.endsWith("/") ? baseUrl : baseUrl + "/";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/config/types.ts","../src/middleware/proxy.ts","../src/utils/debug.ts","../src/setupDocsRoute.ts","../src/utils/store.ts","../src/client.ts"],"sourcesContent":["import { AzuraClient } from \"azurajs\";\nimport { NextFunction, RequestServer, ResponseServer } from \"azurajs/types\";\n\nexport interface ScalarConfigType {\n baseUrl: string;\n proxyPath?: string;\n docPath?: string;\n apiSpecPath?: string;\n customHtmlPath?: string;\n app: AzuraClient;\n}\n\nexport interface ScalarStoreType {\n proxy_url?: string;\n api_spec_url?: string;\n doc_url?: string;\n custom_html_path?: string;\n}\n\nexport type ProxyMiddlewareType = (\n req: RequestServer,\n res: ResponseServer,\n next?: NextFunction,\n) => Promise<void>;\n\nexport class ScalarError extends Error {\n constructor(\n public readonly message: string,\n public readonly code: string,\n public readonly statusCode: number,\n ) {\n super(message);\n Object.setPrototypeOf(this, ScalarError.prototype);\n }\n}\n\nexport interface ProxyOptions {\n apiSpecUrl: string;\n proxyUrlPath: string;\n app: AzuraClient;\n baseUrl: string;\n}\n\nexport interface SetupDocsRouteOptions extends ScalarConfigType {\n docPath: string;\n proxyUrl: string;\n apiSpecUrl: string;\n}\n","import { ProxyOptions } from \"../config/types\";\nimport { logger } from \"azurajs/logger\";\nimport { debug } from \"../utils/debug\";\n\nexport function proxyMiddleware({\n apiSpecUrl,\n app,\n baseUrl,\n proxyUrlPath,\n}: ProxyOptions) {\n debug(\"Setting up proxy middleware:\", {\n apiSpecUrl,\n proxyUrlPath,\n });\n return app.get(proxyUrlPath, async (req, res) => {\n debug(\"=== PROXY HIT ===\");\n debug(\"Method:\", req.method);\n debug(\"URL:\", req.url);\n debug(\"Headers:\", req.headers);\n\n try {\n if (!req.url || !req.method) {\n return res.status(400).json({ error: \"Invalid request\" });\n }\n\n logger(\"info\", `[PROXY] ${req.method} ${req.url}`);\n\n /* =========================\n TARGET URL\n ========================= */\n const query = new URLSearchParams(req.url.split(\"?\")[1] || \"\");\n const scalarUrl = query.get(\"scalar_url\");\n const targetUrl = scalarUrl || apiSpecUrl;\n\n debug(\"Target URL:\", targetUrl);\n\n /* =========================\n SAME-ORIGIN\n ========================= */\n const target = new URL(targetUrl);\n const apiBase = new URL(apiSpecUrl);\n const baseOrigin = new URL(baseUrl).origin;\n\n const allowed =\n target.origin === apiBase.origin || target.origin === baseOrigin;\n\n debug(\"Origin check:\", {\n target: target.origin,\n apiSpec: apiBase.origin,\n base: baseOrigin,\n allowed,\n });\n\n if (!allowed) {\n logger(\"warn\", `[PROXY] Blocked cross-origin: ${targetUrl}`);\n return res.status(403).json({ error: \"Cross-origin blocked\" });\n }\n\n /* =========================\n HEADERS\n ========================= */\n const headers: Record<string, string> = {};\n\n for (const [k, v] of Object.entries(req.headers)) {\n if (!v) continue;\n headers[k] = Array.isArray(v) ? v.join(\", \") : v;\n }\n\n headers.host = apiBase.host;\n\n debug(\"Forward headers:\", headers);\n\n /* =========================\n BODY\n ========================= */\n const body = [\"GET\", \"HEAD\"].includes(req.method)\n ? undefined\n : typeof req.body === \"string\"\n ? req.body\n : JSON.stringify(req.body);\n\n debug(\"Forward body type:\", typeof body);\n debug(\"Forward body length:\", body?.length ?? 0);\n\n /* =========================\n FETCH\n ========================= */\n const proxyRes = await fetch(targetUrl, {\n method: req.method,\n headers,\n body,\n });\n\n debug(\"=== FETCH RESPONSE ===\");\n debug(\"Status:\", proxyRes.status);\n debug(\"StatusText:\", proxyRes.statusText);\n debug(\"URL:\", proxyRes.url);\n\n const headersObj: Record<string, string> = {};\n for (const [k, v] of proxyRes.headers.entries()) {\n headersObj[k] = v;\n }\n debug(\"Response headers:\", headersObj);\n\n debug(\"content-type:\", proxyRes.headers.get(\"content-type\"));\n debug(\"content-encoding:\", proxyRes.headers.get(\"content-encoding\"));\n debug(\"transfer-encoding:\", proxyRes.headers.get(\"transfer-encoding\"));\n debug(\"content-length:\", proxyRes.headers.get(\"content-length\"));\n\n /* =========================\n CORS\n ========================= */\n res.setHeader(\"Access-Control-Allow-Origin\", \"*\");\n res.setHeader(\n \"Access-Control-Allow-Methods\",\n \"GET,POST,PUT,PATCH,DELETE,OPTIONS,HEAD\",\n );\n res.setHeader(\"Access-Control-Allow-Headers\", \"*\");\n res.setHeader(\"Access-Control-Expose-Headers\", \"*\");\n\n /* =========================\n SAFE HEADERS PASS\n ========================= */\n for (const [key, value] of proxyRes.headers.entries()) {\n const k = key.toLowerCase();\n\n // quebram proxy quando body já vem decodado\n if (k === \"content-encoding\") continue;\n if (k === \"content-length\") continue;\n\n // headers de conexão\n if (\n [\n \"connection\",\n \"keep-alive\",\n \"transfer-encoding\",\n \"te\",\n \"trailer\",\n \"upgrade\",\n \"host\",\n ].includes(k)\n )\n continue;\n\n res.setHeader(key, value);\n }\n\n if (req.method === \"OPTIONS\") {\n debug(\"OPTIONS request -> end\");\n return res.end();\n }\n\n /* =========================\n DEBUG SEVERO BODY\n ========================= */\n const arrayBuf = await proxyRes.arrayBuffer();\n const buffer = Buffer.from(arrayBuf);\n\n debug(\"=== BODY DEBUG ===\");\n debug(\"ArrayBuffer byteLength:\", arrayBuf.byteLength);\n debug(\"Buffer length:\", buffer.length);\n debug(\"Buffer empty:\", buffer.length === 0);\n debug(\"First 50 bytes (hex):\", buffer.subarray(0, 50).toString(\"hex\"));\n debug(\n \"First 200 chars (utf8):\",\n buffer.subarray(0, 200).toString(\"utf8\"),\n );\n debug(\"=== END BODY DEBUG ===\");\n\n /* =========================\n SEND\n ========================= */\n res.status(proxyRes.status).send(buffer);\n } catch (err) {\n debug(\"=== PROXY ERROR ===\");\n debug(\"Ocorreu um erro no proxy...\", err);\n logger(\"error\", `[PROXY] Error: ${err}`);\n res.status(500).json({ error: \"Proxy error\" });\n }\n });\n}\n","/**\n * Debug utility function that only logs when DEBUG environment variable is set to 'true'\n */\n\nexport function debug(message: string, ...optionalParams: any[]) {\n if (process.env.DEBUG === 'true' || process.env.DEBUG === '1') {\n console.log(`[DEBUG] ${message}`, ...optionalParams);\n }\n}","import { logger } from \"azurajs/logger\";\nimport fs from \"fs\";\nimport path from \"node:path\";\nimport { ScalarError, SetupDocsRouteOptions } from \"./config/types\";\nimport { debug } from \"./utils/debug\";\n\nexport async function setupScalarDocs({\n app,\n docPath,\n customHtmlPath,\n apiSpecUrl,\n proxyUrl,\n}: SetupDocsRouteOptions) {\n debug(\"Setting up docs route with options:\", { docPath, customHtmlPath, apiSpecUrl, proxyUrl });\n\n return app.get(docPath, (req, res) => {\n debug(\"Docs route hit with request:\", req.method, req.url);\n try {\n if (!proxyUrl || !apiSpecUrl) {\n debug(\"Missing required URLs - proxyUrl:\", proxyUrl, \"apiSpecUrl:\", apiSpecUrl);\n throw new ScalarError(\n \"Missing required URLs\",\n \"STORE_VALUES_MISSING\",\n 500,\n );\n }\n\n const htmlPath =\n customHtmlPath || path.join(__dirname, \"../api-docs.html\");\n debug(\"HTML template path:\", htmlPath);\n\n if (!fs.existsSync(htmlPath)) {\n debug(\"HTML template not found at path:\", htmlPath);\n throw new ScalarError(\n \"HTML template not found\",\n \"HTML_TEMPLATE_NOT_FOUND\",\n 404,\n );\n }\n\n const html = fs.readFileSync(htmlPath, \"utf-8\");\n debug(\"HTML template read successfully, length:\", html.length);\n\n const processedHtml = html\n .replace(/&{proxy_url}/g, proxyUrl)\n .replace(/&{api_spec_url}/g, apiSpecUrl);\n debug(\"HTML template processed with proxyUrl and apiSpecUrl\");\n\n return res.send(processedHtml);\n } catch (error) {\n debug(\"Error in docs route:\", error);\n if (error instanceof ScalarError) {\n logger(\"error\", `[ScalarError] ${error.message}`);\n return res.status(error.statusCode).json({ message: error.message });\n } else {\n logger(\"error\", String(error));\n return res.status(500).json({ message: \"Server error\" });\n }\n }\n });\n}\n","/**\n * @fileoverview Store utility for managing application state\n * This module provides a typed store for managing scalar configuration values\n */\n\nimport { ScalarStoreType } from \"../config/types\";\n\n/**\n * Typed store class for managing scalar configuration values\n */\nclass ScalarStore {\n private store: Map<keyof ScalarStoreType, string | undefined> = new Map();\n\n /**\n * Sets a value in the store\n * @param key The key to set\n * @param value The value to set (if undefined, the key will be removed)\n */\n set<K extends keyof ScalarStoreType>(\n key: K,\n value: ScalarStoreType[K],\n ): void {\n this.store.set(key, value as string | undefined);\n }\n\n /**\n * Gets a value from the store\n * @param key The key to get\n * @returns The value associated with the key\n */\n get<K extends keyof ScalarStoreType>(key: K): ScalarStoreType[K] {\n return this.store.get(key) as ScalarStoreType[K];\n }\n\n /**\n * Checks if a key exists in the store\n * @param key The key to check\n * @returns True if the key exists, false otherwise\n */\n has(key: keyof ScalarStoreType): boolean {\n return this.store.has(key);\n }\n\n /**\n * Deletes a key from the store\n * @param key The key to delete\n * @returns True if the key existed and was deleted, false otherwise\n */\n delete(key: keyof ScalarStoreType): boolean {\n return this.store.delete(key);\n }\n\n /**\n * Clears all values from the store\n */\n clear(): void {\n this.store.clear();\n }\n\n /**\n * Gets all values from the store\n * @returns An object containing all key-value pairs in the store\n */\n getAll(): ScalarStoreType {\n const result: Partial<ScalarStoreType> = {};\n for (const [key, value] of this.store.entries()) {\n result[key] = value as ScalarStoreType[keyof ScalarStoreType];\n }\n return result as ScalarStoreType;\n }\n\n // Index signature to allow direct property access\n [key: string]: any;\n}\n\nexport const store = new ScalarStore();\n","/**\n * Scalar client for API documentation\n */\nimport {\n ScalarConfigType,\n ScalarError,\n SetupDocsRouteOptions,\n} from \"./config/types\";\nimport { proxyMiddleware } from \"./middleware/proxy\";\nimport { setupScalarDocs } from \"./setupDocsRoute\";\nimport { store } from \"./utils/store\";\nimport { debug } from \"./utils/debug\";\n\nexport class Scalar {\n constructor(config: ScalarConfigType) {\n debug(\"Scalar constructor called with config:\", config);\n\n // Normalize baseUrl to ensure it's a valid absolute URL before validation\n const normalizedConfig = { ...config };\n normalizedConfig.baseUrl = this.normalizeBaseUrl(config.baseUrl);\n debug(\"Normalized config:\", normalizedConfig);\n\n // Validate the configuration\n this.validateConfig(normalizedConfig);\n\n // Set default paths if not provided\n const proxyPath = normalizedConfig.proxyPath || \"/scalar/proxy\";\n const docPath = normalizedConfig.docPath || \"/docs\";\n const apiSpecPath = normalizedConfig.apiSpecPath || \"\";\n debug(\n \"Using paths - proxyPath:\",\n proxyPath,\n \"docPath:\",\n docPath,\n \"apiSpecPath:\",\n apiSpecPath,\n );\n\n // Calculate full URLs from baseUrl and paths\n const proxyUrl = this.joinUrl(normalizedConfig.baseUrl, proxyPath);\n const docUrl = this.joinUrl(normalizedConfig.baseUrl, docPath);\n const apiSpecUrl = this.joinUrl(normalizedConfig.baseUrl, apiSpecPath);\n debug(\n \"Calculated URLs - proxyUrl:\",\n proxyUrl,\n \"docUrl:\",\n docUrl,\n \"apiSpecUrl:\",\n apiSpecUrl,\n );\n\n // Store the calculated URLs\n store.set(\"proxy_url\", proxyUrl);\n store.set(\"api_spec_url\", apiSpecUrl);\n store.set(\"doc_url\", docUrl);\n debug(\"Stored URLs in store\");\n\n // Call setup with the calculated URLs\n setupScalarDocs({\n ...normalizedConfig,\n proxyUrl,\n docPath,\n apiSpecUrl,\n });\n debug(\"setupScalarDocs called\");\n\n // Setup proxy middleware\n proxyMiddleware({\n apiSpecUrl,\n proxyUrlPath: proxyPath,\n app: normalizedConfig.app,\n baseUrl: normalizedConfig.baseUrl,\n });\n debug(\"proxyMiddleware called\");\n }\n\n private joinUrl(baseUrl: string, path: string): string {\n // Normalize the baseUrl to ensure it ends with a slash\n const normalizedBaseUrl = baseUrl.endsWith(\"/\") ? baseUrl : baseUrl + \"/\";\n\n // Normalize the path to ensure it starts with a slash\n const normalizedPath = path.startsWith(\"/\") ? path : \"/\" + path;\n\n // Join the baseUrl and path, removing any double slashes\n return normalizedBaseUrl.replace(/\\/$/, \"\") + normalizedPath;\n }\n\n private normalizeBaseUrl(baseUrl: string): string {\n if (!baseUrl) {\n throw new ScalarError(\n \"baseUrl is required\",\n \"MISSING_REQUIRED_CONFIG\",\n 400,\n );\n }\n\n // If baseUrl doesn't start with a protocol, prepend http://\n if (!/^https?:\\/\\//i.test(baseUrl)) {\n return \"http://\" + baseUrl;\n }\n\n return baseUrl;\n }\n\n private validateConfig(config: ScalarConfigType): void {\n if (!config.baseUrl) {\n throw new ScalarError(\n \"baseUrl is required\",\n \"MISSING_REQUIRED_CONFIG\",\n 400,\n );\n }\n\n try {\n // Validate baseUrl\n debug(\"Validating baseUrl:\", config.baseUrl);\n new URL(config.baseUrl);\n\n // Validate paths if provided\n if (config.proxyPath) {\n debug(\"Validating proxyPath:\", config.proxyPath);\n if (!this.isValidPath(config.proxyPath)) {\n debug(\"proxyPath validation FAILED\");\n throw new Error(\"Invalid proxyPath\");\n }\n }\n\n if (config.docPath) {\n debug(\"Validating docPath:\", config.docPath);\n if (!this.isValidPath(config.docPath)) {\n debug(\"docPath validation FAILED\");\n throw new Error(\"Invalid docPath\");\n }\n }\n\n if (config.apiSpecPath) {\n debug(\"Validating apiSpecPath:\", config.apiSpecPath);\n if (!this.isValidPath(config.apiSpecPath)) {\n debug(\"apiSpecPath validation FAILED\");\n throw new Error(\"Invalid apiSpecPath\");\n }\n }\n } catch (error) {\n debug(\"Validation error:\", error);\n throw new ScalarError(\"Invalid URL provided\", \"INVALID_URL\", 400);\n }\n }\n\n private isValidPath(path: string): boolean {\n // Aceita paths relativos com barras no meio e no final\n return (\n typeof path === \"string\" &&\n /^\\/[a-zA-Z0-9\\-._~:\\/@!$&'()*+,;=]*\\/?$/.test(path)\n );\n }\n}\n"],"mappings":";AAyBO,IAAM,cAAN,MAAM,qBAAoB,MAAM;AAAA,EACrC,YACkB,SACA,MACA,YAChB;AACA,UAAM,OAAO;AAJG;AACA;AACA;AAGhB,WAAO,eAAe,MAAM,aAAY,SAAS;AAAA,EACnD;AACF;;;ACjCA,SAAS,cAAc;;;ACGhB,SAAS,MAAM,YAAoB,gBAAuB;AAC/D,MAAI,QAAQ,IAAI,UAAU,UAAU,QAAQ,IAAI,UAAU,KAAK;AAC7D,YAAQ,IAAI,WAAW,OAAO,IAAI,GAAG,cAAc;AAAA,EACrD;AACF;;;ADJO,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAiB;AACf,QAAM,gCAAgC;AAAA,IACpC;AAAA,IACA;AAAA,EACF,CAAC;AACD,SAAO,IAAI,IAAI,cAAc,OAAO,KAAK,QAAQ;AAC/C,UAAM,mBAAmB;AACzB,UAAM,WAAW,IAAI,MAAM;AAC3B,UAAM,QAAQ,IAAI,GAAG;AACrB,UAAM,YAAY,IAAI,OAAO;AAE7B,QAAI;AACF,UAAI,CAAC,IAAI,OAAO,CAAC,IAAI,QAAQ;AAC3B,eAAO,IAAI,OAAO,GAAG,EAAE,KAAK,EAAE,OAAO,kBAAkB,CAAC;AAAA,MAC1D;AAEA,aAAO,QAAQ,WAAW,IAAI,MAAM,IAAI,IAAI,GAAG,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proxy.ts","../src/utils/debug.ts","../src/setupDocsRoute.ts","../src/utils/store.ts","../src/client.ts"],"sourcesContent":["import { AzuraClient } from \"azurajs\";\nimport { NextFunction, RequestServer, ResponseServer } from \"azurajs/types\";\n\nexport interface ScalarConfigType {\n baseUrl: string;\n proxyPath?: string;\n docPath?: string;\n apiSpecPath?: string;\n customHtmlPath?: string;\n app: AzuraClient;\n}\n\nexport interface ScalarStoreType {\n proxy_url?: string;\n api_spec_url?: string;\n doc_url?: string;\n custom_html_path?: string;\n}\n\nexport type ProxyMiddlewareType = (\n req: RequestServer,\n res: ResponseServer,\n next?: NextFunction,\n) => Promise<void>;\n\nexport class ScalarError extends Error {\n constructor(\n public readonly message: string,\n public readonly code: string,\n public readonly statusCode: number,\n ) {\n super(message);\n Object.setPrototypeOf(this, ScalarError.prototype);\n }\n}\n\nexport interface ProxyOptions {\n apiSpecUrl: string;\n proxyUrlPath: string;\n app: AzuraClient;\n baseUrl: string;\n}\n\nexport interface SetupDocsRouteOptions extends ScalarConfigType {\n docPath: string;\n proxyUrl: string;\n apiSpecUrl: string;\n}\n","import { ProxyOptions } from \"../config/types\";\nimport { logger } from \"azurajs/logger\";\nimport { debug } from \"../utils/debug\";\nimport { RequestServer, ResponseServer } from \"azurajs/types\";\n\nexport function proxyMiddleware({\n apiSpecUrl,\n app,\n baseUrl,\n proxyUrlPath,\n}: ProxyOptions) {\n debug(\"Setting up proxy middleware:\", {\n apiSpecUrl,\n proxyUrlPath,\n });\n return app.use(\n proxyUrlPath,\n async (req: RequestServer, res: ResponseServer) => {\n debug(\"=== PROXY HIT ===\");\n debug(\"Method:\", req.method);\n debug(\"URL:\", req.url);\n debug(\"Headers:\", req.headers);\n\n try {\n if (!req.url || !req.method) {\n return res.status(400).json({ error: \"Invalid request\" });\n }\n\n logger(\"info\", `[PROXY] ${req.method} ${req.url}`);\n\n /* =========================\n TARGET URL\n ========================= */\n const query = new URLSearchParams(req.url.split(\"?\")[1] || \"\");\n const scalarUrl = query.get(\"scalar_url\");\n const targetUrl = scalarUrl || apiSpecUrl;\n\n debug(\"Target URL:\", targetUrl);\n\n /* =========================\n SAME-ORIGIN\n ========================= */\n const target = new URL(targetUrl);\n const apiBase = new URL(apiSpecUrl);\n const baseOrigin = new URL(baseUrl).origin;\n\n const allowed =\n target.origin === apiBase.origin || target.origin === baseOrigin;\n\n debug(\"Origin check:\", {\n target: target.origin,\n apiSpec: apiBase.origin,\n base: baseOrigin,\n allowed,\n });\n\n if (!allowed) {\n logger(\"warn\", `[PROXY] Blocked cross-origin: ${targetUrl}`);\n return res.status(403).json({ error: \"Cross-origin blocked\" });\n }\n\n /* =========================\n HEADERS\n ========================= */\n const headers: Record<string, string> = {};\n\n for (const [k, v] of Object.entries(req.headers)) {\n if (!v) continue;\n headers[k] = Array.isArray(v) ? v.join(\", \") : v;\n }\n\n headers.host = apiBase.host;\n\n debug(\"Forward headers:\", headers);\n\n /* =========================\n BODY\n ========================= */\n const body = [\"GET\", \"HEAD\"].includes(req.method)\n ? undefined\n : typeof req.body === \"string\"\n ? req.body\n : JSON.stringify(req.body);\n\n debug(\"Forward body type:\", typeof body);\n debug(\"Forward body length:\", body?.length ?? 0);\n\n /* =========================\n FETCH\n ========================= */\n const proxyRes = await fetch(targetUrl, {\n method: req.method,\n headers,\n body,\n });\n\n debug(\"=== FETCH RESPONSE ===\");\n debug(\"Status:\", proxyRes.status);\n debug(\"StatusText:\", proxyRes.statusText);\n debug(\"URL:\", proxyRes.url);\n\n const headersObj: Record<string, string> = {};\n for (const [k, v] of proxyRes.headers.entries()) {\n headersObj[k] = v;\n }\n debug(\"Response headers:\", headersObj);\n\n debug(\"content-type:\", proxyRes.headers.get(\"content-type\"));\n debug(\"content-encoding:\", proxyRes.headers.get(\"content-encoding\"));\n debug(\"transfer-encoding:\", proxyRes.headers.get(\"transfer-encoding\"));\n debug(\"content-length:\", proxyRes.headers.get(\"content-length\"));\n\n /* =========================\n CORS\n ========================= */\n res.setHeader(\"Access-Control-Allow-Origin\", \"*\");\n res.setHeader(\n \"Access-Control-Allow-Methods\",\n \"GET,POST,PUT,PATCH,DELETE,OPTIONS,HEAD\",\n );\n res.setHeader(\"Access-Control-Allow-Headers\", \"*\");\n res.setHeader(\"Access-Control-Expose-Headers\", \"*\");\n\n /* =========================\n SAFE HEADERS PASS\n ========================= */\n for (const [key, value] of proxyRes.headers.entries()) {\n const k = key.toLowerCase();\n\n // quebram proxy quando body já vem decodado\n if (k === \"content-encoding\") continue;\n if (k === \"content-length\") continue;\n\n // headers de conexão\n if (\n [\n \"connection\",\n \"keep-alive\",\n \"transfer-encoding\",\n \"te\",\n \"trailer\",\n \"upgrade\",\n \"host\",\n ].includes(k)\n )\n continue;\n\n res.setHeader(key, value);\n }\n\n if (req.method === \"OPTIONS\") {\n debug(\"OPTIONS request -> end\");\n return res.end();\n }\n\n /* =========================\n DEBUG SEVERO BODY\n ========================= */\n const arrayBuf = await proxyRes.arrayBuffer();\n const buffer = Buffer.from(arrayBuf);\n\n debug(\"=== BODY DEBUG ===\");\n debug(\"ArrayBuffer byteLength:\", arrayBuf.byteLength);\n debug(\"Buffer length:\", buffer.length);\n debug(\"Buffer empty:\", buffer.length === 0);\n debug(\"First 50 bytes (hex):\", buffer.subarray(0, 50).toString(\"hex\"));\n debug(\n \"First 200 chars (utf8):\",\n buffer.subarray(0, 200).toString(\"utf8\"),\n );\n debug(\"=== END BODY DEBUG ===\");\n\n /* =========================\n SEND\n ========================= */\n res.status(proxyRes.status).send(buffer);\n } catch (err) {\n debug(\"=== PROXY ERROR ===\");\n debug(\"Ocorreu um erro no proxy...\", err);\n logger(\"error\", `[PROXY] Error: ${err}`);\n res.status(500).json({ error: \"Proxy error\" });\n }\n },\n );\n}\n","/**\n * Debug utility function that only logs when DEBUG environment variable is set to 'true'\n */\n\nexport function debug(message: string, ...optionalParams: any[]) {\n if (process.env.DEBUG === 'true' || process.env.DEBUG === '1') {\n console.log(`[DEBUG] ${message}`, ...optionalParams);\n }\n}","import { logger } from \"azurajs/logger\";\nimport fs from \"fs\";\nimport path from \"node:path\";\nimport { ScalarError, SetupDocsRouteOptions } from \"./config/types\";\nimport { debug } from \"./utils/debug\";\n\nexport async function setupScalarDocs({\n app,\n docPath,\n customHtmlPath,\n apiSpecUrl,\n proxyUrl,\n}: SetupDocsRouteOptions) {\n debug(\"Setting up docs route with options:\", { docPath, customHtmlPath, apiSpecUrl, proxyUrl });\n\n return app.get(docPath, (req, res) => {\n debug(\"Docs route hit with request:\", req.method, req.url);\n try {\n if (!proxyUrl || !apiSpecUrl) {\n debug(\"Missing required URLs - proxyUrl:\", proxyUrl, \"apiSpecUrl:\", apiSpecUrl);\n throw new ScalarError(\n \"Missing required URLs\",\n \"STORE_VALUES_MISSING\",\n 500,\n );\n }\n\n const htmlPath =\n customHtmlPath || path.join(__dirname, \"../api-docs.html\");\n debug(\"HTML template path:\", htmlPath);\n\n if (!fs.existsSync(htmlPath)) {\n debug(\"HTML template not found at path:\", htmlPath);\n throw new ScalarError(\n \"HTML template not found\",\n \"HTML_TEMPLATE_NOT_FOUND\",\n 404,\n );\n }\n\n const html = fs.readFileSync(htmlPath, \"utf-8\");\n debug(\"HTML template read successfully, length:\", html.length);\n\n const processedHtml = html\n .replace(/&{proxy_url}/g, proxyUrl)\n .replace(/&{api_spec_url}/g, apiSpecUrl);\n debug(\"HTML template processed with proxyUrl and apiSpecUrl\");\n\n return res.send(processedHtml);\n } catch (error) {\n debug(\"Error in docs route:\", error);\n if (error instanceof ScalarError) {\n logger(\"error\", `[ScalarError] ${error.message}`);\n return res.status(error.statusCode).json({ message: error.message });\n } else {\n logger(\"error\", String(error));\n return res.status(500).json({ message: \"Server error\" });\n }\n }\n });\n}\n","/**\n * @fileoverview Store utility for managing application state\n * This module provides a typed store for managing scalar configuration values\n */\n\nimport { ScalarStoreType } from \"../config/types\";\n\n/**\n * Typed store class for managing scalar configuration values\n */\nclass ScalarStore {\n private store: Map<keyof ScalarStoreType, string | undefined> = new Map();\n\n /**\n * Sets a value in the store\n * @param key The key to set\n * @param value The value to set (if undefined, the key will be removed)\n */\n set<K extends keyof ScalarStoreType>(\n key: K,\n value: ScalarStoreType[K],\n ): void {\n this.store.set(key, value as string | undefined);\n }\n\n /**\n * Gets a value from the store\n * @param key The key to get\n * @returns The value associated with the key\n */\n get<K extends keyof ScalarStoreType>(key: K): ScalarStoreType[K] {\n return this.store.get(key) as ScalarStoreType[K];\n }\n\n /**\n * Checks if a key exists in the store\n * @param key The key to check\n * @returns True if the key exists, false otherwise\n */\n has(key: keyof ScalarStoreType): boolean {\n return this.store.has(key);\n }\n\n /**\n * Deletes a key from the store\n * @param key The key to delete\n * @returns True if the key existed and was deleted, false otherwise\n */\n delete(key: keyof ScalarStoreType): boolean {\n return this.store.delete(key);\n }\n\n /**\n * Clears all values from the store\n */\n clear(): void {\n this.store.clear();\n }\n\n /**\n * Gets all values from the store\n * @returns An object containing all key-value pairs in the store\n */\n getAll(): ScalarStoreType {\n const result: Partial<ScalarStoreType> = {};\n for (const [key, value] of this.store.entries()) {\n result[key] = value as ScalarStoreType[keyof ScalarStoreType];\n }\n return result as ScalarStoreType;\n }\n\n // Index signature to allow direct property access\n [key: string]: any;\n}\n\nexport const store = new ScalarStore();\n","/**\n * Scalar client for API documentation\n */\nimport { ScalarConfigType, ScalarError } from \"./config/types\";\nimport { proxyMiddleware } from \"./middleware/proxy\";\nimport { setupScalarDocs } from \"./setupDocsRoute\";\nimport { store } from \"./utils/store\";\nimport { debug } from \"./utils/debug\";\n\nexport class Scalar {\n constructor(config: ScalarConfigType) {\n debug(\"Scalar constructor called with config:\", config);\n\n // Normalize baseUrl to ensure it's a valid absolute URL before validation\n const normalizedConfig = { ...config };\n normalizedConfig.baseUrl = this.normalizeBaseUrl(config.baseUrl);\n debug(\"Normalized config:\", normalizedConfig);\n\n // Validate the configuration\n this.validateConfig(normalizedConfig);\n\n // Set default paths if not provided\n const proxyPath = normalizedConfig.proxyPath || \"/scalar/proxy\";\n const docPath = normalizedConfig.docPath || \"/docs\";\n const apiSpecPath = normalizedConfig.apiSpecPath || \"\";\n debug(\n \"Using paths - proxyPath:\",\n proxyPath,\n \"docPath:\",\n docPath,\n \"apiSpecPath:\",\n apiSpecPath,\n );\n\n // Calculate full URLs from baseUrl and paths\n // Use default proxy if proxyPath is not provided\n const proxyUrl = normalizedConfig.proxyPath\n ? this.joinUrl(normalizedConfig.baseUrl, normalizedConfig.proxyPath)\n : \"https://proxy.scalar.com\";\n const docUrl = this.joinUrl(normalizedConfig.baseUrl, docPath);\n const apiSpecUrl = this.joinUrl(normalizedConfig.baseUrl, apiSpecPath);\n debug(\n \"Calculated URLs - proxyUrl:\",\n proxyUrl,\n \"docUrl:\",\n docUrl,\n \"apiSpecUrl:\",\n apiSpecUrl,\n );\n\n // Store the calculated URLs\n store.set(\"proxy_url\", proxyUrl);\n store.set(\"api_spec_url\", apiSpecUrl);\n store.set(\"doc_url\", docUrl);\n debug(\"Stored URLs in store\");\n\n // Call setup with the calculated URLs\n setupScalarDocs({\n ...normalizedConfig,\n proxyUrl,\n docPath,\n apiSpecUrl,\n });\n debug(\"setupScalarDocs called\");\n\n // Setup proxy middleware if proxyPath is provided (for custom proxy)\n if (normalizedConfig.proxyPath) {\n // Setup proxy middleware\n proxyMiddleware({\n apiSpecUrl,\n proxyUrlPath: normalizedConfig.proxyPath,\n app: normalizedConfig.app,\n baseUrl: normalizedConfig.baseUrl,\n });\n debug(\"proxyMiddleware called\");\n }\n }\n\n private joinUrl(baseUrl: string, path: string): string {\n // Normalize the baseUrl to ensure it ends with a slash\n const normalizedBaseUrl = baseUrl.endsWith(\"/\") ? baseUrl : baseUrl + \"/\";\n\n // Normalize the path to ensure it starts with a slash\n const normalizedPath = path.startsWith(\"/\") ? path : \"/\" + path;\n\n // Join the baseUrl and path, removing any double slashes\n return normalizedBaseUrl.replace(/\\/$/, \"\") + normalizedPath;\n }\n\n private normalizeBaseUrl(baseUrl: string): string {\n if (!baseUrl) {\n throw new ScalarError(\n \"baseUrl is required\",\n \"MISSING_REQUIRED_CONFIG\",\n 400,\n );\n }\n\n // If baseUrl doesn't start with a protocol, prepend http://\n if (!/^https?:\\/\\//i.test(baseUrl)) {\n return \"http://\" + baseUrl;\n }\n\n return baseUrl;\n }\n\n private validateConfig(config: ScalarConfigType): void {\n if (!config.baseUrl) {\n throw new ScalarError(\n \"baseUrl is required\",\n \"MISSING_REQUIRED_CONFIG\",\n 400,\n );\n }\n\n try {\n // Validate baseUrl\n debug(\"Validating baseUrl:\", config.baseUrl);\n new URL(config.baseUrl);\n\n // Validate paths if provided\n if (config.proxyPath) {\n debug(\"Validating proxyPath:\", config.proxyPath);\n if (!this.isValidPath(config.proxyPath)) {\n debug(\"proxyPath validation FAILED\");\n throw new Error(\"Invalid proxyPath\");\n }\n }\n\n if (config.docPath) {\n debug(\"Validating docPath:\", config.docPath);\n if (!this.isValidPath(config.docPath)) {\n debug(\"docPath validation FAILED\");\n throw new Error(\"Invalid docPath\");\n }\n }\n\n if (config.apiSpecPath) {\n debug(\"Validating apiSpecPath:\", config.apiSpecPath);\n if (!this.isValidPath(config.apiSpecPath)) {\n debug(\"apiSpecPath validation FAILED\");\n throw new Error(\"Invalid apiSpecPath\");\n }\n }\n } catch (error) {\n debug(\"Validation error:\", error);\n throw new ScalarError(\"Invalid URL provided\", \"INVALID_URL\", 400);\n }\n }\n\n private isValidPath(path: string): boolean {\n // Aceita paths relativos com barras no meio e no final\n return (\n typeof path === \"string\" &&\n /^\\/[a-zA-Z0-9\\-._~:\\/@!$&'()*+,;=]*\\/?$/.test(path)\n );\n }\n}\n"],"mappings":";AAyBO,IAAM,cAAN,MAAM,qBAAoB,MAAM;AAAA,EACrC,YACkB,SACA,MACA,YAChB;AACA,UAAM,OAAO;AAJG;AACA;AACA;AAGhB,WAAO,eAAe,MAAM,aAAY,SAAS;AAAA,EACnD;AACF;;;ACjCA,SAAS,cAAc;;;ACGhB,SAAS,MAAM,YAAoB,gBAAuB;AAC/D,MAAI,QAAQ,IAAI,UAAU,UA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6B;AACnC,gBAAM,IAAI,MAAM,mBAAmB;AAAA,QACrC;AAAA,MACF;AAEA,UAAI,OAAO,SAAS;AAClB,cAAM,uBAAuB,OAAO,OAAO;AAC3C,YAAI,CAAC,KAAK,YAAY,OAAO,OAAO,GAAG;AACrC,gBAAM,2BAA2B;AACjC,gBAAM,IAAI,MAAM,iBAAiB;AAAA,QACnC;AAAA,MACF;AAEA,UAAI,OAAO,aAAa;AACtB,cAAM,2BAA2B,OAAO,WAAW;AACnD,YAAI,CAAC,KAAK,YAAY,OAAO,WAAW,GAAG;AACzC,gBAAM,+BAA+B;AACrC,gBAAM,IAAI,MAAM,qBAAqB;AAAA,QACvC;AAAA,MACF;AAAA,IACF,SAAS,OAAO;AACd,YAAM,qBAAqB,KAAK;AAChC,YAAM,IAAI,YAAY,wBAAwB,eAAe,GAAG;AAAA,IAClE;AAAA,EACF;AAAA,EAEQ,YAAYA,OAAuB;AAEzC,WACE,OAAOA,UAAS,YAChB,0CAA0C,KAAKA,KAAI;AAAA,EAEvD;AACF;","names":["logger","logger","path"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "azurajs-scalar",
3
- "version": "2.1.2",
3
+ "version": "2.1.3-1",
4
4
  "description": "Proxy middleware and controller to scalar documentation.",
5
5
  "type": "module",
6
6
  "publishConfig": {
Binary file