@caiquecamargo/vite-plugin-netlify-cms 0.1.1 → 0.1.3

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
@@ -1,9 +1,8 @@
1
- import {
2
- authUrl,
3
- clientId,
4
- clientSecret,
5
- tokenUrl
6
- } from "./chunk-JOUSWMWF.js";
1
+ // src/oauth/config.ts
2
+ var clientId = process.env.OAUTH_GITHUB_CLIENT_ID;
3
+ var clientSecret = process.env.OAUTH_GITHUB_CLIENT_SECRET;
4
+ var authUrl = `https://github.com/login/oauth/authorize?client_id=${clientId}&scope=repo,user`;
5
+ var tokenUrl = "https://github.com/login/oauth/access_token";
7
6
 
8
7
  // src/oauth/callback.ts
9
8
  async function handleOAuthCallback(code) {
@@ -383,12 +382,12 @@ function githubOAuthIntegration(options) {
383
382
  }
384
383
  injectRoute({
385
384
  pattern: loginRoute,
386
- entrypoint: "@caiquecamargo/vite-plugin-netlify-cms/src/oauth/astro-login.js",
385
+ entrypoint: "@caiquecamargo/vite-plugin-netlify-cms/src/oauth/astro-login.ts",
387
386
  prerender: false
388
387
  });
389
388
  injectRoute({
390
389
  pattern: callbackRoute,
391
- entrypoint: "@caiquecamargo/vite-plugin-netlify-cms/src/oauth/astro-callback.js",
390
+ entrypoint: "@caiquecamargo/vite-plugin-netlify-cms/src/oauth/astro-callback.ts",
392
391
  prerender: false
393
392
  });
394
393
  }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/oauth/callback.ts","../src/oauth/login.ts","../src/oauth-plugin.ts","../src/plugin.ts","../src/index.template.ts","../src/astro-oauth-integration.ts","../index.ts"],"sourcesContent":["import { clientId, clientSecret, tokenUrl } from './config';\n\n/**\n * OAuth callback handler - exchanges code for access token\n */\nexport async function handleOAuthCallback(code: string) {\n const data = {\n code,\n client_id: clientId,\n client_secret: clientSecret,\n };\n\n try {\n const response = await fetch(tokenUrl, {\n method: 'POST',\n headers: {\n 'Accept': 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(data),\n });\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const body = await response.json();\n\n const content = {\n token: body.access_token,\n provider: 'github',\n };\n\n // Return HTML with postMessage script to communicate with CMS\n const script = `\n <script>\n const receiveMessage = (message) => {\n window.opener.postMessage(\n 'authorization:${content.provider}:success:${JSON.stringify(content)}',\n message.origin\n );\n\n window.removeEventListener(\"message\", receiveMessage, false);\n }\n\n window.addEventListener(\"message\", receiveMessage, false);\n\n window.opener.postMessage(\"authorizing:${content.provider}\", \"*\");\n </script>\n `;\n\n return {\n statusCode: 200,\n headers: {\n 'Content-Type': 'text/html',\n },\n body: script,\n };\n }\n catch (err) {\n console.error('OAuth callback error:', err);\n return {\n statusCode: 500,\n headers: {\n 'Content-Type': 'text/html',\n },\n body: '<html><body><h1>OAuth Error</h1><p>Authentication failed. Please close this window and try again.</p></body></html>',\n };\n }\n}\n","import { authUrl } from './config';\n\n/**\n * OAuth login handler - redirects to GitHub authorization\n */\nexport function handleOAuthLogin() {\n return {\n statusCode: 302,\n headers: {\n Location: authUrl,\n },\n body: '',\n };\n}\n","import type { Plugin } from 'vite';\nimport { handleOAuthCallback } from './oauth/callback';\nimport { clientId, clientSecret } from './oauth/config';\nimport { handleOAuthLogin } from './oauth/login';\n\nexport interface OAuthPluginOptions {\n /**\n * OAuth login route\n * @default '/oauth'\n */\n loginRoute?: string;\n\n /**\n * OAuth callback route\n * @default '/oauth/callback'\n */\n callbackRoute?: string;\n\n /**\n * Disable OAuth plugin\n * @default false\n */\n disabled?: boolean;\n}\n\n/**\n * Vite plugin for OAuth authentication routes\n * Adds /oauth and /oauth/callback routes for GitHub authentication\n */\nexport default function oauthPlugin(options?: OAuthPluginOptions): Plugin {\n const {\n loginRoute = '/oauth',\n callbackRoute = '/oauth/callback',\n disabled = false,\n } = options ?? {};\n\n if (disabled) {\n return {\n name: 'vite-plugin-oauth',\n };\n }\n\n let warningShown = false;\n\n return {\n name: 'vite-plugin-oauth',\n configureServer(server) {\n server.middlewares.use(async (req, res, next) => {\n const url = req.url;\n\n // Show warning once if environment variables are not set\n if (!warningShown) {\n if (!clientId || !clientSecret) {\n console.warn(\n '\\x1B[33m⚠ OAuth plugin enabled but OAUTH_GITHUB_CLIENT_ID or OAUTH_GITHUB_CLIENT_SECRET environment variables are not set.\\x1B[0m',\n );\n }\n warningShown = true;\n }\n\n // Handle OAuth login route\n if (url === loginRoute) {\n const result = handleOAuthLogin();\n res.writeHead(result.statusCode, result.headers);\n res.end(result.body);\n return;\n }\n\n // Handle OAuth callback route\n if (url?.startsWith(callbackRoute)) {\n const urlParams = new URLSearchParams(url.split('?')[1]);\n const code = urlParams.get('code');\n\n if (!code) {\n res.writeHead(400, { 'Content-Type': 'text/html' });\n res.end('<html><body><h1>Error</h1><p>No code provided</p></body></html>');\n return;\n }\n\n const result = await handleOAuthCallback(code);\n res.writeHead(result.statusCode, result.headers);\n res.end(result.body);\n return;\n }\n\n next();\n });\n },\n };\n}\n","import type { Plugin } from 'vite';\nimport type {\n BooleanWidget,\n CodeWidget,\n ColorWidget,\n ComputeWidget,\n DateTimeWidget,\n FileCollection,\n FileCollectionEntry,\n FileWidget,\n FolderCollection,\n HiddenWidget,\n ImageWidget,\n KeyValueWidget,\n ListWidget,\n MapWidget,\n MarkdownWidget,\n NetlifyCMSConfig,\n NumberWidget,\n ObjectWidget,\n RelationWidget,\n RichTextWidget,\n SelectWidget,\n StringWidget,\n TextWidget,\n UuidWidget,\n} from './types';\nimport { mkdir, readdir, writeFile } from 'node:fs/promises';\nimport path from 'node:path';\nimport { loadConfigFromFile } from 'vite';\nimport YAML from 'yaml';\nimport indexHTMLTemplate from './index.template';\n\nexport function defineConfig(config: NetlifyCMSConfig): NetlifyCMSConfig {\n return config;\n}\nexport function defineFolderCollection(collection: FolderCollection) {\n return collection;\n}\nexport const defineFileCollection = (collection: FileCollection) => collection;\nexport const defineFileCollectionEntry = (collection: FileCollectionEntry) => collection;\nexport function defineBooleanWidget(widget: Omit<BooleanWidget, 'widget'>): BooleanWidget {\n return {\n widget: 'boolean',\n ...widget,\n };\n}\nexport function defineCodeWidget(widget: Omit<CodeWidget, 'widget'>): CodeWidget {\n return {\n widget: 'code',\n ...widget,\n };\n}\nexport function defineColorWidget(widget: Omit<ColorWidget, 'widget'>): ColorWidget {\n return {\n widget: 'color',\n ...widget,\n };\n}\nexport function defineComputeWidget(widget: Omit<ComputeWidget, 'widget'>): ComputeWidget {\n return {\n widget: 'compute',\n ...widget,\n };\n}\nexport function defineDateTimeWidget(widget: Omit<DateTimeWidget, 'widget'>): DateTimeWidget {\n return { widget: 'datetime', ...widget };\n}\nexport function defineHiddenWidget(widget: Omit<HiddenWidget, 'widget'>): HiddenWidget {\n return {\n widget: 'hidden',\n ...widget,\n };\n}\nexport function defineFileWidget(widget: Omit<FileWidget, 'widget'>): FileWidget {\n return {\n widget: 'file',\n ...widget,\n };\n}\nexport function defineImageWidget(widget: Omit<ImageWidget, 'widget'>): ImageWidget {\n return {\n widget: 'image',\n ...widget,\n };\n}\nexport function defineKeyValueWidget(widget: Omit<KeyValueWidget, 'widget'>): KeyValueWidget {\n return {\n widget: 'keyvalue',\n ...widget,\n };\n}\nexport function defineListWidget(widget: Omit<ListWidget, 'widget'>): ListWidget {\n return {\n widget: 'list',\n ...widget,\n };\n}\nexport function defineMapWidget(widget: Omit<MapWidget, 'widget'>): MapWidget {\n return {\n widget: 'map',\n ...widget,\n };\n}\nexport function defineNumberWidget(widget: Omit<NumberWidget, 'widget'>): NumberWidget {\n return {\n widget: 'number',\n ...widget,\n };\n}\nexport function defineObjectWidget(widget: Omit<ObjectWidget, 'widget'>): ObjectWidget {\n return {\n widget: 'object',\n ...widget,\n };\n}\nexport function defineRelationWidget(widget: Omit<RelationWidget, 'widget'>): RelationWidget {\n return { widget: 'relation', ...widget };\n}\nexport function defineSelectWidget(widget: Omit<SelectWidget, 'widget'>): SelectWidget {\n return {\n widget: 'select',\n ...widget,\n };\n}\nexport function defineStringWidget(widget: Omit<StringWidget, 'widget'>): StringWidget {\n return {\n widget: 'string',\n ...widget,\n };\n}\nexport function defineTextWidget(widget: Omit<TextWidget, 'widget'>): TextWidget {\n return {\n widget: 'text',\n ...widget,\n };\n}\nexport function defineMarkdownWidget(widget: Omit<MarkdownWidget, 'widget'>): MarkdownWidget {\n return {\n widget: 'markdown',\n ...widget,\n };\n}\nexport function defineRichTextWidget(widget: Omit<RichTextWidget, 'widget'>): RichTextWidget {\n return {\n widget: 'richtext',\n ...widget,\n };\n}\nexport function defineUuidWidget(widget: Omit<UuidWidget, 'widget'>): UuidWidget {\n return {\n widget: 'uuid',\n ...widget,\n };\n}\n\nexport interface NetlifyCMSEntry {\n /**\n * Name of config file\n *\n * @default cms.config\n */\n configFile?: string;\n\n /**\n * Netlify CMS config object\n */\n config?: NetlifyCMSConfig;\n\n /**\n * Folder to save config file\n *\n * @default ./public/admin\n */\n saveFolder?: string;\n\n /**\n * If has to create index.html file in the save folder\n */\n createIndexHTML?: boolean;\n\n /**\n * Title of the admin page\n *\n * @default Admin\n */\n title?: string;\n\n /**\n * Icon URL of the admin page\n *\n * @default https://decapcms.org/img/decap-logo.svg\n */\n iconUrl?: string;\n\n /**\n * If has to use identity widget\n *\n * @default true\n */\n useIdentityWidget?: boolean;\n\n /**\n * Type of CMS to generate config for\n *\n * @default 'sveltia'\n */\n type?: 'decap' | 'sveltia';\n}\n\nasync function createFolderIfNotExists(path: string) {\n try {\n await readdir(path);\n }\n catch {\n await mkdir(path, { recursive: true });\n }\n}\n\nasync function saveConfig(document: string, pathTo: string) {\n await writeFile(pathTo, document);\n}\n\nfunction resolveConfigFilePath(configFile: string) {\n const _path = configFile.startsWith('.') ? configFile.slice(2) : configFile;\n\n if (!_path)\n return configFile;\n if (['ts', 'js', 'cjs', 'mjs'].some(ext => _path.includes(ext)))\n return _path.split('.').slice(0, -1).join('.');\n\n return _path;\n}\n\nasync function getConfigFile(root: string, configFile: string): Promise<NetlifyCMSConfig> {\n try {\n const files = await readdir(root);\n const configPath = resolveConfigFilePath(configFile);\n\n if (configPath.includes('/')) {\n const [folder, file] = configPath.split('/');\n return await getConfigFile(path.join(root, folder), file);\n }\n\n const file = files.find(file => file.startsWith(configPath));\n\n if (!file)\n throw new Error(`Config file not found`);\n\n const { config }\n = (await loadConfigFromFile(\n { command: 'build', mode: '' },\n path.join(root, file),\n )) ?? {};\n\n if (!config)\n throw new Error(`Config file not found`);\n\n return config as NetlifyCMSConfig;\n }\n catch {\n throw new Error(`Config file not found`);\n }\n}\n\nfunction createIndex(title: string, iconUrl: string, useIdentityWidget: boolean, type: 'decap' | 'sveltia' = 'sveltia') {\n const icon = iconUrl ? `<link rel=\"icon\" type=\"image/svg+xml\" href=\"${iconUrl}\" />` : '';\n const identity = useIdentityWidget ? `<script src=\"https://identity.netlify.com/v1/netlify-identity-widget.js\"></script>` : '';\n\n const script = type === 'decap'\n ? `<script src=\"https://unpkg.com/decap-cms@^3.0.0/dist/decap-cms.js\"></script>`\n : `<script src=\"https://unpkg.com/@sveltia/cms/dist/sveltia-cms.js\"></script>`;\n\n const document = indexHTMLTemplate\n .replace('{{ script }}', script)\n .replace('{{ title }}', title)\n .replace('{{ icon }}', icon)\n .replace('{{ identity }}', identity);\n\n return document;\n}\n\nexport async function createConfig(root: string, entry?: NetlifyCMSEntry) {\n const {\n configFile = 'cms.config',\n config,\n saveFolder = './public/admin',\n createIndexHTML = true,\n title = 'Admin',\n iconUrl = 'https://decapcms.org/img/decap-logo.svg',\n useIdentityWidget = false,\n type = 'sveltia',\n } = entry ?? {};\n\n const resolvedConfig = config ?? (await getConfigFile(root, configFile));\n await createFolderIfNotExists(path.join(root, saveFolder));\n\n const document = YAML.stringify(resolvedConfig);\n await saveConfig(document, path.join(root, saveFolder, 'config.yml'));\n\n if (!createIndexHTML)\n return;\n\n const indexHTML = createIndex(title, iconUrl, useIdentityWidget, type);\n await saveConfig(indexHTML, path.join(root, saveFolder, 'index.html'));\n}\n\nexport default async function (entry?: NetlifyCMSEntry): Promise<Plugin> {\n let root = '';\n\n return {\n name: 'vite-plugin-netlify-cms',\n configResolved: (config) => {\n root = config.root;\n },\n buildStart: async () => {\n try {\n await createConfig(root, entry);\n }\n catch (error) {\n console.log(error);\n }\n },\n handleHotUpdate: async ({ file }) => {\n if (file.includes(entry?.configFile ?? 'cms.config')) {\n try {\n await createConfig(root, entry);\n }\n catch (error) {\n console.log(error);\n }\n }\n },\n };\n}\n","export default `<!DOCTYPE html>\n<html>\n <head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>{{ title }}</title>\n {{ icon }}\n {{ identity }}\n </head>\n <body>\n {{ script }}\n </body>\n</html>`;\n","export interface AstroOAuthOptions {\n /**\n * OAuth login route\n * @default '/oauth'\n */\n loginRoute?: string;\n\n /**\n * OAuth callback route\n * @default '/oauth/callback'\n */\n callbackRoute?: string;\n\n /**\n * Disable OAuth integration\n * @default false\n */\n disabled?: boolean;\n}\n\nconst defaultOptions: AstroOAuthOptions = {\n loginRoute: '/oauth',\n callbackRoute: '/oauth/callback',\n disabled: false,\n};\n\n/**\n * Astro integration for OAuth authentication routes\n * Adds /oauth and /oauth/callback routes for GitHub authentication\n *\n * @example\n * ```ts\n * import { defineConfig } from 'astro/config';\n * import { githubOAuthIntegration } from 'vite-plugin-netlify-cms';\n *\n * export default defineConfig({\n * integrations: [githubOAuthIntegration()],\n * output: 'server', // or 'hybrid'\n * });\n * ```\n */\nexport function githubOAuthIntegration(options?: AstroOAuthOptions): any {\n const { loginRoute, callbackRoute, disabled } = { ...defaultOptions, ...options };\n\n if (!loginRoute?.startsWith('/') || !callbackRoute?.startsWith('/')) {\n throw new Error('`loginRoute` and `callbackRoute` options must start with \"/\"');\n }\n\n return {\n name: 'github-oauth-integration',\n hooks: {\n 'astro:config:setup': async ({ injectRoute }: any) => {\n if (disabled) {\n return;\n }\n\n // Inject OAuth login route\n injectRoute({\n pattern: loginRoute,\n entrypoint: '@caiquecamargo/vite-plugin-netlify-cms/src/oauth/astro-login.js',\n prerender: false,\n });\n\n // Inject OAuth callback route\n injectRoute({\n pattern: callbackRoute,\n entrypoint: '@caiquecamargo/vite-plugin-netlify-cms/src/oauth/astro-callback.js',\n prerender: false,\n });\n },\n },\n };\n}\n","import oauthPlugin from './src/oauth-plugin.js';\nimport cmsPlugin from './src/plugin.js';\n\nexport * from './src/astro-oauth-integration.js';\nexport * from './src/oauth-plugin.js';\nexport * from './src/plugin.js';\nexport * from './src/types.js';\n\nexport { cmsPlugin, oauthPlugin };\nexport default cmsPlugin;\n"],"mappings":";;;;;;;;AAKA,eAAsB,oBAAoB,MAAc;AACtD,QAAM,OAAO;AAAA,IACX;AAAA,IACA,WAAW;AAAA,IACX,eAAe;AAAA,EACjB;AAEA,MAAI;AACF,UAAM,WAAW,MAAM,MAAM,UAAU;AAAA,MACrC,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,UAAU;AAAA,QACV,gBAAgB;AAAA,MAClB;AAAA,MACA,MAAM,KAAK,UAAU,IAAI;AAAA,IAC3B,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,IAAI,MAAM,uBAAuB,SAAS,MAAM,EAAE;AAAA,IAC1D;AAEA,UAAM,OAAO,MAAM,SAAS,KAAK;AAEjC,UAAM,UAAU;AAAA,MACd,OAAO,KAAK;AAAA,MACZ,UAAU;AAAA,IACZ;AAGA,UAAM,SAAS;AAAA;AAAA;AAAA;AAAA,6BAIU,QAAQ,QAAQ,YAAY,KAAK,UAAU,OAAO,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iDAS/B,QAAQ,QAAQ;AAAA;AAAA;AAI7D,WAAO;AAAA,MACL,YAAY;AAAA,MACZ,SAAS;AAAA,QACP,gBAAgB;AAAA,MAClB;AAAA,MACA,MAAM;AAAA,IACR;AAAA,EACF,SACO,KAAK;AACV,YA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,eAAe,SAAS,IAAI,EAAE,GAAG,gBAAgB,GAAG,QAAQ;AAEhF,MAAI,CAAC,YAAY,WAAW,GAAG,KAAK,CAAC,eAAe,WAAW,GAAG,GAAG;AACnE,UAAM,IAAI,MAAM,8DAA8D;AAAA,EAChF;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,MACL,sBAAsB,OAAO,EAAE,YAAY,MAAW;AACpD,YAAI,UAAU;AACZ;AAAA,QACF;AAGA,oBAAY;AAAA,UACV,SAAS;AAAA,UACT,YAAY;AAAA,UACZ,WAAW;AAAA,QACb,CAAC;AAGD,oBAAY;AAAA,UACV,SAAS;AAAA,UACT,YAAY;AAAA,UACZ,WAAW;AAAA,QACb,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;;;AC/DA,IAAO,gBAAQ;","names":["path","file"]}
1
+ {"version":3,"sources":["../src/oauth/config.ts","../src/oauth/callback.ts","../src/oauth/login.ts","../src/oauth-plugin.ts","../src/plugin.ts","../src/index.template.ts","../src/astro-oauth-integration.ts","../index.ts"],"sourcesContent":["export const clientId = process.env.OAUTH_GITHUB_CLIENT_ID;\nexport const clientSecret = process.env.OAUTH_GITHUB_CLIENT_SECRET;\n\nexport const authUrl = `https://github.com/login/oauth/authorize?client_id=${clientId}&scope=repo,user`;\nexport const tokenUrl = 'https://github.com/login/oauth/access_token';\n","import { clientId, clientSecret, tokenUrl } from './config';\n\n/**\n * OAuth callback handler - exchanges code for access token\n */\nexport async function handleOAuthCallback(code: string) {\n const data = {\n code,\n client_id: clientId,\n client_secret: clientSecret,\n };\n\n try {\n const response = await fetch(tokenUrl, {\n method: 'POST',\n headers: {\n 'Accept': 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(data),\n });\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const body = await response.json();\n\n const content = {\n token: body.access_token,\n provider: 'github',\n };\n\n // Return HTML with postMessage script to communicate with CMS\n const script = `\n <script>\n const receiveMessage = (message) => {\n window.opener.postMessage(\n 'authorization:${content.provider}:success:${JSON.stringify(content)}',\n message.origin\n );\n\n window.removeEventListener(\"message\", receiveMessage, false);\n }\n\n window.addEventListener(\"message\", receiveMessage, false);\n\n window.opener.postMessage(\"authorizing:${content.provider}\", \"*\");\n </script>\n `;\n\n return {\n statusCode: 200,\n headers: {\n 'Content-Type': 'text/html',\n },\n body: script,\n };\n }\n catch (err) {\n console.error('OAuth callback error:', err);\n return {\n statusCode: 500,\n headers: {\n 'Content-Type': 'text/html',\n },\n body: '<html><body><h1>OAuth Error</h1><p>Authentication failed. Please close this window and try again.</p></body></html>',\n };\n }\n}\n","import { authUrl } from './config';\n\n/**\n * OAuth login handler - redirects to GitHub authorization\n */\nexport function handleOAuthLogin() {\n return {\n statusCode: 302,\n headers: {\n Location: authUrl,\n },\n body: '',\n };\n}\n","import type { Plugin } from 'vite';\nimport { handleOAuthCallback } from './oauth/callback';\nimport { clientId, clientSecret } from './oauth/config';\nimport { handleOAuthLogin } from './oauth/login';\n\nexport interface OAuthPluginOptions {\n /**\n * OAuth login route\n * @default '/oauth'\n */\n loginRoute?: string;\n\n /**\n * OAuth callback route\n * @default '/oauth/callback'\n */\n callbackRoute?: string;\n\n /**\n * Disable OAuth plugin\n * @default false\n */\n disabled?: boolean;\n}\n\n/**\n * Vite plugin for OAuth authentication routes\n * Adds /oauth and /oauth/callback routes for GitHub authentication\n */\nexport default function oauthPlugin(options?: OAuthPluginOptions): Plugin {\n const {\n loginRoute = '/oauth',\n callbackRoute = '/oauth/callback',\n disabled = false,\n } = options ?? {};\n\n if (disabled) {\n return {\n name: 'vite-plugin-oauth',\n };\n }\n\n let warningShown = false;\n\n return {\n name: 'vite-plugin-oauth',\n configureServer(server) {\n server.middlewares.use(async (req, res, next) => {\n const url = req.url;\n\n // Show warning once if environment variables are not set\n if (!warningShown) {\n if (!clientId || !clientSecret) {\n console.warn(\n '\\x1B[33m⚠ OAuth plugin enabled but OAUTH_GITHUB_CLIENT_ID or OAUTH_GITHUB_CLIENT_SECRET environment variables are not set.\\x1B[0m',\n );\n }\n warningShown = true;\n }\n\n // Handle OAuth login route\n if (url === loginRoute) {\n const result = handleOAuthLogin();\n res.writeHead(result.statusCode, result.headers);\n res.end(result.body);\n return;\n }\n\n // Handle OAuth callback route\n if (url?.startsWith(callbackRoute)) {\n const urlParams = new URLSearchParams(url.split('?')[1]);\n const code = urlParams.get('code');\n\n if (!code) {\n res.writeHead(400, { 'Content-Type': 'text/html' });\n res.end('<html><body><h1>Error</h1><p>No code provided</p></body></html>');\n return;\n }\n\n const result = await handleOAuthCallback(code);\n res.writeHead(result.statusCode, result.headers);\n res.end(result.body);\n return;\n }\n\n next();\n });\n },\n };\n}\n","import type { Plugin } from 'vite';\nimport type {\n BooleanWidget,\n CodeWidget,\n ColorWidget,\n ComputeWidget,\n DateTimeWidget,\n FileCollection,\n FileCollectionEntry,\n FileWidget,\n FolderCollection,\n HiddenWidget,\n ImageWidget,\n KeyValueWidget,\n ListWidget,\n MapWidget,\n MarkdownWidget,\n NetlifyCMSConfig,\n NumberWidget,\n ObjectWidget,\n RelationWidget,\n RichTextWidget,\n SelectWidget,\n StringWidget,\n TextWidget,\n UuidWidget,\n} from './types';\nimport { mkdir, readdir, writeFile } from 'node:fs/promises';\nimport path from 'node:path';\nimport { loadConfigFromFile } from 'vite';\nimport YAML from 'yaml';\nimport indexHTMLTemplate from './index.template';\n\nexport function defineConfig(config: NetlifyCMSConfig): NetlifyCMSConfig {\n return config;\n}\nexport function defineFolderCollection(collection: FolderCollection) {\n return collection;\n}\nexport const defineFileCollection = (collection: FileCollection) => collection;\nexport const defineFileCollectionEntry = (collection: FileCollectionEntry) => collection;\nexport function defineBooleanWidget(widget: Omit<BooleanWidget, 'widget'>): BooleanWidget {\n return {\n widget: 'boolean',\n ...widget,\n };\n}\nexport function defineCodeWidget(widget: Omit<CodeWidget, 'widget'>): CodeWidget {\n return {\n widget: 'code',\n ...widget,\n };\n}\nexport function defineColorWidget(widget: Omit<ColorWidget, 'widget'>): ColorWidget {\n return {\n widget: 'color',\n ...widget,\n };\n}\nexport function defineComputeWidget(widget: Omit<ComputeWidget, 'widget'>): ComputeWidget {\n return {\n widget: 'compute',\n ...widget,\n };\n}\nexport function defineDateTimeWidget(widget: Omit<DateTimeWidget, 'widget'>): DateTimeWidget {\n return { widget: 'datetime', ...widget };\n}\nexport function defineHiddenWidget(widget: Omit<HiddenWidget, 'widget'>): HiddenWidget {\n return {\n widget: 'hidden',\n ...widget,\n };\n}\nexport function defineFileWidget(widget: Omit<FileWidget, 'widget'>): FileWidget {\n return {\n widget: 'file',\n ...widget,\n };\n}\nexport function defineImageWidget(widget: Omit<ImageWidget, 'widget'>): ImageWidget {\n return {\n widget: 'image',\n ...widget,\n };\n}\nexport function defineKeyValueWidget(widget: Omit<KeyValueWidget, 'widget'>): KeyValueWidget {\n return {\n widget: 'keyvalue',\n ...widget,\n };\n}\nexport function defineListWidget(widget: Omit<ListWidget, 'widget'>): ListWidget {\n return {\n widget: 'list',\n ...widget,\n };\n}\nexport function defineMapWidget(widget: Omit<MapWidget, 'widget'>): MapWidget {\n return {\n widget: 'map',\n ...widget,\n };\n}\nexport function defineNumberWidget(widget: Omit<NumberWidget, 'widget'>): NumberWidget {\n return {\n widget: 'number',\n ...widget,\n };\n}\nexport function defineObjectWidget(widget: Omit<ObjectWidget, 'widget'>): ObjectWidget {\n return {\n widget: 'object',\n ...widget,\n };\n}\nexport function defineRelationWidget(widget: Omit<RelationWidget, 'widget'>): RelationWidget {\n return { widget: 'relation', ...widget };\n}\nexport function defineSelectWidget(widget: Omit<SelectWidget, 'widget'>): SelectWidget {\n return {\n widget: 'select',\n ...widget,\n };\n}\nexport function defineStringWidget(widget: Omit<StringWidget, 'widget'>): StringWidget {\n return {\n widget: 'string',\n ...widget,\n };\n}\nexport function defineTextWidget(widget: Omit<TextWidget, 'widget'>): TextWidget {\n return {\n widget: 'text',\n ...widget,\n };\n}\nexport function defineMarkdownWidget(widget: Omit<MarkdownWidget, 'widget'>): MarkdownWidget {\n return {\n widget: 'markdown',\n ...widget,\n };\n}\nexport function defineRichTextWidget(widget: Omit<RichTextWidget, 'widget'>): RichTextWidget {\n return {\n widget: 'richtext',\n ...widget,\n };\n}\nexport function defineUuidWidget(widget: Omit<UuidWidget, 'widget'>): UuidWidget {\n return {\n widget: 'uuid',\n ...widget,\n };\n}\n\nexport interface NetlifyCMSEntry {\n /**\n * Name of config file\n *\n * @default cms.config\n */\n configFile?: string;\n\n /**\n * Netlify CMS config object\n */\n config?: NetlifyCMSConfig;\n\n /**\n * Folder to save config file\n *\n * @default ./public/admin\n */\n saveFolder?: string;\n\n /**\n * If has to create index.html file in the save folder\n */\n createIndexHTML?: boolean;\n\n /**\n * Title of the admin page\n *\n * @default Admin\n */\n title?: string;\n\n /**\n * Icon URL of the admin page\n *\n * @default https://decapcms.org/img/decap-logo.svg\n */\n iconUrl?: string;\n\n /**\n * If has to use identity widget\n *\n * @default true\n */\n useIdentityWidget?: boolean;\n\n /**\n * Type of CMS to generate config for\n *\n * @default 'sveltia'\n */\n type?: 'decap' | 'sveltia';\n}\n\nasync function createFolderIfNotExists(path: string) {\n try {\n await readdir(path);\n }\n catch {\n await mkdir(path, { recursive: true });\n }\n}\n\nasync function saveConfig(document: string, pathTo: string) {\n await writeFile(pathTo, document);\n}\n\nfunction resolveConfigFilePath(configFile: string) {\n const _path = configFile.startsWith('.') ? configFile.slice(2) : configFile;\n\n if (!_path)\n return configFile;\n if (['ts', 'js', 'cjs', 'mjs'].some(ext => _path.includes(ext)))\n return _path.split('.').slice(0, -1).join('.');\n\n return _path;\n}\n\nasync function getConfigFile(root: string, configFile: string): Promise<NetlifyCMSConfig> {\n try {\n const files = await readdir(root);\n const configPath = resolveConfigFilePath(configFile);\n\n if (configPath.includes('/')) {\n const [folder, file] = configPath.split('/');\n return await getConfigFile(path.join(root, folder), file);\n }\n\n const file = files.find(file => file.startsWith(configPath));\n\n if (!file)\n throw new Error(`Config file not found`);\n\n const { config }\n = (await loadConfigFromFile(\n { command: 'build', mode: '' },\n path.join(root, file),\n )) ?? {};\n\n if (!config)\n throw new Error(`Config file not found`);\n\n return config as NetlifyCMSConfig;\n }\n catch {\n throw new Error(`Config file not found`);\n }\n}\n\nfunction createIndex(title: string, iconUrl: string, useIdentityWidget: boolean, type: 'decap' | 'sveltia' = 'sveltia') {\n const icon = iconUrl ? `<link rel=\"icon\" type=\"image/svg+xml\" href=\"${iconUrl}\" />` : '';\n const identity = useIdentityWidget ? `<script src=\"https://identity.netlify.com/v1/netlify-identity-widget.js\"></script>` : '';\n\n const script = type === 'decap'\n ? `<script src=\"https://unpkg.com/decap-cms@^3.0.0/dist/decap-cms.js\"></script>`\n : `<script src=\"https://unpkg.com/@sveltia/cms/dist/sveltia-cms.js\"></script>`;\n\n const document = indexHTMLTemplate\n .replace('{{ script }}', script)\n .replace('{{ title }}', title)\n .replace('{{ icon }}', icon)\n .replace('{{ identity }}', identity);\n\n return document;\n}\n\nexport async function createConfig(root: string, entry?: NetlifyCMSEntry) {\n const {\n configFile = 'cms.config',\n config,\n saveFolder = './public/admin',\n createIndexHTML = true,\n title = 'Admin',\n iconUrl = 'https://decapcms.org/img/decap-logo.svg',\n useIdentityWidget = false,\n type = 'sveltia',\n } = entry ?? {};\n\n const resolvedConfig = config ?? (await getConfigFile(root, configFile));\n await createFolderIfNotExists(path.join(root, saveFolder));\n\n const document = YAML.stringify(resolvedConfig);\n await saveConfig(document, path.join(root, saveFolder, 'config.yml'));\n\n if (!createIndexHTML)\n return;\n\n const indexHTML = createIndex(title, iconUrl, useIdentityWidget, type);\n await saveConfig(indexHTML, path.join(root, saveFolder, 'index.html'));\n}\n\nexport default async function (entry?: NetlifyCMSEntry): Promise<Plugin> {\n let root = '';\n\n return {\n name: 'vite-plugin-netlify-cms',\n configResolved: (config) => {\n root = config.root;\n },\n buildStart: async () => {\n try {\n await createConfig(root, entry);\n }\n catch (error) {\n console.log(error);\n }\n },\n handleHotUpdate: async ({ file }) => {\n if (file.includes(entry?.configFile ?? 'cms.config')) {\n try {\n await createConfig(root, entry);\n }\n catch (error) {\n console.log(error);\n }\n }\n },\n };\n}\n","export default `<!DOCTYPE html>\n<html>\n <head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>{{ title }}</title>\n {{ icon }}\n {{ identity }}\n </head>\n <body>\n {{ script }}\n </body>\n</html>`;\n","export interface AstroOAuthOptions {\n /**\n * OAuth login route\n * @default '/oauth'\n */\n loginRoute?: string;\n\n /**\n * OAuth callback route\n * @default '/oauth/callback'\n */\n callbackRoute?: string;\n\n /**\n * Disable OAuth integration\n * @default false\n */\n disabled?: boolean;\n}\n\nconst defaultOptions: AstroOAuthOptions = {\n loginRoute: '/oauth',\n callbackRoute: '/oauth/callback',\n disabled: false,\n};\n\n/**\n * Astro integration for OAuth authentication routes\n * Adds /oauth and /oauth/callback routes for GitHub authentication\n *\n * @example\n * ```ts\n * import { defineConfig } from 'astro/config';\n * import { githubOAuthIntegration } from 'vite-plugin-netlify-cms';\n *\n * export default defineConfig({\n * integrations: [githubOAuthIntegration()],\n * output: 'server', // or 'hybrid'\n * });\n * ```\n */\nexport function githubOAuthIntegration(options?: AstroOAuthOptions): any {\n const { loginRoute, callbackRoute, disabled } = { ...defaultOptions, ...options };\n\n if (!loginRoute?.startsWith('/') || !callbackRoute?.startsWith('/')) {\n throw new Error('`loginRoute` and `callbackRoute` options must start with \"/\"');\n }\n\n return {\n name: 'github-oauth-integration',\n hooks: {\n 'astro:config:setup': async ({ injectRoute }: any) => {\n if (disabled) {\n return;\n }\n\n // Inject OAuth login route\n injectRoute({\n pattern: loginRoute,\n entrypoint: '@caiquecamargo/vite-plugin-netlify-cms/src/oauth/astro-login.ts',\n prerender: false,\n });\n\n // Inject OAuth callback route\n injectRoute({\n pattern: callbackRoute,\n entrypoint: '@caiquecamargo/vite-plugin-netlify-cms/src/oauth/astro-callback.ts',\n prerender: false,\n });\n },\n },\n };\n}\n","import oauthPlugin from './src/oauth-plugin.js';\nimport cmsPlugin from './src/plugin.js';\n\nexport * from './src/astro-oauth-integration.js';\nexport * from './src/oauth-plugin.js';\nexport * from './src/plugin.js';\nexport * from './src/types.js';\n\nexport { cmsPlugin, oauthPlugin };\nexport default cmsPlugin;\n"],"mappings":";AAAO,IAAM,WAAW,QAAQ,IAAI;AAC7B,IAAM,eAAe,QAAQ,IAAI;AAEjC,IAAM,UAAU,sDAAsD,QAAQ;AAC9E,IAAM,WAAW;;;ACCxB,eAAsB,oBAAoB,MAAc;AACtD,QAAM,OAAO;AAAA,IACX;AAAA,IACA,WAAW;AAAA,IACX,eAAe;AAAA,EACjB;AAEA,MAAI;AACF,UAAM,WAAW,MAAM,MAAM,UAAU;AAAA,MACrC,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,UAAU;AAAA,QACV,gBAAgB;AAAA,MAClB;AAAA,MACA,MAAM,KAAK,UAAU,IAAI;AAAA,IAC3B,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,IAAI,MAAM,uBAAuB,SAAS,MAAM,EAAE;AAAA,IAC1D;AAEA,UAAM,OAAO,MAAM,SAAS,KAAK;AAEjC,UAAM,UAAU;AAAA,MACd,OAAO,KAAK;AAAA,MACZ,UAAU;AAAA,IACZ;AAGA,UAAM,SAAS;AAAA;AAAA;AAAA;AAAA,6BAIU,QAAQ,QAAQ,YAAY,KAAK,UAAU,OAAO,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iDAS/B,QAAQ,QAAQ;AAAA;AAAA;AAI7D,WAAO;AAAA,MACL,YAAY;AAAA,MACZ,SAAS;AAAA,QACP,gBAAgB;AAAA,MAClB;AAAA,MACA,MAAM;AAAA,IACR;AAAA,EACF,SACO,KAAK;AACV,YAAQ,MAAM,yBAAyB,GAAG;AAC1C,WAAO;AAAA,MACL,YAAY;AAAA,MACZ,SAAS;AAAA,QACP,gBA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G,KAAK,CAAC,eAAe,WAAW,GAAG,GAAG;AACnE,UAAM,IAAI,MAAM,8DAA8D;AAAA,EAChF;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,MACL,sBAAsB,OAAO,EAAE,YAAY,MAAW;AACpD,YAAI,UAAU;AACZ;AAAA,QACF;AAGA,oBAAY;AAAA,UACV,SAAS;AAAA,UACT,YAAY;AAAA,UACZ,WAAW;AAAA,QACb,CAAC;AAGD,oBAAY;AAAA,UACV,SAAS;AAAA,UACT,YAAY;AAAA,UACZ,WAAW;AAAA,QACb,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;;;AC/DA,IAAO,gBAAQ;","names":["path","file"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@caiquecamargo/vite-plugin-netlify-cms",
3
3
  "type": "module",
4
- "version": "0.1.1",
4
+ "version": "0.1.3",
5
5
  "author": "Caique de Camargo",
6
6
  "license": "ISC",
7
7
  "repository": {
@@ -14,13 +14,17 @@
14
14
  "types": "./dist/index.d.ts",
15
15
  "import": "./dist/index.js",
16
16
  "default": "./dist/index.js"
17
- }
17
+ },
18
+ "./src/oauth/astro-callback.ts": "./src/oauth/astro-callback.ts",
19
+ "./src/oauth/astro-login.ts": "./src/oauth/astro-login.ts"
18
20
  },
19
21
  "main": "./dist/index.js",
20
22
  "module": "./dist/index.js",
21
23
  "types": "./dist/index.d.ts",
22
24
  "files": [
23
- "dist"
25
+ "dist",
26
+ "src/oauth/astro-callback.ts",
27
+ "src/oauth/astro-login.ts"
24
28
  ],
25
29
  "peerDependencies": {
26
30
  "vite": "^7.0.0"
@@ -1,41 +1,45 @@
1
- import {
2
- clientId,
3
- clientSecret,
4
- tokenUrl
5
- } from "../../chunk-JOUSWMWF.js";
1
+ import { clientId, clientSecret, tokenUrl } from './config';
2
+
3
+ export const prerender = false;
4
+
5
+ export async function GET({ url, redirect }: any) {
6
+ const code = url.searchParams.get('code');
6
7
 
7
- // src/oauth/astro-callback.ts
8
- var prerender = false;
9
- async function GET({ url, redirect }) {
10
- const code = url.searchParams.get("code");
11
8
  if (!code) {
12
- return new Response("<html><body><h1>Error</h1><p>No code provided</p></body></html>", {
9
+ return new Response('<html><body><h1>Error</h1><p>No code provided</p></body></html>', {
13
10
  status: 400,
14
- headers: { "Content-Type": "text/html" }
11
+ headers: { 'Content-Type': 'text/html' },
15
12
  });
16
13
  }
14
+
17
15
  const data = {
18
16
  code,
19
17
  client_id: clientId,
20
- client_secret: clientSecret
18
+ client_secret: clientSecret,
21
19
  };
20
+
22
21
  try {
23
22
  const response = await fetch(tokenUrl, {
24
- method: "POST",
23
+ method: 'POST',
25
24
  headers: {
26
- "Accept": "application/json",
27
- "Content-Type": "application/json"
25
+ 'Accept': 'application/json',
26
+ 'Content-Type': 'application/json',
28
27
  },
29
- body: JSON.stringify(data)
28
+ body: JSON.stringify(data),
30
29
  });
30
+
31
31
  if (!response.ok) {
32
32
  throw new Error(`HTTP error! status: ${response.status}`);
33
33
  }
34
+
34
35
  const body = await response.json();
36
+
35
37
  const content = {
36
38
  token: body.access_token,
37
- provider: "github"
39
+ provider: 'github',
38
40
  };
41
+
42
+ // Return HTML with postMessage script to communicate with CMS
39
43
  const script = `
40
44
  <script>
41
45
  const receiveMessage = (message) => {
@@ -52,16 +56,13 @@ async function GET({ url, redirect }) {
52
56
  window.opener.postMessage("authorizing:${content.provider}", "*");
53
57
  </script>
54
58
  `;
59
+
55
60
  return new Response(script, {
56
- headers: { "Content-Type": "text/html" }
61
+ headers: { 'Content-Type': 'text/html' },
57
62
  });
58
- } catch (err) {
59
- console.error("OAuth callback error:", err);
60
- return redirect("/?error=oauth_failed");
63
+ }
64
+ catch (err) {
65
+ console.error('OAuth callback error:', err);
66
+ return redirect('/?error=oauth_failed');
61
67
  }
62
68
  }
63
- export {
64
- GET,
65
- prerender
66
- };
67
- //# sourceMappingURL=astro-callback.js.map
@@ -0,0 +1,7 @@
1
+ import { authUrl } from './config';
2
+
3
+ export const prerender = false;
4
+
5
+ export function GET({ redirect }: any) {
6
+ return redirect(authUrl);
7
+ }
@@ -1,13 +0,0 @@
1
- // src/oauth/config.ts
2
- var clientId = process.env.OAUTH_GITHUB_CLIENT_ID;
3
- var clientSecret = process.env.OAUTH_GITHUB_CLIENT_SECRET;
4
- var authUrl = `https://github.com/login/oauth/authorize?client_id=${clientId}&scope=repo,user`;
5
- var tokenUrl = "https://github.com/login/oauth/access_token";
6
-
7
- export {
8
- clientId,
9
- clientSecret,
10
- authUrl,
11
- tokenUrl
12
- };
13
- //# sourceMappingURL=chunk-JOUSWMWF.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/oauth/config.ts"],"sourcesContent":["export const clientId = process.env.OAUTH_GITHUB_CLIENT_ID;\nexport const clientSecret = process.env.OAUTH_GITHUB_CLIENT_SECRET;\n\nexport const authUrl = `https://github.com/login/oauth/authorize?client_id=${clientId}&scope=repo,user`;\nexport const tokenUrl = 'https://github.com/login/oauth/access_token';\n"],"mappings":";AAAO,IAAM,WAAW,QAAQ,IAAI;AAC7B,IAAM,eAAe,QAAQ,IAAI;AAEjC,IAAM,UAAU,sDAAsD,QAAQ;AAC9E,IAAM,WAAW;","names":[]}
@@ -1,4 +0,0 @@
1
- declare const prerender = false;
2
- declare function GET({ url, redirect }: any): Promise<any>;
3
-
4
- export { GET, prerender };
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/oauth/astro-callback.ts"],"sourcesContent":["import { clientId, clientSecret, tokenUrl } from './config';\n\nexport const prerender = false;\n\nexport async function GET({ url, redirect }: any) {\n const code = url.searchParams.get('code');\n\n if (!code) {\n return new Response('<html><body><h1>Error</h1><p>No code provided</p></body></html>', {\n status: 400,\n headers: { 'Content-Type': 'text/html' },\n });\n }\n\n const data = {\n code,\n client_id: clientId,\n client_secret: clientSecret,\n };\n\n try {\n const response = await fetch(tokenUrl, {\n method: 'POST',\n headers: {\n 'Accept': 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(data),\n });\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const body = await response.json();\n\n const content = {\n token: body.access_token,\n provider: 'github',\n };\n\n // Return HTML with postMessage script to communicate with CMS\n const script = `\n <script>\n const receiveMessage = (message) => {\n window.opener.postMessage(\n 'authorization:${content.provider}:success:${JSON.stringify(content)}',\n message.origin\n );\n\n window.removeEventListener(\"message\", receiveMessage, false);\n }\n\n window.addEventListener(\"message\", receiveMessage, false);\n\n window.opener.postMessage(\"authorizing:${content.provider}\", \"*\");\n </script>\n `;\n\n return new Response(script, {\n headers: { 'Content-Type': 'text/html' },\n });\n }\n catch (err) {\n console.error('OAuth callback error:', err);\n return redirect('/?error=oauth_failed');\n }\n}\n"],"mappings":";;;;;;;AAEO,IAAM,YAAY;AAEzB,eAAsB,IAAI,EAAE,KAAK,SAAS,GAAQ;AAChD,QAAM,OAAO,IAAI,aAAa,IAAI,MAAM;AAExC,MAAI,CAAC,MAAM;AACT,WAAO,IAAI,SAAS,mEAAmE;AAAA,MACrF,QAAQ;AAAA,MACR,SAAS,EAAE,gBAAgB,YAAY;AAAA,IACzC,CAAC;AAAA,EACH;AAEA,QAAM,OAAO;AAAA,IACX;AAAA,IACA,WAAW;AAAA,IACX,eAAe;AAAA,EACjB;AAEA,MAAI;AACF,UAAM,WAAW,MAAM,MAAM,UAAU;AAAA,MACrC,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,UAAU;AAAA,QACV,gBAAgB;AAAA,MAClB;AAAA,MACA,MAAM,KAAK,UAAU,IAAI;AAAA,IAC3B,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,IAAI,MAAM,uBAAuB,SAAS,MAAM,EAAE;AAAA,IAC1D;AAEA,UAAM,OAAO,MAAM,SAAS,KAAK;AAEjC,UAAM,UAAU;AAAA,MACd,OAAO,KAAK;AAAA,MACZ,UAAU;AAAA,IACZ;AAGA,UAAM,SAAS;AAAA;AAAA;AAAA;AAAA,6BAIU,QAAQ,QAAQ,YAAY,KAAK,UAAU,OAAO,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iDAS/B,QAAQ,QAAQ;AAAA;AAAA;AAI7D,WAAO,IAAI,SAAS,QAAQ;AAAA,MAC1B,SAAS,EAAE,gBAAgB,YAAY;AAAA,IACzC,CAAC;AAAA,EACH,SACO,KAAK;AACV,YAAQ,MAAM,yBAAyB,GAAG;AAC1C,WAAO,SAAS,sBAAsB;AAAA,EACxC;AACF;","names":[]}
@@ -1,4 +0,0 @@
1
- declare const prerender = false;
2
- declare function GET({ redirect }: any): any;
3
-
4
- export { GET, prerender };
@@ -1,14 +0,0 @@
1
- import {
2
- authUrl
3
- } from "../../chunk-JOUSWMWF.js";
4
-
5
- // src/oauth/astro-login.ts
6
- var prerender = false;
7
- function GET({ redirect }) {
8
- return redirect(authUrl);
9
- }
10
- export {
11
- GET,
12
- prerender
13
- };
14
- //# sourceMappingURL=astro-login.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/oauth/astro-login.ts"],"sourcesContent":["import { authUrl } from './config';\n\nexport const prerender = false;\n\nexport function GET({ redirect }: any) {\n return redirect(authUrl);\n}\n"],"mappings":";;;;;AAEO,IAAM,YAAY;AAElB,SAAS,IAAI,EAAE,SAAS,GAAQ;AACrC,SAAO,SAAS,OAAO;AACzB;","names":[]}