@scalar/mock-server 0.9.9 → 0.9.11

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/create-mock-server.js +79 -68
  3. package/dist/index.js +1 -5
  4. package/dist/libs/store.js +66 -65
  5. package/dist/routes/mock-any-response.js +70 -63
  6. package/dist/routes/mock-handler-response.js +140 -100
  7. package/dist/routes/respond-with-authorize-page.js +89 -80
  8. package/dist/routes/respond-with-openapi-document.js +32 -35
  9. package/dist/routes/respond-with-token.js +40 -45
  10. package/dist/types.js +2 -5
  11. package/dist/utils/build-handler-context.js +83 -70
  12. package/dist/utils/build-seed-context.js +59 -52
  13. package/dist/utils/create-openapi-definition.js +7 -10
  14. package/dist/utils/execute-handler.js +16 -18
  15. package/dist/utils/execute-seed.js +22 -21
  16. package/dist/utils/find-preferred-response-key.js +9 -9
  17. package/dist/utils/get-open-auth-token-urls.js +45 -35
  18. package/dist/utils/get-operation.js +12 -12
  19. package/dist/utils/handle-authentication.js +106 -101
  20. package/dist/utils/hono-route-from-path.js +6 -6
  21. package/dist/utils/is-authentication-required.js +17 -15
  22. package/dist/utils/log-authentication-instructions.js +105 -110
  23. package/dist/utils/process-openapi-document.js +71 -58
  24. package/dist/utils/set-up-authentication-routes.js +80 -77
  25. package/dist/utils/store-wrapper.js +40 -39
  26. package/package.json +10 -16
  27. package/dist/create-mock-server.js.map +0 -7
  28. package/dist/index.js.map +0 -7
  29. package/dist/libs/store.js.map +0 -7
  30. package/dist/routes/mock-any-response.js.map +0 -7
  31. package/dist/routes/mock-handler-response.js.map +0 -7
  32. package/dist/routes/respond-with-authorize-page.js.map +0 -7
  33. package/dist/routes/respond-with-openapi-document.js.map +0 -7
  34. package/dist/routes/respond-with-token.js.map +0 -7
  35. package/dist/types.js.map +0 -7
  36. package/dist/utils/build-handler-context.js.map +0 -7
  37. package/dist/utils/build-seed-context.js.map +0 -7
  38. package/dist/utils/create-openapi-definition.js.map +0 -7
  39. package/dist/utils/execute-handler.js.map +0 -7
  40. package/dist/utils/execute-seed.js.map +0 -7
  41. package/dist/utils/find-preferred-response-key.js.map +0 -7
  42. package/dist/utils/get-open-auth-token-urls.js.map +0 -7
  43. package/dist/utils/get-operation.js.map +0 -7
  44. package/dist/utils/handle-authentication.js.map +0 -7
  45. package/dist/utils/hono-route-from-path.js.map +0 -7
  46. package/dist/utils/is-authentication-required.js.map +0 -7
  47. package/dist/utils/log-authentication-instructions.js.map +0 -7
  48. package/dist/utils/process-openapi-document.js.map +0 -7
  49. package/dist/utils/set-up-authentication-routes.js.map +0 -7
  50. package/dist/utils/store-wrapper.js.map +0 -7
