/opt/canhelp/node_modules/better-auth/dist/plugins/open-api
Edit: /opt/canhelp/node_modules/better-auth/dist/plugins/open-api/index.mjs.map (4719B)
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/plugins/open-api/index.ts"],"sourcesContent":["import type { BetterAuthPlugin, LiteralString } from \"@better-auth/core\";\nimport { createAuthEndpoint } from \"@better-auth/core/api\";\nimport { APIError } from \"../../api\";\nimport { HIDE_METADATA } from \"../../utils\";\nimport { generator } from \"./generator\";\nimport { logo } from \"./logo\";\n\ndeclare module \"@better-auth/core\" {\n\tinterface BetterAuthPluginRegistry
{\n\t\t\"open-api\": {\n\t\t\tcreator: typeof openAPI;\n\t\t};\n\t}\n}\n\nexport type { FieldSchema, OpenAPIModelSchema, Path } from \"./generator\";\n\ntype ScalarTheme =\n\t| \"alternate\"\n\t| \"default\"\n\t| \"moon\"\n\t| \"purple\"\n\t| \"solarized\"\n\t| \"bluePlanet\"\n\t| \"saturn\"\n\t| \"kepler\"\n\t| \"mars\"\n\t| \"deepSpace\"\n\t| \"laserwave\"\n\t| \"none\";\n\nconst getHTML = (\n\tapiReference: Record,\n\ttheme?: ScalarTheme | undefined,\n\tnonce?: string | undefined,\n) => {\n\tconst nonceAttr = nonce ? `nonce=\"${nonce}\"` : \"\";\n\treturn `\n\n \n Scalar API Reference\n \n \n \n \n \n\t \n\t \n \n`;\n};\n\nexport interface OpenAPIOptions {\n\t/**\n\t * The path to the OpenAPI reference page\n\t *\n\t * keep in mind that this path will be appended to the base URL `/api/auth` path\n\t * by default, so if you set this to `/reference`, the full path will be `/api/auth/reference`\n\t *\n\t * @default \"/reference\"\n\t */\n\tpath?: LiteralString | undefined;\n\t/**\n\t * Disable the default reference page that is generated by Scalar\n\t *\n\t * @default false\n\t */\n\tdisableDefaultReference?: boolean | undefined;\n\t/**\n\t * Theme of the OpenAPI reference page.\n\t *\n\t * @default \"default\"\n\t */\n\ttheme?: ScalarTheme | undefined;\n\t/**\n\t * A 'nonce' string to be attached to inline scripts\n\t * for Content Security Policy (CSP) compliance.\n\t * @default undefined\n\t */\n\tnonce?: string | undefined;\n}\n\nexport const openAPI = (options?: O | undefined) => {\n\tconst path = options?.path ?? \"/reference\";\n\treturn {\n\t\tid: \"open-api\",\n\t\tendpoints: {\n\t\t\tgenerateOpenAPISchema: createAuthEndpoint(\n\t\t\t\t\"/open-api/generate-schema\",\n\t\t\t\t{\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t},\n\t\t\t\tasync (ctx) => {\n\t\t\t\t\tconst schema = await generator(ctx.context, ctx.context.options);\n\t\t\t\t\treturn ctx.json(schema);\n\t\t\t\t},\n\t\t\t),\n\t\t\topenAPIReference: createAuthEndpoint(\n\t\t\t\tpath,\n\t\t\t\t{\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\tmetadata: HIDE_METADATA,\n\t\t\t\t},\n\t\t\t\tasync (ctx) => {\n\t\t\t\t\tif (options?.disableDefaultReference) {\n\t\t\t\t\t\tthrow new APIError(\"NOT_FOUND\");\n\t\t\t\t\t}\n\t\t\t\t\tconst schema = await generator(ctx.context, ctx.context.options);\n\t\t\t\t\treturn new Response(getHTML(schema, options?.theme, options?.nonce), {\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\"Content-Type\": \"text/html\",\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t),\n\t\t},\n\t\toptions: options as NoInfer,\n\t} satisfies BetterAuthPlugin;\n};\n\nexport type * from \"./generator\";\n"],"mappings":";;;;;;;;AA+BA,MAAM,WACL,cACA,OACA,UACI;CACJ,MAAM,YAAY,QAAQ,UAAU,MAAM,KAAK;AAC/C,QAAO;;;;;;;;;;;;;MAaF,KAAK,UAAU,aAAa,CAAC;;YAEvB,UAAU;;wCAEkB,mBAAmB,KAAK,CAAC;eAClD,SAAS,UAAU;;;;;;;;;;sEAUoC,UAAU;;;;AAmChF,MAAa,WAAqC,YAA4B;CAC7E,MAAM,OAAO,SAAS,QAAQ;AAC9B,QAAO;EACN,IAAI;EACJ,WAAW;GACV,uBAAuB,mBACtB,6BACA,EACC,QAAQ,OACR,EACD,OAAO,QAAQ;IACd,MAAM,SAAS,MAAM,UAAU,IAAI,SAAS,IAAI,QAAQ,QAAQ;AAChE,WAAO,IAAI,KAAK,OAAO;KAExB;GACD,kBAAkB,mBACjB,MACA;IACC,QAAQ;IACR,UAAU;IACV,EACD,OAAO,QAAQ;AACd,QAAI,SAAS,wBACZ,OAAM,IAAI,SAAS,YAAY;IAEhC,MAAM,SAAS,MAAM,UAAU,IAAI,SAAS,IAAI,QAAQ,QAAQ;AAChE,WAAO,IAAI,SAAS,QAAQ,QAAQ,SAAS,OAAO,SAAS,MAAM,EAAE,EACpE,SAAS,EACR,gBAAgB,aAChB,EACD,CAAC;KAEH;GACD;EACQ;EACT"}