@@ -1,80 +1,83 @@
1
- import { respondWithAuthorizePage } from "../routes/respond-with-authorize-page.js";
2
- import { respondWithToken } from "../routes/respond-with-token.js";
3
- import { getOpenAuthTokenUrls, getPathFromUrl } from "./get-open-auth-token-urls.js";
4
- function setUpAuthenticationRoutes(app, schema) {
5
- const securitySchemes = schema?.components?.securitySchemes || {};
6
- getOpenAuthTokenUrls(schema).forEach((tokenUrl) => {
7
- app.post(tokenUrl, (c) => {
8
- return c.json(
9
- {
10
- access_token: "super-secret-access-token",
11
- token_type: "Bearer",
12
- expires_in: 3600,
13
- refresh_token: "example-refresh-token"
14
- },
15
- 200,
16
- {
17
- /**
18
- * When responding with an access token, the server must also include the additional
19
- * Cache-Control: no-store HTTP header to ensure clients do not cache this request.
20
- *
21
- * @see https://www.oauth.com/oauth2-servers/access-tokens/access-token-response/
22
- */
23
- "Cache-Control": "no-store"
1
+ import { respondWithAuthorizePage } from '../routes/respond-with-authorize-page.js';
2
+ import { respondWithToken } from '../routes/respond-with-token.js';
3
+ import { getOpenAuthTokenUrls, getPathFromUrl } from './get-open-auth-token-urls.js';
4
+ /**
5
+ * Helper function to set up authentication routes for OAuth 2.0 flows
6
+ */
7
+ export function setUpAuthenticationRoutes(app, schema) {
8
+ const securitySchemes = schema?.components?.securitySchemes || {};
9
+ // Set up authentication routes for OAuth 2.0 flows
10
+ getOpenAuthTokenUrls(schema).forEach((tokenUrl) => {
11
+ app.post(tokenUrl, (c) => {
12
+ return c.json({
13
+ access_token: 'super-secret-access-token',
14
+ token_type: 'Bearer',
15
+ expires_in: 3600,
16
+ refresh_token: 'example-refresh-token',
17
+ }, 200, {
18
+ /**
19
+ * When responding with an access token, the server must also include the additional
20
+ * Cache-Control: no-store HTTP header to ensure clients do not cache this request.
21
+ *
22
+ * @see https://www.oauth.com/oauth2-servers/access-tokens/access-token-response/
23
+ */
24
+ 'Cache-Control': 'no-store',
25
+ });
26
+ });
27
+ });
28
+ // Set up routes for different OAuth 2.0 flows
29
+ const authorizeUrls = new Set();
30
+ const tokenUrls = new Set();
31
+ Object.entries(securitySchemes).forEach(([_, scheme]) => {
32
+ if (scheme.type === 'oauth2') {
33
+ if (scheme.flows?.authorizationCode) {
34
+ const authorizeRoute = scheme.flows.authorizationCode.authorizationUrl ?? '/oauth/authorize';
35
+ const tokenRoute = scheme.flows.authorizationCode.tokenUrl ?? '/oauth/token';
36
+ authorizeUrls.add(getPathFromUrl(authorizeRoute));
37
+ tokenUrls.add(tokenRoute);
38
+ }
39
+ if (scheme.flows?.implicit) {
40
+ const authorizeRoute = scheme.flows.implicit.authorizationUrl ?? '/oauth/authorize';
41
+ authorizeUrls.add(getPathFromUrl(authorizeRoute));
42
+ }
43
+ if (scheme.flows?.password) {
44
+ const tokenRoute = scheme.flows.password.tokenUrl ?? '/oauth/token';
45
+ tokenUrls.add(tokenRoute);
46
+ }
47
+ if (scheme.flows?.clientCredentials) {
48
+ const tokenRoute = scheme.flows.clientCredentials.tokenUrl ?? '/oauth/token';
49
+ tokenUrls.add(tokenRoute);
50
+ }
51
+ }
52
+ else if (scheme.type === 'openIdConnect') {
53
+ // Handle OpenID Connect configuration
54
+ if (scheme.openIdConnectUrl) {
55
+ const configPath = getPathFromUrl(scheme.openIdConnectUrl ?? '/.well-known/openid-configuration');
56
+ // Add route for OpenID Connect configuration
57
+ app.get(configPath, (c) => {
58
+ return c.json({
59
+ issuer: 'https://example.com',
60
+ authorization_endpoint: '/oauth/authorize',
61
+ token_endpoint: '/oauth/token',
62
+ response_types_supported: ['code', 'token', 'id_token'],
63
+ subject_types_supported: ['public'],
64
+ id_token_signing_alg_values_supported: ['RS256'],
65
+ });
66
+ });
67
+ // Add standard endpoints
68
+ const authorizeRoute = '/oauth/authorize';
69
+ const tokenRoute = '/oauth/token';
70
+ authorizeUrls.add(getPathFromUrl(authorizeRoute));
71
+ tokenUrls.add(tokenRoute);
72
+ }
24
73
  }
25
- );
26
74
  });
27
- });
28
- const authorizeUrls = /* @__PURE__ */ new Set();
29
- const tokenUrls = /* @__PURE__ */ new Set();
30
- Object.entries(securitySchemes).forEach(([_, scheme]) => {
31
- if (scheme.type === "oauth2") {
32
- if (scheme.flows?.authorizationCode) {
33
- const authorizeRoute = scheme.flows.authorizationCode.authorizationUrl ?? "/oauth/authorize";
34
- const tokenRoute = scheme.flows.authorizationCode.tokenUrl ?? "/oauth/token";
35
- authorizeUrls.add(getPathFromUrl(authorizeRoute));
36
- tokenUrls.add(tokenRoute);
37
- }
38
- if (scheme.flows?.implicit) {
39
- const authorizeRoute = scheme.flows.implicit.authorizationUrl ?? "/oauth/authorize";
40
- authorizeUrls.add(getPathFromUrl(authorizeRoute));
41
- }
42
- if (scheme.flows?.password) {
43
- const tokenRoute = scheme.flows.password.tokenUrl ?? "/oauth/token";
44
- tokenUrls.add(tokenRoute);
45
- }
46
- if (scheme.flows?.clientCredentials) {
47
- const tokenRoute = scheme.flows.clientCredentials.tokenUrl ?? "/oauth/token";
48
- tokenUrls.add(tokenRoute);
49
- }
50
- } else if (scheme.type === "openIdConnect") {
51
- if (scheme.openIdConnectUrl) {
52
- const configPath = getPathFromUrl(scheme.openIdConnectUrl ?? "/.well-known/openid-configuration");
53
- app.get(configPath, (c) => {
54
- return c.json({
55
- issuer: "https://example.com",
56
- authorization_endpoint: "/oauth/authorize",
57
- token_endpoint: "/oauth/token",
58
- response_types_supported: ["code", "token", "id_token"],
59
- subject_types_supported: ["public"],
60
- id_token_signing_alg_values_supported: ["RS256"]
61
- });
62
- });
63
- const authorizeRoute = "/oauth/authorize";
64
- const tokenRoute = "/oauth/token";
65
- authorizeUrls.add(getPathFromUrl(authorizeRoute));
66
- tokenUrls.add(tokenRoute);
67
- }
68
- }
69
- });
70
- authorizeUrls.forEach((authorizeUrl) => {
71
- app.get(authorizeUrl, (c) => respondWithAuthorizePage(c, schema?.info?.title));
72
- });
73
- tokenUrls.forEach((tokenUrl) => {
74
- app.post(tokenUrl, respondWithToken);
75
- });
75
+ // Set up unique authorization routes
76
+ authorizeUrls.forEach((authorizeUrl) => {
77
+ app.get(authorizeUrl, (c) => respondWithAuthorizePage(c, schema?.info?.title));
78
+ });
79
+ // Set up unique token routes
80
+ tokenUrls.forEach((tokenUrl) => {
81
+ app.post(tokenUrl, respondWithToken);
82
+ });
76
83
  }
77
- export {
78
- setUpAuthenticationRoutes
79
- };
80
- //# sourceMappingURL=set-up-authentication-routes.js.map
@@ -1,40 +1,41 @@
1
- function createStoreWrapper(store) {
2
- const tracking = {
3
- operations: []
4
- };
5
- const wrappedStore = {
6
- list(collection) {
7
- const result = store.list(collection);
8
- tracking.operations.push({ operation: "list", result });
9
- return result;
10
- },
11
- get(collection, id) {
12
- const result = store.get(collection, id);
13
- tracking.operations.push({ operation: "get", result });
14
- return result;
15
- },
16
- create(collection, data) {
17
- const result = store.create(collection, data);
18
- tracking.operations.push({ operation: "create", result });
19
- return result;
20
- },
21
- update(collection, id, data) {
22
- const result = store.update(collection, id, data);
23
- tracking.operations.push({ operation: "update", result });
24
- return result;
25
- },
26
- delete(collection, id) {
27
- const result = store.delete(collection, id);
28
- tracking.operations.push({ operation: "delete", result });
29
- return result;
30
- },
31
- clear(collection) {
32
- store.clear(collection);
33
- }
34
- };
35
- return { wrappedStore, tracking };
1
+ /**
2
+ * Creates a wrapped store that tracks operations.
3
+ * Returns both the wrapped store and a tracking object that gets updated as operations are performed.
4
+ */
5
+ export function createStoreWrapper(store) {
6
+ const tracking = {
7
+ operations: [],
8
+ };
9
+ const wrappedStore = {
10
+ list(collection) {
11
+ const result = store.list(collection);
12
+ tracking.operations.push({ operation: 'list', result });
13
+ return result;
14
+ },
15
+ get(collection, id) {
16
+ const result = store.get(collection, id);
17
+ tracking.operations.push({ operation: 'get', result });
18
+ return result;
19
+ },
20
+ create(collection, data) {
21
+ const result = store.create(collection, data);
22
+ tracking.operations.push({ operation: 'create', result });
23
+ return result;
24
+ },
25
+ update(collection, id, data) {
26
+ const result = store.update(collection, id, data);
27
+ tracking.operations.push({ operation: 'update', result });
28
+ return result;
29
+ },
30
+ delete(collection, id) {
31
+ const result = store.delete(collection, id);
32
+ tracking.operations.push({ operation: 'delete', result });
33
+ return result;
34
+ },
35
+ clear(collection) {
36
+ store.clear(collection);
37
+ // clear() doesn't set tracking as it's not a typical CRUD operation
38
+ },
39
+ };
40
+ return { wrappedStore, tracking };
36
41
  }
37
- export {
38
- createStoreWrapper
39
- };
40
- //# sourceMappingURL=store-wrapper.js.map
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "swagger",
17
17
  "cli"
18
18
  ],
19
- "version": "0.9.9",
19
+ "version": "0.9.11",
20
20
  "engines": {
21
21
  "node": ">=22"
22
22
  },
@@ -53,26 +53,20 @@
53
53
  "dependencies": {
54
54
  "@faker-js/faker": "^10.2.0",
55
55
  "hono": "4.12.4",
56
- "@scalar/helpers": "0.4.1",
57
- "@scalar/json-magic": "0.12.3",
58
- "@scalar/oas-utils": "0.10.8",
59
- "@scalar/openapi-types": "0.6.0",
60
- "@scalar/openapi-upgrader": "0.2.0",
61
- "@scalar/openapi-parser": "0.25.4"
56
+ "@scalar/helpers": "0.4.2",
57
+ "@scalar/oas-utils": "0.10.10",
58
+ "@scalar/json-magic": "0.12.4",
59
+ "@scalar/openapi-types": "0.6.1",
60
+ "@scalar/openapi-upgrader": "0.2.2",
61
+ "@scalar/openapi-parser": "0.25.6"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@types/node": "^24.1.0",
65
- "vite": "^7.3.1",
66
- "@scalar/build-tooling": "0.5.0"
65
+ "vite": "8.0.0"
67
66
  },
68
67
  "scripts": {
69
- "build": "scalar-build-esbuild",
70
- "dev": "cd playground && pnpm run dev",
71
- "dev:local": "cd playground && pnpm run dev:local",
72
- "lint:check": "scalar-lint-check",
73
- "lint:fix": "scalar-lint-fix",
68
+ "build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
74
69
  "test": "vitest",
75
- "types:build": "scalar-types-build",
76
- "types:check": "scalar-types-check"
70
+ "types:check": "tsc --noEmit"
77
71
  }
78
72
  }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/create-mock-server.ts"],
4
- "sourcesContent": ["import type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { Hono } from 'hono'\nimport { cors } from 'hono/cors'\n\nimport type { HttpMethod, MockServerOptions } from '@/types'\nimport { buildSeedContext } from '@/utils/build-seed-context'\nimport { executeSeed } from '@/utils/execute-seed'\nimport { getOperations } from '@/utils/get-operation'\nimport { handleAuthentication } from '@/utils/handle-authentication'\nimport { honoRouteFromPath } from '@/utils/hono-route-from-path'\nimport { isAuthenticationRequired } from '@/utils/is-authentication-required'\nimport { logAuthenticationInstructions } from '@/utils/log-authentication-instructions'\nimport { processOpenApiDocument } from '@/utils/process-openapi-document'\nimport { setUpAuthenticationRoutes } from '@/utils/set-up-authentication-routes'\n\nimport { store } from './libs/store'\nimport { mockAnyResponse } from './routes/mock-any-response'\nimport { mockHandlerResponse } from './routes/mock-handler-response'\nimport { respondWithOpenApiDocument } from './routes/respond-with-openapi-document'\n\n/**\n * Create a mock server instance\n */\nexport async function createMockServer(configuration: MockServerOptions): Promise<Hono> {\n const app = new Hono()\n\n /** Dereferenced OpenAPI document */\n const schema = await processOpenApiDocument(configuration?.document ?? configuration?.specification)\n\n // Seed data from schemas with x-seed extension\n // This happens before routes are set up so data is available immediately\n const schemas = schema?.components?.schemas\n if (schemas) {\n for (const [schemaName, schemaObject] of Object.entries(schemas)) {\n const seedCode = (schemaObject as any)?.['x-seed']\n\n if (seedCode && typeof seedCode === 'string') {\n try {\n // Check if collection is empty (idempotent seeding)\n // Use the schema key directly as the collection name\n const existingItems = store.list(schemaName)\n if (existingItems.length === 0) {\n // Build seed context with schema key (used as collection name)\n const seedContext = buildSeedContext(schemaName)\n\n // Execute seed code\n await executeSeed(seedCode, seedContext)\n }\n } catch (error) {\n // Log error but don't fail server startup\n console.error(`Error seeding schema \"${schemaName}\":`, error)\n }\n }\n }\n }\n\n // CORS headers\n app.use(cors())\n\n /** Authentication methods defined in the OpenAPI document */\n setUpAuthenticationRoutes(app, schema)\n\n logAuthenticationInstructions(\n schema?.components?.securitySchemes || ({} as Record<string, OpenAPIV3_1.SecuritySchemeObject>),\n )\n\n /** Paths specified in the OpenAPI document */\n const paths = schema?.paths ?? {}\n\n Object.keys(paths).forEach((path) => {\n const methods = Object.keys(getOperations(paths[path])) as HttpMethod[]\n\n /** Keys for all operations of a specified path */\n methods.forEach((method) => {\n const route = honoRouteFromPath(path)\n const operation = schema?.paths?.[path]?.[method] as OpenAPIV3_1.OperationObject\n\n // Check if authentication is required for this operation\n if (isAuthenticationRequired(operation.security)) {\n app[method](route, handleAuthentication(schema, operation))\n }\n\n // Check if operation has x-handler extension\n // Validate that it's a non-empty string (consistent with x-seed validation)\n const handlerCode = operation?.['x-handler']\n const hasHandler = handlerCode && typeof handlerCode === 'string' && handlerCode.trim().length > 0\n\n // Route to appropriate handler\n if (hasHandler) {\n app[method](route, (c) => mockHandlerResponse(c, operation, configuration))\n } else {\n app[method](route, (c) => mockAnyResponse(c, operation, configuration))\n }\n })\n })\n\n // OpenAPI JSON file\n app.get('/openapi.json', (c) =>\n respondWithOpenApiDocument(c, configuration?.document ?? configuration?.specification, 'json'),\n )\n\n // OpenAPI YAML file\n app.get('/openapi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AAC;AAGtD,YAAQ,QAAQ,CAAC,WAAW;AAC1B,YAAM,QAAQ,kBAAkB,IAAI;AACpC,YAAM,YAAY,QAAQ,QAAQ,IAAI,IAAI,MAAM;AAGhD,UAAI,yBAAyB,UAAU,QAAQ,GAAG;AAChD,YAAI,MAAM,EAAE,OAAO,qBAAqB,QAAQ,SAAS,CAAC;AAAA,MAC5D;AAIA,YAAM,cAAc,YAAY,WAAW;AAC3C,YAAM,aAAa,eAAe,OAAO,gBAAgB,YAAY,YAAY,KAAK,EAAE,SAAS;AAGjG,UAAI,YAAY;AACd,YAAI,MAAM,EAAE,OAAO,CAAC,MAAM,oBAAoB,GAAG,WAAW,aAAa,CAAC;AAAA,MAC5E,OAAO;AACL,YAAI,MAAM,EAAE,OAAO,CAAC,MAAM,gBAAgB,GAAG,WAAW,aAAa,CAAC;AAAA,MACxE;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAGD,MAAI;AAAA,IAAI;AAAA,IAAiB,CAAC,MACxB,2BAA2B,GAAG,eAAe,YAAY,eAAe,eAAe,MAAM;AAAA,EAC/F;AAGA,MAAI;AAAA,IAAI;AAAA,IAAiB,CAAC,MACxB,2BAA2B,GAAG,eAAe,YAAY,eAAe,eAAe,MAAM;AAAA,EAC/F;AAEA,SAAO;AACT;",
6
- "names": []
7
- }
package/dist/index.js.map DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/index.ts"],
4
- "sourcesContent": ["export { createMockServer } from './create-mock-server'\n"],
5
- "mappings": "AAAA,SAAS,wBAAwB;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/libs/store.ts"],
4
- "sourcesContent": ["/**\n * Simple in-memory store for x-handler operations.\n * Data persists during server lifetime but is reset on server restart.\n */\ntype StoreData = Record<string, Record<string, any>>\n\nexport class Store {\n private data: StoreData = {}\n\n /**\n * Get all items in a collection.\n */\n list(collection: string): any[] {\n const items = this.data[collection]\n return items ? Object.values(items) : []\n }\n\n /**\n * Get a single item by ID.\n */\n get(collection: string, id: string): any | undefined {\n return this.data[collection]?.[id]\n }\n\n /**\n * Create a new item in a collection.\n * Auto-generates an ID if not provided.\n */\n create(collection: string, data: any): any {\n if (!this.data[collection]) {\n this.data[collection] = {}\n }\n\n // Handle null/undefined data by defaulting to empty object\n const safeData = data ?? {}\n const id = safeData.id ?? crypto.randomUUID()\n const item = { ...safeData, id }\n\n this.data[collection][id] = item\n\n return item\n }\n\n /**\n * Update an existing item in a collection.\n * Returns null if the item is not found.\n */\n update(collection: string, id: string, data: any): any | null {\n if (!this.data[collection]?.[id]) {\n return null\n }\n\n // Handle null/undefined data by defaulting to empty object\n const safeData = data ?? {}\n const updated = { ...this.data[collection][id], ...safeData, id }\n this.data[collection][id] = updated\n\n return updated\n }\n\n /**\n * Delete an item from a collection.\n * Returns null if the item is not found.\n */\n delete(collection: string, id: string): boolean | null {\n if (!this.data[collection]?.[id]) {\n return null\n }\n\n delete this.data[collection][id]\n\n return true\n }\n\n /**\n * Clear a specific collection or all collections.\n */\n clear(collection?: string): void {\n if (collection) {\n delete this.data[collection]\n } else {\n this.data = {}\n }\n }\n}\n\n/**\n * Singleton store instance shared across all requests.\n */\nexport const store = new Store()\n"],
5
- "mappings": "AAMO,MAAM,MAAM;AAAA,EACT,OAAkB,CAAC;AAAA;AAAA;AAAA;AAAA,EAK3B,KAAK,YAA2B;AAC9B,UAAM,QAAQ,KAAK,KAAK,UAAU;AAClC,WAAO,QAAQ,OAAO,OAAO,KAAK,IAAI,CAAC;AAAA,EACzC;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,YAAoB,IAA6B;AACnD,WAAO,KAAK,KAAK,UAAU,IAAI,EAAE;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,YAAoB,MAAgB;AACzC,QAAI,CAAC,KAAK,KAAK,UAAU,GAAG;AAC1B,WAAK,KAAK,UAAU,IAAI,CAAC;AAAA,IAC3B;AAGA,UAAM,WAAW,QAAQ,CAAC;AAC1B,UAAM,KAAK,SAAS,MAAM,OAAO,WAAW;AAC5C,UAAM,OAAO,EAAE,GAAG,UAAU,GAAG;AAE/B,SAAK,KAAK,UAAU,EAAE,EAAE,IAAI;AAE5B,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,YAAoB,IAAY,MAAuB;AAC5D,QAAI,CAAC,KAAK,KAAK,UAAU,IAAI,EAAE,GAAG;AAChC,aAAO;AAAA,IACT;AAGA,UAAM,WAAW,QAAQ,CAAC;AAC1B,UAAM,UAAU,EAAE,GAAG,KAAK,KAAK,UAAU,EAAE,EAAE,GAAG,GAAG,UAAU,GAAG;AAChE,SAAK,KAAK,UAAU,EAAE,EAAE,IAAI;AAE5B,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,YAAoB,IAA4B;AACrD,QAAI,CAAC,KAAK,KAAK,UAAU,IAAI,EAAE,GAAG;AAChC,aAAO;AAAA,IACT;AAEA,WAAO,KAAK,KAAK,UAAU,EAAE,EAAE;AAE/B,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,YAA2B;AAC/B,QAAI,YAAY;AACd,aAAO,KAAK,KAAK,UAAU;AAAA,IAC7B,OAAO;AACL,WAAK,OAAO,CAAC;AAAA,IACf;AAAA,EACF;AACF;AAKO,MAAM,QAAQ,IAAI,MAAM;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/routes/mock-any-response.ts"],
4
- "sourcesContent": ["import { json2xml } from '@scalar/helpers/file/json2xml'\nimport { getExampleFromSchema } from '@scalar/oas-utils/spec-getters'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport type { Context } from 'hono'\nimport { accepts } from 'hono/accepts'\nimport type { StatusCode } from 'hono/utils/http-status'\n\nimport type { MockServerOptions } from '@/types'\nimport { findPreferredResponseKey } from '@/utils/find-preferred-response-key'\n\n/**\n * Mock any response\n */\nexport function mockAnyResponse(c: Context, operation: OpenAPIV3_1.OperationObject, options: MockServerOptions) {\n // Call onRequest callback\n if (options?.onRequest) {\n options.onRequest({\n context: c,\n operation,\n })\n }\n\n // Response\n // default, 200, 201 \u2026\n const preferredResponseKey = findPreferredResponseKey(Object.keys(operation.responses ?? {}))\n const preferredResponse = preferredResponseKey ? operation.responses?.[preferredResponseKey] : null\n\n if (!preferredResponse) {\n c.status(500)\n\n return c.json({ error: 'No response defined for this operation.' })\n }\n\n // Status code\n const statusCode = Number.parseInt(\n preferredResponseKey === 'default' ? '200' : (preferredResponseKey ?? '200'),\n 10,\n ) as StatusCode\n\n // Headers\n const headers = preferredResponse?.headers ?? {}\n Object.keys(headers).forEach((header) => {\n const value = headers[header].schema ? getExampleFromSchema(headers[header].schema) : null\n if (value !== null) {\n c.header(header, value)\n }\n })\n\n // For 204 No Content responses, we should not set Content-Type and should return null body\n if (statusCode === 204) {\n c.status(statusCode)\n return c.body(null)\n }\n\n const supportedContentTypes = Object.keys(preferredResponse?.content ?? {})\n\n // If no content types are defined, return the status with no body\n if (supportedContentTypes.length === 0) {\n c.status(statusCode)\n return c.body(null)\n }\n\n // Content-Type\n const acceptedContentType = accepts(c, {\n header: 'Accept',\n supports: supportedContentTypes,\n default: supportedContentTypes.includes('application/json')\n ? 'application/json'\n : (supportedContentTypes[0] ?? 'text/plain;charset=UTF-8'),\n })\n\n c.header('Content-Type', acceptedContentType)\n\n const acceptedResponse = preferredResponse?.content?.[acceptedContentType]\n\n // Body\n const body = acceptedResponse?.example\n ? acceptedResponse.example\n : acceptedResponse?.schema\n ? getExampleFromSchema(acceptedResponse.schema, {\n emptyString: 'string',\n variables: c.req.param(),\n mode: 'read',\n })\n : null\n\n c.status(statusCode)\n\n return c.body(\n typeof body === 'object'\n ? // XML\n acceptedContentType?.includes('xml')\n ? json2xml(body)\n : // JSON\n JSON.stringify(body, null, 2)\n : // String\n body,\n )\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nC,CAAC;AAED,IAAE,OAAO,gBAAgB,mBAAmB;AAE5C,QAAM,mBAAmB,mBAAmB,UAAU,mBAAmB;AAGzE,QAAM,OAAO,kBAAkB,UAC3B,iBAAiB,UACjB,kBAAkB,SAChB,qBAAqB,iBAAiB,QAAQ;AAAA,IAC5C,aAAa;AAAA,IACb,WAAW,EAAE,IAAI,MAAM;AAAA,IACvB,MAAM;AAAA,EACR,CAAC,IACD;AAEN,IAAE,OAAO,UAAU;AAEnB,SAAO,EAAE;AAAA,IACP,OAAO,SAAS;AAAA;AAAA,MAEZ,qBAAqB,SAAS,KAAK,IACjC,SAAS,IAAI;AAAA;AAAA,QAEb,KAAK,UAAU,MAAM,MAAM,CAAC;AAAA;AAAA;AAAA;AAAA,MAE9B;AAAA;AAAA,EACN;AACF;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/routes/mock-handler-response.ts"],
4
- "sourcesContent": ["import { getExampleFromSchema } from '@scalar/oas-utils/spec-getters'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport type { Context } from 'hono'\nimport { accepts } from 'hono/accepts'\nimport type { StatusCode } from 'hono/utils/http-status'\n\nimport type { MockServerOptions } from '@/types'\nimport { buildHandlerContext } from '@/utils/build-handler-context'\nimport { executeHandler } from '@/utils/execute-handler'\n\n/**\n * Get example response from OpenAPI spec for a given status code.\n * Returns the example value if found, or null if not available.\n */\nfunction getExampleFromResponse(\n c: Context,\n statusCode: StatusCode,\n responses: OpenAPIV3_1.ResponsesObject | undefined,\n): any {\n if (!responses) {\n return null\n }\n\n const statusCodeStr = statusCode.toString()\n const response = responses[statusCodeStr] || responses.default\n\n if (!response) {\n return null\n }\n\n const supportedContentTypes = Object.keys(response.content ?? {})\n\n // If no content types are defined, return null\n if (supportedContentTypes.length === 0) {\n return null\n }\n\n // Content-Type negotiation\n const acceptedContentType = accepts(c, {\n header: 'Accept',\n supports: supportedContentTypes,\n default: supportedContentTypes.includes('application/json')\n ? 'application/json'\n : (supportedContentTypes[0] ?? 'text/plain;charset=UTF-8'),\n })\n\n const acceptedResponse = response.content?.[acceptedContentType]\n\n if (!acceptedResponse) {\n return null\n }\n\n // Extract example from example property or generate from schema\n return acceptedResponse.example !== undefined\n ? acceptedResponse.example\n : acceptedResponse.schema\n ? getExampleFromSchema(acceptedResponse.schema, {\n emptyString: 'string',\n variables: c.req.param(),\n mode: 'read',\n })\n : null\n}\n\n/**\n * Determine HTTP status code based on store operation tracking.\n * Prioritizes operations based on semantic meaning:\n * - get > update > delete > create > list\n * This ensures that if a handler performs multiple operations (e.g., get followed by create for logging),\n * the status code reflects the most semantically meaningful operation.\n */\nfunction determineStatusCode(tracking: {\n operations: Array<{ operation: 'get' | 'create' | 'update' | 'delete' | 'list'; result: any }>\n}): StatusCode {\n const { operations } = tracking\n\n // If no operations were performed, default to 200\n if (operations.length === 0) {\n return 200\n }\n\n // Priority order: get > update > delete > create > list\n // Check for get operations first (highest priority)\n const getOperation = operations.find((op) => op.operation === 'get')\n if (getOperation) {\n // Return 404 if get() returned undefined or null\n if (getOperation.result === undefined || getOperation.result === null) {\n return 404\n }\n return 200\n }\n\n // Check for update operations\n const updateOperation = operations.find((op) => op.operation === 'update')\n if (updateOperation) {\n // Return 404 if update() returned null (item not found)\n if (updateOperation.result === null || updateOperation.result === undefined) {\n return 404\n }\n return 200\n }\n\n // Check for delete operations\n const deleteOperation = operations.find((op) => op.operation === 'delete')\n if (deleteOperation) {\n // Return 404 if delete() returned null (item not found)\n if (deleteOperation.result === null || deleteOperation.result === undefined) {\n return 404\n }\n return 204\n }\n\n // Check for create operations\n const createOperation = operations.find((op) => op.operation === 'create')\n if (createOperation) {\n return 201\n }\n\n // Default to 200 for list or any other operation\n return 200\n}\n\n/**\n * Mock response using x-handler code.\n * Executes the handler and returns its result as the response.\n */\nexport async function mockHandlerResponse(\n c: Context,\n operation: OpenAPIV3_1.OperationObject,\n options: MockServerOptions,\n) {\n // Call onRequest callback\n if (options?.onRequest) {\n options.onRequest({\n context: c,\n operation,\n })\n }\n\n // Get x-handler code from operation\n const handlerCode = operation?.['x-handler']\n\n if (!handlerCode) {\n c.status(500)\n return c.json({ error: 'x-handler code not found in operation' })\n }\n\n try {\n // Build handler context with tracking\n const { context, tracking } = await buildHandlerContext(c, operation)\n\n // Execute handler\n const { result } = await executeHandler(handlerCode, context)\n\n // Determine status code based on all store operations, prioritizing semantically meaningful ones\n const statusCode = determineStatusCode(tracking)\n\n // Set status code\n c.status(statusCode)\n\n // For 204 No Content, return null body without Content-Type header\n if (statusCode === 204) {\n return c.body(null)\n }\n\n // Set Content-Type header for other responses\n c.header('Content-Type', 'application/json')\n\n // Return the handler result as JSON\n // Handle undefined/null results gracefully\n if (result === undefined || result === null) {\n // Try to pick up example response from OpenAPI spec if available\n const exampleResponse = getExampleFromResponse(\n c,\n statusCode,\n operation.responses as OpenAPIV3_1.ResponsesObject | undefined,\n )\n if (exampleResponse !== null) {\n return c.json(exampleResponse)\n }\n return c.json(null)\n }\n\n return c.json(result)\n } catch (error) {\n // Log error to console\n console.error('x-handler execution error:', error)\n\n // Return 500 error\n c.status(500)\n return c.json({\n error: 'Handler execution failed',\n message: error instanceof Error ? error.message : String(error),\n })\n }\n}\n"],
5
- "mappings": "AAAA,SAAS,4BAA4B;AAGrC,SAAS,eAAe;AAIxB,SAAS,2BAA2B;AACpC,SAAS,sBAAsB;AAM/B,SAAS,uBACP,GACA,YACA,WACK;AACL,MAAI,CAAC,WAAW;AACd,WAAO;AAAA,EACT;AAEA,QAAM,gBAAgB,WAAW,SAAS;AAC1C,QAAM,WAAW,UAAU,aAAa,KAAK,UAAU;AAEvD,MAAI,CAAC,UAAU;AACb,WAAO;AAAA,EACT;AAEA,QAAM,wBAAwB,OAAO,KAAK,SAAS,WAAW,CAAC,CAAC;AAGhE,MAAI,sBAAsB,WAAW,GAAG;AACtC,WAAO;AAAA,EACT;AAGA,QAAM,sBAAsB,QAAQ,GAAG;AAAA,IACrC,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Q,UAAU;AAAA,MAChB,SAAS;AAAA,MACT;AAAA,IACF,CAAC;AAAA,EACH;AAGA,QAAM,cAAc,YAAY,WAAW;AAE3C,MAAI,CAAC,aAAa;AAChB,MAAE,OAAO,GAAG;AACZ,WAAO,EAAE,KAAK,EAAE,OAAO,wCAAwC,CAAC;AAAA,EAClE;AAEA,MAAI;AAEF,UAAM,EAAE,SAAS,SAAS,IAAI,MAAM,oBAAoB,GAAG,SAAS;AAGpE,UAAM,EAAE,OAAO,IAAI,MAAM,eAAe,aAAa,OAAO;AAG5D,UAAM,aAAa,oBAAoB,QAAQ;AAG/C,MAAE,OAAO,UAAU;AAGnB,QAAI,eAAe,KAAK;AACtB,aAAO,EAAE,KAAK,IAAI;AAAA,IACpB;AAGA,MAAE,OAAO,gBAAgB,kBAAkB;AAI3C,QAAI,WAAW,UAAa,WAAW,MAAM;AAE3C,YAAM,kBAAkB;AAAA,QACtB;AAAA,QACA;AAAA,QACA,UAAU;AAAA,MACZ;AACA,UAAI,oBAAoB,MAAM;AAC5B,eAAO,EAAE,KAAK,eAAe;AAAA,MAC/B;AACA,aAAO,EAAE,KAAK,IAAI;AAAA,IACpB;AAEA,WAAO,EAAE,KAAK,MAAM;AAAA,EACtB,SAAS,OAAO;AAEd,YAAQ,MAAM,8BAA8B,KAAK;AAGjD,MAAE,OAAO,GAAG;AACZ,WAAO,EAAE,KAAK;AAAA,MACZ,OAAO;AAAA,MACP,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,IAChE,CAAC;AAAA,EACH;AACF;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/routes/respond-with-authorize-page.ts"],
4
- "sourcesContent": ["import type { Context } from 'hono'\n\n/** Always responds with this code */\nconst EXAMPLE_AUTHORIZATION_CODE = 'super-secret-token'\n/** Always responds with this token for implicit flow */\nconst EXAMPLE_ACCESS_TOKEN = 'super-secret-access-token'\n\n/**\n * Escapes HTML special characters to prevent XSS when rendering user-controlled scope values.\n */\nfunction escapeHtml(s: string): string {\n return s\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n .replace(/'/g, '&#39;')\n}\n\n/**\n * Parses the OAuth 2.0 scope query parameter (space- or +-separated) into an array of scope strings.\n */\nfunction parseScopeParam(scopeQuery: string | undefined): string[] {\n if (!scopeQuery || scopeQuery.trim() === '') {\n return []\n }\n return scopeQuery\n .split(/[\\s+]+/)\n .map((s) => s.trim())\n .filter(Boolean)\n}\n\n/**\n * Responds with an HTML page that simulates an OAuth 2.0 authorization page.\n */\nexport function respondWithAuthorizePage(c: Context, title = '') {\n const redirectUri = c.req.query('redirect_uri')\n const responseType = c.req.query('response_type')\n const scope = c.req.query('scope')\n const state = c.req.query('state')\n\n if (!redirectUri) {\n return c.html(\n generateErrorHtml(\n 'Missing redirect_uri parameter',\n 'This parameter is required for the OAuth 2.0 authorization flow to function correctly. Please provide a valid redirect URI in your request.',\n ),\n 400,\n )\n }\n\n try {\n // Validate redirect URI against allowed domains\n const redirectUrl = new URL(redirectUri)\n const isImplicitFlow = responseType === 'token'\n\n if (isImplicitFlow) {\n const fragmentParams = new URLSearchParams()\n fragmentParams.set('access_token', EXAMPLE_ACCESS_TOKEN)\n fragmentParams.set('token_type', 'Bearer')\n fragmentParams.set('expires_in', '3600')\n\n if (scope) {\n fragmentParams.set('scope', scope)\n }\n\n if (state) {\n fragmentParams.set('state', state)\n }\n\n redirectUrl.hash = fragmentParams.toString()\n } else {\n redirectUrl.searchParams.set('code', EXAMPLE_AUTHORIZATION_CODE)\n\n if (state) {\n redirectUrl.searchParams.set('state', state)\n }\n }\n\n const deniedUrl = new URL(redirectUri)\n if (isImplicitFlow) {\n const deniedFragmentParams = new URLSearchParams()\n deniedFragmentParams.set('error', 'access_denied')\n deniedFragmentParams.set('error_description', 'User has denied the authorization request')\n\n if (state) {\n deniedFragmentParams.set('state', state)\n }\n\n deniedUrl.hash = deniedFragmentParams.toString()\n } else {\n if (state) {\n deniedUrl.searchParams.set('state', state)\n }\n deniedUrl.searchParams.set('error', 'access_denied')\n deniedUrl.searchParams.set('error_description', 'User has denied the authorization request')\n }\n\n const scopes = parseScopeParam(c.req.query('scope'))\n const htmlContent = generateAuthorizationHtml(redirectUrl.toString(), deniedUrl.toString(), title, scopes)\n\n return c.html(htmlContent)\n } catch {\n return c.html(\n generateErrorHtml(\n 'Invalid redirect_uri format',\n 'Please provide a valid URL. The redirect_uri parameter must be a properly formatted URL that includes the protocol (e.g., https://) and a valid domain. This is essential for the OAuth 2.0 flow to securely redirect after authorization.',\n ),\n 400,\n )\n }\n}\n\nfunction generateAuthorizationHtml(redirectUrl: string, deniedUrl: string, title = '', scopes: string[] = []) {\n const scopesSection =\n scopes.length > 0\n ? `\n <p class=\"font-medium text-gray-700\">Requested Scopes</p>\n <ul class=\"list-disc list-inside space-y-1\">\n ${scopes.map((scope) => `<li><code class=\"bg-gray-100 py-1 px-2 rounded text-sm\">${escapeHtml(scope)}</code></li>`).join('\\n ')}\n </ul>`\n : ''\n\n return `\n<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>OAuth 2.0 Authorization</title>\n <script src=\"https://cdn.tailwindcss.com\"></script>\n </head>\n <body class=\"flex justify-center items-center h-screen bg-gray-100\">\n\n <div class=\"flex flex-col\">\n <div class=\"mb-5 flex justify-center items-center gap-2\">\n <img src=\"https://cdn.scalar.com/images/logo-dark.svg\" class=\"w-6 inline-block\" />\n <div class=\"font-medium truncate max-w-[26ch] text-lg\">\n ${escapeHtml(title)}\n </div>\n </div>\n <div class=\"bg-gray-50 rounded-lg p-1 rounded-lg w-[28rem] shadow\">\n <div class=\"\">\n <h1 class=\"text font-medium text-gray-800 px-6 pt-2 pb-3 flex gap-3 rounded-t-lg\">\n OAuth 2.0 Authorization\n </h1>\n <div class=\"bg-white rounded\">\n <div class=\"text-gray-600 text-base px-6 py-5 flex flex-col gap-3\">\n <p>\n This application is requesting access to your account. By granting authorization, you allow the application to perform certain actions on your behalf.\n </p>\n ${scopesSection}\n <p>\n If you're comfortable with the access being requested, click the button below to grant authorization:\n </p>\n </div>\n <div class=\"px-6 py-4 pt-0 flex justify-between\">\n <a href=\"${deniedUrl}\" class=\"inline-block px-6 py-2 text-gray-600 rounded border\" aria-label=\"Cancel authorization\">\n Cancel\n </a>\n <a href=\"${redirectUrl}\" class=\"inline-block px-6 py-2 bg-black text-white rounded transition-colors duration-300 hover:bg-gray-800\" aria-label=\"Authorize application\">\n Authorize\n </a>\n </div>\n </div>\n </div>\n </div>\n\n <p class=\"text-xs text-gray-400 mt-5 text-center\">\n This authorization page is provided by the <a href=\"https://scalar.com/products/mock-server/getting-started\" target=\"_blank\" class=\"underline text-gray-600 hover:text-gray-800\">Scalar Mock Server</a>.\n </p>\n\n </div>\n </body>\n</html>\n `\n}\n\nfunction generateErrorHtml(title: string, message: string) {\n return `<html>\n <html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>OAuth 2.0 Authorization</title>\n <script src=\"https://cdn.tailwindcss.com\"></script>\n </head>\n <body>\n <div class=\"p-4 m-8 flex flex-col gap-4 text-lg\">\n <h1 class=\"font-bold\">\n Error: ${title}\n </h1>\n <p>\n ${message}\n </p>\n <p>\n Example: <code class=\"bg-gray-100 py-1 px-2 rounded text-base\"><a href=\"?redirect_uri=https://example.com/callback\">?redirect_uri=https://example.com/callback</a></code>\n </p>\n </div>\n </body>\n</html>`\n}\n"],
5
- "mappings": "AAGA,MAAM,6BAA6B;AAEnC,MAAM,uBAAuB;AAK7B,SAAS,WAAW,GAAmB;AACrC,SAAO,EACJ,QAAQ,MAAM,OAAO,EACrB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,QAAQ,EAC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zD,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAWQ,KAAK;AAAA;AAAA;AAAA,UAGZ,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQjB;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/routes/respond-with-openapi-document.ts"],
4
- "sourcesContent": ["import { normalize, toYaml } from '@scalar/openapi-parser'\nimport type { Context } from 'hono'\n\n/**\n * OpenAPI endpoints\n */\nexport function respondWithOpenApiDocument(\n c: Context,\n input?: string | Record<string, any>,\n format: 'json' | 'yaml' = 'json',\n) {\n if (!input) {\n return c.text('Not found', 404)\n }\n\n try {\n const document = normalize(input)\n\n // JSON\n if (format === 'json') {\n return c.json(document)\n }\n\n // YAML\n try {\n const yamlDocument = toYaml(normalize(document))\n\n c.header('Content-Type', 'text/yaml')\n return c.text(yamlDocument, 200, {\n 'Content-Type': 'application/yaml; charset=UTF-8',\n })\n } catch (error) {\n return c.json(\n {\n error: 'Failed to convert document to YAML',\n message: error instanceof Error ? error.message : 'Unknown error occurred',\n },\n 500,\n )\n }\n } catch (error) {\n return c.json(\n {\n error: 'Failed to parse OpenAPI document',\n message: error instanceof Error ? error.message : 'Unknown error occurred',\n },\n 400,\n )\n }\n}\n"],
5
- "mappings": "AAAA,SAAS,WAAW,cAAc;AAM3B,SAAS,2BACd,GACA,OACA,SAA0B,QAC1B;AACA,MAAI,CAAC,OAAO;AACV,WAAO,EAAE,KAAK,aAAa,GAAG;AAAA,EAChC;AAEA,MAAI;AACF,UAAM,WAAW,UAAU,KAAK;AAGhC,QAAI,WAAW,QAAQ;AACrB,aAAO,EAAE,KAAK,QAAQ;AAAA,IACxB;AAGA,QAAI;AACF,YAAM,eAAe,OAAO,UAAU,QAAQ,CAAC;AAE/C,QAAE,OAAO,gBAAgB,WAAW;AACpC,aAAO,EAAE,KAAK,cAAc,KAAK;AAAA,QAC/B,gBAAgB;AAAA,MAClB,CAAC;AAAA,IACH,SAAS,OAAO;AACd,aAAO,EAAE;AAAA,QACP;AAAA,UACE,OAAO;AAAA,UACP,SAAS,iBAAiB,QAAQ,MAAM,UAAU;AAAA,QACpD;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF,SAAS,OAAO;AACd,WAAO,EAAE;AAAA,MACP;AAAA,QACE,OAAO;AAAA,QACP,SAAS,iBAAiB,QAAQ,MAAM,UAAU;AAAA,MACpD;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/routes/respond-with-token.ts"],
4
- "sourcesContent": ["import type { Context } from 'hono'\n\n/** Always responds with this token */\nconst EXAMPLE_ACCESS_TOKEN = 'super-secret-access-token'\n\n/**\n * Responds with a JSON object simulating an OAuth 2.0 token response.\n */\nexport function respondWithToken(c: Context) {\n const grantType = c.req.query('grant_type')\n\n if (!grantType) {\n return c.json(\n {\n error: 'invalid_request',\n error_description: 'Missing grant_type parameter',\n },\n 400,\n )\n }\n\n // Validate supported grant types\n const supportedGrantTypes = ['authorization_code', 'client_credentials', 'refresh_token']\n\n if (!supportedGrantTypes.includes(grantType)) {\n return c.json(\n {\n error: 'unsupported_grant_type',\n error_description: `Grant type must be one of: ${supportedGrantTypes.join(', ')}`,\n },\n 400,\n )\n }\n\n // Validate required parameters for each grant type\n if (grantType === 'authorization_code' && !c.req.query('code')) {\n return c.json(\n {\n error: 'invalid_request',\n error_description: 'Missing code parameter',\n },\n 400,\n )\n }\n\n // Simulate token generation\n const tokenResponse = {\n access_token: EXAMPLE_ACCESS_TOKEN,\n token_type: 'Bearer',\n expires_in: 3600,\n refresh_token: 'example-refresh-token',\n scope: c.req.query('scope') ?? 'read write',\n }\n\n // Security headers\n c.header('Cache-Control', 'no-store')\n c.header('Pragma', 'no-cache')\n\n return c.json(tokenResponse)\n}\n"],
5
- "mappings": "AAGA,MAAM,uBAAuB;AAKtB,SAAS,iBAAiB,GAAY;AAC3C,QAAM,YAAY,EAAE,IAAI,MAAM,YAAY;AAE1C,MAAI,CAAC,WAAW;AACd,WAAO,EAAE;AAAA,MACP;AAAA,QACE,OAAO;AAAA,QACP,mBAAmB;AAAA,MACrB;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAGA,QAAM,sBAAsB,CAAC,sBAAsB,sBAAsB,eAAe;AAExF,MAAI,CAAC,oBAAoB,SAAS,SAAS,GAAG;AAC5C,WAAO,EAAE;AAAA,MACP;AAAA,QACE,OAAO;AAAA,QACP,mBAAmB,8BAA8B,oBAAoB,KAAK,IAAI,CAAC;AAAA,MACjF;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAGA,MAAI,cAAc,wBAAwB,CAAC,EAAE,IAAI,MAAM,MAAM,GAAG;AAC9D,WAAO,EAAE;AAAA,MACP;AAAA,QACE,OAAO;AAAA,QACP,mBAAmB;AAAA,MACrB;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAGA,QAAM,gBAAgB;AAAA,IACpB,cAAc;AAAA,IACd,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,OAAO,EAAE,IAAI,MAAM,OAAO,KAAK;AAAA,EACjC;AAGA,IAAE,OAAO,iBAAiB,UAAU;AACpC,IAAE,OAAO,UAAU,UAAU;AAE7B,SAAO,EAAE,KAAK,aAAa;AAC7B;",
6
- "names": []
7
- }
package/dist/types.js.map DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/types.ts"],
4
- "sourcesContent": ["import type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport type { Context } from 'hono'\n\n/** Available HTTP methods for Hono routes */\nexport const httpMethods = ['get', 'put', 'post', 'delete', 'options', 'patch'] as const\n\n/** Valid HTTP method */\nexport type HttpMethod = (typeof httpMethods)[number]\n\n/**\n * Represents a partial object where at least one of the given properties is required.\n */\ntype RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> &\n {\n [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>\n }[Keys]\n\ntype BaseMockServerOptions = {\n /**\n * The OpenAPI document to use for mocking.\n * Can be a string (URL or file path) or an object.\n *\n * @deprecated Use `document` instead\n */\n specification?: string | Record<string, any>\n\n /**\n * The OpenAPI document to use for mocking.\n * Can be a string (URL or file path) or an object.\n */\n document?: string | Record<string, any>\n\n /**\n * Callback function to be called before each request is processed.\n */\n onRequest?: (data: { context: Context; operation: OpenAPIV3_1.OperationObject }) => void\n}\n\nexport type MockServerOptions = RequireAtLeastOne<BaseMockServerOptions, 'specification' | 'document'>\n"],
5
- "mappings": "AAIO,MAAM,cAAc,CAAC,OAAO,OAAO,QAAQ,UAAU,WAAW,OAAO;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/build-handler-context.ts"],
4
- "sourcesContent": ["import { faker } from '@faker-js/faker'\nimport { getExampleFromSchema } from '@scalar/oas-utils/spec-getters'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport type { Context } from 'hono'\nimport { accepts } from 'hono/accepts'\n\nimport { store } from '../libs/store'\nimport { type StoreOperationTracking, createStoreWrapper } from './store-wrapper'\n\n/**\n * Context object provided to x-handler code.\n */\nexport type HandlerContext = {\n store: ReturnType<typeof createStoreWrapper>['wrappedStore']\n faker: typeof faker\n req: {\n body: any\n params: Record<string, string>\n query: Record<string, string>\n headers: Record<string, string>\n }\n res: Record<string, any>\n}\n\n/**\n * Result of building handler context, including operation tracking.\n */\ntype HandlerContextResult = {\n context: HandlerContext\n tracking: StoreOperationTracking\n}\n\n/**\n * Get example response from OpenAPI spec for a given status code.\n * Returns the example value if found, or null if not available.\n */\nfunction getExampleFromResponse(\n c: Context,\n statusCode: string,\n responses: OpenAPIV3_1.ResponsesObject | undefined,\n): any {\n if (!responses) {\n return null\n }\n\n const response = responses[statusCode] || responses.default\n\n if (!response) {\n return null\n }\n\n const supportedContentTypes = Object.keys(response.content ?? {})\n\n // If no content types are defined, return null\n if (supportedContentTypes.length === 0) {\n return null\n }\n\n // Content-Type negotiation - prefer application/json\n const acceptedContentType = accepts(c, {\n header: 'Accept',\n supports: supportedContentTypes,\n default: supportedContentTypes.includes('application/json')\n ? 'application/json'\n : (supportedContentTypes[0] ?? 'text/plain;charset=UTF-8'),\n })\n\n const acceptedResponse = response.content?.[acceptedContentType]\n\n if (!acceptedResponse) {\n return null\n }\n\n // Extract example from example property or generate from schema\n return acceptedResponse.example !== undefined\n ? acceptedResponse.example\n : acceptedResponse.schema\n ? getExampleFromSchema(acceptedResponse.schema, {\n emptyString: 'string',\n variables: c.req.param(),\n mode: 'read',\n })\n : null\n}\n\n/**\n * Build the handler context from a Hono context.\n */\nexport async function buildHandlerContext(\n c: Context,\n operation?: OpenAPIV3_1.OperationObject,\n): Promise<HandlerContextResult> {\n let body: any = undefined\n\n try {\n const contentType = c.req.header('content-type') ?? ''\n if (contentType.includes('application/json')) {\n body = await c.req.json().catch(() => undefined)\n } else if (contentType.includes('application/x-www-form-urlencoded')) {\n body = await c.req.parseBody().catch(() => undefined)\n } else if (contentType.includes('text/')) {\n body = await c.req.text().catch(() => undefined)\n }\n } catch {\n // Ignore parsing errors, body remains undefined\n }\n\n const { wrappedStore, tracking } = createStoreWrapper(store)\n\n // Build res object with examples for all response status codes\n const res: Record<string, any> = {}\n if (operation?.responses) {\n for (const statusCode of Object.keys(operation.responses)) {\n res[statusCode] = getExampleFromResponse(\n c,\n statusCode,\n operation.responses as OpenAPIV3_1.ResponsesObject | undefined,\n )\n }\n }\n\n return {\n context: {\n store: wrappedStore,\n faker,\n req: {\n body,\n params: c.req.param(),\n query: Object.fromEntries(new URL(c.req.url).searchParams.entries()),\n headers: Object.fromEntries(Object.entries(c.req.header()).map(([key, value]) => [key, value ?? ''])),\n },\n res,\n },\n tracking,\n }\n}\n"],
5
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,MAAS;AAAA,IACjD;AAAA,EACF,QAAQ;AAAA,EAER;AAEA,QAAM,EAAE,cAAc,SAAS,IAAI,mBAAmB,KAAK;AAG3D,QAAM,MAA2B,CAAC;AAClC,MAAI,WAAW,WAAW;AACxB,eAAW,cAAc,OAAO,KAAK,UAAU,SAAS,GAAG;AACzD,UAAI,UAAU,IAAI;AAAA,QAChB;AAAA,QACA;AAAA,QACA,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,SAAS;AAAA,MACP,OAAO;AAAA,MACP;AAAA,MACA,KAAK;AAAA,QACH;AAAA,QACA,QAAQ,EAAE,IAAI,MAAM;AAAA,QACpB,OAAO,OAAO,YAAY,IAAI,IAAI,EAAE,IAAI,GAAG,EAAE,aAAa,QAAQ,CAAC;AAAA,QACnE,SAAS,OAAO,YAAY,OAAO,QAAQ,EAAE,IAAI,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,SAAS,EAAE,CAAC,CAAC;AAAA,MACtG;AAAA,MACA;AAAA,IACF;AAAA,IACA;AAAA,EACF;AACF;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/build-seed-context.ts"],
4
- "sourcesContent": ["import { faker } from '@faker-js/faker'\n\nimport { store } from '../libs/store'\nimport { createStoreWrapper } from './store-wrapper'\n\n/**\n * Seed helper function type.\n */\ntype SeedHelper = {\n /**\n * Create n items using a factory function.\n */\n count: (n: number, factory: () => any) => any[]\n /**\n * Create items from an array of objects.\n */\n (items: any[]): any[]\n /**\n * Create a single item using a factory function (shorthand for count(1, factory)).\n */\n (factory: () => any): any\n}\n\n/**\n * Context object provided to x-seed code.\n */\nexport type SeedContext = {\n store: ReturnType<typeof createStoreWrapper>['wrappedStore']\n faker: typeof faker\n seed: SeedHelper\n schema: string\n}\n\n/**\n * Build the seed context with a seed helper function.\n * The seed helper automatically uses the schema key as the collection name.\n */\nexport function buildSeedContext(schemaKey: string): SeedContext {\n const { wrappedStore } = createStoreWrapper(store)\n\n /**\n * Seed helper function that provides a Laravel-inspired API.\n */\n const seedHelper = ((arg1: number | any[] | (() => any), arg2?: () => any) => {\n // Case 1: seed.count(n, factory)\n if (typeof arg1 === 'number' && typeof arg2 === 'function') {\n const count = arg1\n const factory = arg2\n const items: any[] = []\n\n for (let i = 0; i < count; i++) {\n const item = factory()\n const created = wrappedStore.create(schemaKey, item)\n items.push(created)\n }\n\n return items\n }\n\n // Case 2: seed(array)\n if (Array.isArray(arg1)) {\n const items: any[] = []\n\n for (const item of arg1) {\n const created = wrappedStore.create(schemaKey, item)\n items.push(created)\n }\n\n return items\n }\n\n // Case 3: seed(factory) - single item\n if (typeof arg1 === 'function') {\n const factory = arg1\n const item = factory()\n const created = wrappedStore.create(schemaKey, item)\n return created\n }\n\n throw new Error('Invalid seed() usage. Use seed.count(n, factory), seed(array), or seed(factory)')\n }) as SeedHelper\n\n // Add count method to the function\n seedHelper.count = (n: number, factory: () => any) => {\n const items: any[] = []\n\n for (let i = 0; i < n; i++) {\n const item = factory()\n const created = wrappedStore.create(schemaKey, item)\n items.push(created)\n }\n\n return items\n }\n\n return {\n store: wrappedStore,\n faker,\n seed: seedHelper,\n schema: schemaKey,\n }\n}\n"],
5
- "mappings": "AAAA,SAAS,aAAa;AAEtB,SAAS,aAAa;AACtB,SAAS,0BAA0B;AAkC5B,SAAS,iBAAiB,WAAgC;AAC/D,QAAM,EAAE,aAAa,IAAI,mBAAmB,KAAK;AAKjD,QAAM,aAAc,CAAC,MAAoC,SAAqB;AAE5E,QAAI,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;AAC1D,YAAM,QAAQ;AACd,YAAM,UAAU;AAChB,YAAM,QAAe,CAAC;AAEtB,eAAS,IAAI,GAAG,IAAI,OAAO,KAAK;AAC9B,cAAM,OAAO,QAAQ;AACrB,cAAM,UAAU,aAAa,OAAO,WAAW,IAAI;AACnD,cAAM,KAAK,OAAO;AAAA,MACpB;AAEA,aAAO;AAAA,IACT;AAGA,QAAI,MAAM,QAAQ,IAAI,GAAG;AACvB,YAAM,QAAe,CAAC;AAEtB,iBAAW,QAAQ,MAAM;AACvB,cAAM,UAAU,aAAa,OAAO,WAAW,IAAI;AACnD,cAAM,KAAK,OAAO;AAAA,MACpB;AAEA,aAAO;AAAA,IACT;AAGA,QAAI,OAAO,SAAS,YAAY;AAC9B,YAAM,UAAU;AAChB,YAAM,OAAO,QAAQ;AACrB,YAAM,UAAU,aAAa,OAAO,WAAW,IAAI;AACnD,aAAO;AAAA,IACT;AAEA,UAAM,IAAI,MAAM,iFAAiF;AAAA,EACnG;AAGA,aAAW,QAAQ,CAAC,GAAW,YAAuB;AACpD,UAAM,QAAe,CAAC;AAEtB,aAAS,IAAI,GAAG,IAAI,GAAG,KAAK;AAC1B,YAAM,OAAO,QAAQ;AACrB,YAAM,UAAU,aAAa,OAAO,WAAW,IAAI;AACnD,YAAM,KAAK,OAAO;AAAA,IACpB;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL,OAAO;AAAA,IACP;AAAA,IACA,MAAM;AAAA,IACN,QAAQ;AAAA,EACV;AACF;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/create-openapi-definition.ts"],
4
- "sourcesContent": ["import type { OpenAPIV3, OpenAPIV3_1 } from '@scalar/openapi-types'\n\n/** Helper function create an OpenAPI document with security schemss */\nexport function createOpenApiDefinition(\n securitySchemes: Record<string, OpenAPIV3.SecuritySchemeObject | OpenAPIV3_1.SecuritySchemeObject>,\n): OpenAPIV3_1.Document {\n return {\n openapi: '3.1.1',\n info: { title: 'Test API', version: '1.0.0' },\n components: { securitySchemes },\n }\n}\n"],
5
- "mappings": "AAGO,SAAS,wBACd,iBACsB;AACtB,SAAO;AAAA,IACL,SAAS;AAAA,IACT,MAAM,EAAE,OAAO,YAAY,SAAS,QAAQ;AAAA,IAC5C,YAAY,EAAE,gBAAgB;AAAA,EAChC;AACF;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/execute-handler.ts"],
4
- "sourcesContent": ["import type { HandlerContext } from './build-handler-context'\n\n/**\n * Result of executing a handler, including the result and operation tracking.\n */\ntype HandlerExecutionResult = {\n result: any\n}\n\n/**\n * Execute handler code in a sandboxed environment.\n * The code has access only to the provided context (store, faker, req, res).\n */\nexport async function executeHandler(code: string, context: HandlerContext): Promise<HandlerExecutionResult> {\n // Create a function that executes the handler code with the context\n // Using Function constructor to create a sandboxed environment\n // The code is wrapped in a function body that returns the result\n const handlerFunction = new Function(\n 'store',\n 'faker',\n 'req',\n 'res',\n `\n ${code}\n `,\n )\n const result = handlerFunction(context.store, context.faker, context.req, context.res)\n\n // If the result is a Promise, await it\n if (result instanceof Promise) {\n return { result: await result }\n }\n\n return { result }\n}\n"],
5
- "mappings": "AAaA,eAAsB,eAAe,MAAc,SAA0D;AAI3G,QAAM,kBAAkB,IAAI;AAAA,IAC1B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,IAAI;AAAA;AAAA,EAER;AACA,QAAM,SAAS,gBAAgB,QAAQ,OAAO,QAAQ,OAAO,QAAQ,KAAK,QAAQ,GAAG;AAGrF,MAAI,kBAAkB,SAAS;AAC7B,WAAO,EAAE,QAAQ,MAAM,OAAO;AAAA,EAChC;AAEA,SAAO,EAAE,OAAO;AAClB;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/execute-seed.ts"],
4
- "sourcesContent": ["import type { SeedContext } from './build-seed-context'\n\n/**\n * Result of executing a seed handler.\n */\ntype SeedExecutionResult = {\n result: any\n}\n\n/**\n * Execute seed code in a sandboxed environment.\n * The code has access only to the provided context (store, faker, seed, schema).\n */\nexport async function executeSeed(code: string, context: SeedContext): Promise<SeedExecutionResult> {\n // Create a function that executes the seed code with the context\n // Using Function constructor to create a sandboxed environment\n // The code is wrapped in a function body that returns the result\n const seedFunction = new Function(\n 'store',\n 'faker',\n 'seed',\n 'schema',\n `\n ${code}\n `,\n )\n\n // Execute the seed function with the context\n try {\n const result = seedFunction(context.store, context.faker, context.seed, context.schema)\n\n // If the result is a Promise, await it\n if (result instanceof Promise) {\n return { result: await result }\n }\n\n return { result }\n } catch (error) {\n // Re-throw to be caught by the caller\n throw error\n }\n}\n"],
5
- "mappings": "AAaA,eAAsB,YAAY,MAAc,SAAoD;AAIlG,QAAM,eAAe,IAAI;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,IAAI;AAAA;AAAA,EAER;AAGA,MAAI;AACF,UAAM,SAAS,aAAa,QAAQ,OAAO,QAAQ,OAAO,QAAQ,MAAM,QAAQ,MAAM;AAGtF,QAAI,kBAAkB,SAAS;AAC7B,aAAO,EAAE,QAAQ,MAAM,OAAO;AAAA,IAChC;AAEA,WAAO,EAAE,OAAO;AAAA,EAClB,SAAS,OAAO;AAEd,UAAM;AAAA,EACR;AACF;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/find-preferred-response-key.ts"],
4
- "sourcesContent": ["/**\n * Find the preferred response key: default, 200, 201 \u2026\n */\nexport function findPreferredResponseKey(responses?: string[]) {\n return (\n // Regular status codes\n ['default', '200', '201', '204', '404', '500'].find((key) => responses?.includes(key) ?? false) ??\n // Lowest status code\n responses?.sort()[0] ??\n undefined\n )\n}\n"],
5
- "mappings": "AAGO,SAAS,yBAAyB,WAAsB;AAC7D;AAAA;AAAA,IAEE,CAAC,WAAW,OAAO,OAAO,OAAO,OAAO,KAAK,EAAE,KAAK,CAAC,QAAQ,WAAW,SAAS,GAAG,KAAK,KAAK;AAAA,IAE9F,WAAW,KAAK,EAAE,CAAC,KACnB;AAAA;AAEJ;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/get-open-auth-token-urls.ts"],
4
- "sourcesContent": ["import type { OpenAPI, OpenAPIV3, OpenAPIV3_1 } from '@scalar/openapi-types'\n\n/**\n * Extract path from URL\n */\nexport function getPathFromUrl(url: string): string {\n try {\n // Handle relative URLs by prepending a base\n const urlObject = url.startsWith('http') ? new URL(url) : new URL(url, 'http://example.com')\n\n // Normalize: remove trailing slash except for root path\n const path = urlObject.pathname\n return path === '/' ? path : path.replace(/\\/$/, '')\n } catch {\n // If URL is invalid, return the original string\n return url\n }\n}\n\n/**\n * Returns all token URLs mentioned in the securitySchemes, without the domain\n */\n// Type guard for OAuth2 security scheme\nfunction isOAuth2Scheme(\n scheme: OpenAPIV3.SecuritySchemeObject | OpenAPIV3_1.SecuritySchemeObject,\n): scheme is OpenAPIV3.OAuth2SecurityScheme | OpenAPIV3_1.OAuth2SecurityScheme {\n return scheme.type === 'oauth2'\n}\n\n// Validate token URL\nfunction isValidTokenUrl(url: string): boolean {\n return url.trim().length > 0\n}\n\nexport function getOpenAuthTokenUrls(schema?: OpenAPI.Document): string[] {\n if (!schema?.components?.securitySchemes) {\n return []\n }\n\n const securitySchemes: Record<string, OpenAPIV3.SecuritySchemeObject | OpenAPIV3_1.SecuritySchemeObject> =\n schema.components.securitySchemes\n\n // Use Set from the start for better memory efficiency\n const tokenUrls = new Set<string>()\n\n // Iterate through all security schemes\n for (const scheme of Object.values(securitySchemes)) {\n if (!isOAuth2Scheme(scheme)) {\n continue\n }\n\n const flows = scheme.flows // Type assertion no longer needed\n\n // Helper to safely add valid token URLs\n const addTokenUrl = (url?: string) => {\n if (url && isValidTokenUrl(url)) {\n tokenUrls.add(getPathFromUrl(url))\n }\n }\n\n addTokenUrl(flows?.password?.tokenUrl)\n addTokenUrl(flows?.clientCredentials?.tokenUrl)\n addTokenUrl(flows?.authorizationCode?.tokenUrl)\n }\n\n return Array.from(tokenUrls)\n}\n"],
5
- "mappings": "AAKO,SAAS,eAAe,KAAqB;AAClD,MAAI;AAEF,UAAM,YAAY,IAAI,WAAW,MAAM,IAAI,IAAI,IAAI,GAAG,IAAI,IAAI,IAAI,KAAK,oBAAoB;AAG3F,UAAM,OAAO,UAAU;AACvB,WAAO,SAAS,MAAM,OAAO,KAAK,QAAQ,OAAO,EAAE;AAAA,EACrD,QAAQ;AAEN,WAAO;AAAA,EACT;AACF;AAMA,SAAS,eACP,QAC6E;AAC7E,SAAO,OAAO,SAAS;AACzB;AAGA,SAAS,gBAAgB,KAAsB;AAC7C,SAAO,IAAI,KAAK,EAAE,SAAS;AAC7B;AAEO,SAAS,qBAAqB,QAAqC;AACxE,MAAI,CAAC,QAAQ,YAAY,iBAAiB;AACxC,WAAO,CAAC;AAAA,EACV;AAEA,QAAM,kBACJ,OAAO,WAAW;AAGpB,QAAM,YAAY,oBAAI,IAAY;AAGlC,aAAW,UAAU,OAAO,OAAO,eAAe,GAAG;AACnD,QAAI,CAAC,eAAe,MAAM,GAAG;AAC3B;AAAA,IACF;AAEA,UAAM,QAAQ,OAAO;AAGrB,UAAM,cAAc,CAAC,QAAiB;AACpC,UAAI,OAAO,gBAAgB,GAAG,GAAG;AAC/B,kBAAU,IAAI,eAAe,GAAG,CAAC;AAAA,MACnC;AAAA,IACF;AAEA,gBAAY,OAAO,UAAU,QAAQ;AACrC,gBAAY,OAAO,mBAAmB,QAAQ;AAC9C,gBAAY,OAAO,mBAAmB,QAAQ;AAAA,EAChD;AAEA,SAAO,MAAM,KAAK,SAAS;AAC7B;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/get-operation.ts"],
4
- "sourcesContent": ["import type { OpenAPIV3_1 } from '@scalar/openapi-types'\n\nimport { type HttpMethod, httpMethods } from '@/types'\n\n/**\n * Takes a dereferenced OpenAPI document and returns all operations.\n * Ignores other attributes, like summary, parameters, etc.\n */\nexport function getOperations(path?: OpenAPIV3_1.PathItemObject): Record<HttpMethod, OpenAPIV3_1.OperationObject> {\n const operations = {} as Record<HttpMethod, OpenAPIV3_1.OperationObject>\n\n for (const method of httpMethods) {\n if (path?.[method]) {\n operations[method] = path?.[method]\n }\n }\n\n return operations\n}\n"],
5
- "mappings": "AAEA,SAA0B,mBAAmB;AAMtC,SAAS,cAAc,MAAoF;AAChH,QAAM,aAAa,CAAC;AAEpB,aAAW,UAAU,aAAa;AAChC,QAAI,OAAO,MAAM,GAAG;AAClB,iBAAW,MAAM,IAAI,OAAO,MAAM;AAAA,IACpC;AAAA,EACF;AAEA,SAAO;AACT;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/handle-authentication.ts"],
4
- "sourcesContent": ["import type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport type { Context } from 'hono'\nimport { getCookie } from 'hono/cookie'\n\n/**\n * Handles authentication for incoming requests based on the OpenAPI document.\n */\nexport function handleAuthentication(schema?: OpenAPIV3_1.Document, operation?: OpenAPIV3_1.OperationObject) {\n return async (c: Context, next: () => Promise<void>): Promise<Response | void> => {\n const operationSecuritySchemes = operation?.security || schema?.security\n\n if (operationSecuritySchemes && operationSecuritySchemes.length > 0) {\n let isAuthenticated = false\n let authScheme = ''\n\n for (const securityRequirement of operationSecuritySchemes) {\n let securitySchemeAuthenticated = true\n\n for (const [schemeName] of Object.entries(securityRequirement)) {\n const scheme = schema?.components?.securitySchemes?.[schemeName]\n\n // Skip if scheme is a reference object (should be dereferenced already, but check to be safe)\n if (scheme && '$ref' in scheme) {\n continue\n }\n\n if (scheme && 'type' in scheme) {\n const securityScheme = scheme as OpenAPIV3_1.SecuritySchemeObject\n\n switch (securityScheme.type) {\n case 'http':\n if ('scheme' in securityScheme && securityScheme.scheme === 'basic') {\n authScheme = 'Basic'\n const authHeader = c.req.header('Authorization')\n\n if (authHeader?.startsWith('Basic ')) {\n isAuthenticated = true\n }\n } else if ('scheme' in securityScheme && securityScheme.scheme === 'bearer') {\n authScheme = 'Bearer'\n const authHeader = c.req.header('Authorization')\n\n if (authHeader?.startsWith('Bearer ')) {\n isAuthenticated = true\n }\n }\n break\n case 'apiKey':\n if ('name' in securityScheme && 'in' in securityScheme && securityScheme.name) {\n authScheme = `ApiKey ${securityScheme.name}`\n\n if (securityScheme.in === 'header') {\n const apiKey = c.req.header(securityScheme.name)\n if (apiKey) {\n isAuthenticated = true\n }\n } else if (securityScheme.in === 'query') {\n const apiKey = c.req.query(securityScheme.name)\n\n if (apiKey) {\n isAuthenticated = true\n }\n } else if (securityScheme.in === 'cookie') {\n const apiKey = getCookie(c, securityScheme.name)\n\n if (apiKey) {\n isAuthenticated = true\n }\n }\n }\n break\n case 'oauth2':\n authScheme = 'Bearer'\n // Handle OAuth 2.0 flows, including password grant\n if (c.req.header('Authorization')?.startsWith('Bearer ')) {\n isAuthenticated = true\n }\n break\n case 'openIdConnect':\n authScheme = 'Bearer'\n // Handle OpenID Connect similar to OAuth2\n if (c.req.header('Authorization')?.startsWith('Bearer ')) {\n isAuthenticated = true\n }\n break\n }\n }\n\n if (!isAuthenticated) {\n securitySchemeAuthenticated = false\n break\n }\n }\n\n if (securitySchemeAuthenticated) {\n isAuthenticated = true\n break\n }\n }\n\n if (!isAuthenticated) {\n let wwwAuthenticateValue = authScheme\n\n if (authScheme.startsWith('ApiKey')) {\n wwwAuthenticateValue += ` realm=\"Scalar Mock Server\", error=\"invalid_token\", error_description=\"Invalid or missing API key\"`\n } else {\n switch (authScheme) {\n case 'Basic':\n wwwAuthenticateValue += ' realm=\"Scalar Mock Server\", charset=\"UTF-8\"'\n break\n case 'Bearer':\n wwwAuthenticateValue +=\n ' realm=\"Scalar Mock Server\", error=\"invalid_token\", error_description=\"The access token is invalid or has expired\"'\n break\n default:\n wwwAuthenticateValue = 'Bearer realm=\"Scalar Mock Server\"'\n }\n }\n\n c.header('WWW-Authenticate', wwwAuthenticateValue)\n return c.json(\n {\n error: 'Unauthorized',\n message: 'Authentication is required to access this resource.',\n },\n 401,\n )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E,IAAI,MAAM,eAAe,IAAI;AAE9C,wBAAI,QAAQ;AACV,wCAAkB;AAAA,oBACpB;AAAA,kBACF,WAAW,eAAe,OAAO,UAAU;AACzC,0BAAM,SAAS,UAAU,GAAG,eAAe,IAAI;AAE/C,wBAAI,QAAQ;AACV,wCAAkB;AAAA,oBACpB;AAAA,kBACF;AAAA,gBACF;AACA;AAAA,cACF,KAAK;AACH,6BAAa;AAEb,oBAAI,EAAE,IAAI,OAAO,eAAe,GAAG,WAAW,SAAS,GAAG;AACxD,oCAAkB;AAAA,gBACpB;AACA;AAAA,cACF,KAAK;AACH,6BAAa;AAEb,oBAAI,EAAE,IAAI,OAAO,eAAe,GAAG,WAAW,SAAS,GAAG;AACxD,oCAAkB;AAAA,gBACpB;AACA;AAAA,YACJ;AAAA,UACF;AAEA,cAAI,CAAC,iBAAiB;AACpB,0CAA8B;AAC9B;AAAA,UACF;AAAA,QACF;AAEA,YAAI,6BAA6B;AAC/B,4BAAkB;AAClB;AAAA,QACF;AAAA,MACF;AAEA,UAAI,CAAC,iBAAiB;AACpB,YAAI,uBAAuB;AAE3B,YAAI,WAAW,WAAW,QAAQ,GAAG;AACnC,kCAAwB;AAAA,QAC1B,OAAO;AACL,kBAAQ,YAAY;AAAA,YAClB,KAAK;AACH,sCAAwB;AACxB;AAAA,YACF,KAAK;AACH,sCACE;AACF;AAAA,YACF;AACE,qCAAuB;AAAA,UAC3B;AAAA,QACF;AAEA,UAAE,OAAO,oBAAoB,oBAAoB;AACjD,eAAO,EAAE;AAAA,UACP;AAAA,YACE,OAAO;AAAA,YACP,SAAS;AAAA,UACX;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAGA,UAAM,KAAK;AAAA,EACb;AACF;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/hono-route-from-path.ts"],
4
- "sourcesContent": ["/**\n * Convert path to route\n * Example: /posts/{id} -> /posts/:id\n */\nexport function honoRouteFromPath(path: string) {\n return path.replace(/{/g, ':').replace(/}/g, '')\n}\n"],
5
- "mappings": "AAIO,SAAS,kBAAkB,MAAc;AAC9C,SAAO,KAAK,QAAQ,MAAM,GAAG,EAAE,QAAQ,MAAM,EAAE;AACjD;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/is-authentication-required.ts"],
4
- "sourcesContent": ["import type { OpenAPIV3 } from '@scalar/openapi-types'\n\n/**\n * Check whether the given security scheme key is in the `security` configuration for this operation.\n */\nexport function isAuthenticationRequired(security?: OpenAPIV3.SecurityRequirementObject[]): boolean {\n // If security is not defined, auth is not required.\n if (!security) {\n return false\n }\n\n // Don't require auth if security is just an empty array []\n if (Array.isArray(security) && !security.length) {\n return false\n }\n\n // Includes empty object = auth is not required\n if ((security ?? []).some((securityRequirement) => !Object.keys(securityRequirement).length)) {\n return false\n }\n\n return true\n}\n"],
5
- "mappings": "AAKO,SAAS,yBAAyB,UAA2D;AAElG,MAAI,CAAC,UAAU;AACb,WAAO;AAAA,EACT;AAGA,MAAI,MAAM,QAAQ,QAAQ,KAAK,CAAC,SAAS,QAAQ;AAC/C,WAAO;AAAA,EACT;AAGA,OAAK,YAAY,CAAC,GAAG,KAAK,CAAC,wBAAwB,CAAC,OAAO,KAAK,mBAAmB,EAAE,MAAM,GAAG;AAC5F,WAAO;AAAA,EACT;AAEA,SAAO;AACT;",
6
- "names": []
7
- }