UNPKG

verdaccio-passport-google-oauth-ui

Version:
235 lines (198 loc) 13.1 kB
#!/usr/bin/env node var $jPguN$express = require("express"); var $jPguN$open = require("open"); var $jPguN$picocolors = require("picocolors"); var $jPguN$child_process = require("child_process"); var $jPguN$minimist = require("minimist"); var $jPguN$url = require("url"); function $parcel$interopDefault(a) { return a && a.__esModule ? a.default : a; } var $4e6a0abbae82ce34$exports = {}; $4e6a0abbae82ce34$exports = JSON.parse("{\"$schema\":\"http://json.schemastore.org/package\",\"name\":\"verdaccio-passport-google-oauth-ui\",\"version\":\"0.1.5\",\"keywords\":[\"authentication\",\"google\",\"login\",\"npm\",\"oauth\",\"package\",\"passport\",\"private\",\"registry\",\"verdaccio\",\"verdaccio-auth\",\"verdaccio-auth-plugin\",\"verdaccio-plugin\"],\"bugs\":\"https://github.com/okayasu/verdaccio-passport-google-oauth-ui/issues\",\"repository\":\"github:okayasu/verdaccio-passport-google-oauth-ui\",\"license\":\"MIT\",\"author\":\"Masanori Okayasu\",\"main\":\"dist/server/index.js\",\"bin\":\"dist/cli/index.js\",\"files\":[\"dist\",\"verdaccio.yaml\"],\"scripts\":{\"build\":\"bash run build\",\"clean\":\"bash run clean\",\"cli\":\"bash run cli\",\"cli:login\":\"bash run cli-login\",\"cli:publish\":\"bash run cli-publish\",\"cli:whoami\":\"bash run cli-whoami\",\"copy\":\"bash run copy\",\"coverage\":\"vitest --coverage\",\"dev\":\"yarn update && yarn start\",\"docker\":\"bash run docker_\",\"fix\":\"yarn format && yarn typecheck\",\"format\":\"prettier --write \\\"**/*.{ts,js,css,scss,html,json}\\\"\",\"format:check\":\"prettier --check \\\"**/*.{ts,js,css,scss,html,json}\\\"\",\"prepack\":\"bash run clean && bash run build\",\"start\":\"verdaccio -c verdaccio.yaml\",\"test\":\"vitest\",\"typecheck\":\"bash run typecheck\",\"update\":\"yarn prepack && yarn copy\",\"watch\":\"nodemon --watch src --watch verdaccio.yaml --ext ts,css,yaml --exec \\\"yarn dev\\\"\"},\"dependencies\":{\"@octokit/oauth-methods\":\"^4.1.0\",\"@octokit/request\":\"^8.4.0\",\"@verdaccio/url\":\"^11.0.0-6-next.42\",\"dotenv\":\"^16.4.5\",\"express\":\"^4.19.2\",\"global-agent\":\"^3.0.0\",\"lodash\":\"^4.17.21\",\"memory-cache\":\"^0.2.0\",\"minimist\":\"^1.2.8\",\"octokit\":\"^3.2.1\",\"open\":\"^8.4.2\",\"ow\":\"^0.28.2\",\"passport\":\"^0.5.3\",\"passport-google-oauth\":\"^2.0.0\",\"picocolors\":\"^1.0.1\",\"query-string\":\"^7.1.3\"},\"devDependencies\":{\"@parcel/config-default\":\"~2.4.1\",\"@parcel/transformer-typescript-tsc\":\"~2.4.1\",\"@types/express\":\"^4.17.21\",\"@types/global-agent\":\"^2.1.3\",\"@types/lodash\":\"^4.17.4\",\"@types/memory-cache\":\"^0.2.5\",\"@types/minimist\":\"^1.2.5\",\"@types/node\":\"^20.12.12\",\"@types/passport\":\"^1.0.17\",\"@types/passport-google-oauth\":\"^1.0.45\",\"@types/query-string\":\"^6.3.0\",\"@verdaccio/types\":\"^10.8.0\",\"@vitest/coverage-v8\":\"^1.6.0\",\"browserslist\":\"^4.23.0\",\"core-js\":\"^3.37.1\",\"nodemon\":\"^3.1.0\",\"parcel\":\"~2.4.1\",\"prettier\":\"^3.2.5\",\"process\":\"^0.11.10\",\"release-it\":\"^16.3.0\",\"timekeeper\":\"^2.3.1\",\"type-fest\":\"^4.18.2\",\"typescript\":\"^5.4.5\",\"verdaccio\":\"^5.30.3\",\"verdaccio-htpasswd\":\"^10.5.5\",\"vitest\":\"^1.6.0\"},\"peerDependencies\":{\"verdaccio\":\">=5\"},\"packageManager\":\"yarn@3.2.1\",\"publishConfig\":{\"registry\":\"https://registry.npmjs.org/\"},\"targets\":{\"client\":{\"source\":\"src/client/verdaccio-5.ts\",\"distDir\":\"dist/client\",\"context\":\"browser\",\"includeNodeModules\":true},\"server\":{\"source\":\"src/server/index.ts\",\"distDir\":\"dist/server\",\"context\":\"node\",\"outputFormat\":\"commonjs\",\"optimize\":false,\"isLibrary\":true},\"cli\":{\"source\":\"src/cli/index.ts\",\"distDir\":\"dist/cli\",\"context\":\"node\",\"outputFormat\":\"commonjs\",\"optimize\":false}}}"); const $0ff0f9ccaab5f0b2$export$3a689f099db7e338 = (/*@__PURE__*/$parcel$interopDefault($4e6a0abbae82ce34$exports)).name; const $0ff0f9ccaab5f0b2$export$18d4026d1ea86bb1 = (/*@__PURE__*/$parcel$interopDefault($4e6a0abbae82ce34$exports)).name.replace("verdaccio-", ""); const $0ff0f9ccaab5f0b2$export$42fcb85fa5803dac = "/-/oauth/authorize"; const $0ff0f9ccaab5f0b2$export$9e960429933a7149 = "/-/oauth/callback"; const $0ff0f9ccaab5f0b2$export$cf98473208e53590 = $0ff0f9ccaab5f0b2$export$42fcb85fa5803dac; const $0ff0f9ccaab5f0b2$export$bd46c9d2d39fc9 = "/"; const $0ff0f9ccaab5f0b2$export$3c6c1020e175037c = 8239; const $0ff0f9ccaab5f0b2$export$32fbdff0ec95e1c6 = "cli"; const $0ff0f9ccaab5f0b2$export$b3d17af05dbcae2f = "/oauth/authorize"; const $0ff0f9ccaab5f0b2$export$827c2d0b213c39b9 = [ "$all", "@all", "$authenticated", "@authenticated", ]; const $27d9f4d812c7c7d0$var$prefix = ($parcel$interopDefault($jPguN$picocolors)).blue(`[${$0ff0f9ccaab5f0b2$export$18d4026d1ea86bb1}]`); const $27d9f4d812c7c7d0$export$af88d00dbe7f521 = { log: console.log.bind(console, $27d9f4d812c7c7d0$var$prefix), error: (...args)=>console.error($27d9f4d812c7c7d0$var$prefix, ($parcel$interopDefault($jPguN$picocolors)).red(args.join(" "))) }; $27d9f4d812c7c7d0$export$af88d00dbe7f521.log(`Version: ${(/*@__PURE__*/$parcel$interopDefault($4e6a0abbae82ce34$exports)).name}@${(/*@__PURE__*/$parcel$interopDefault($4e6a0abbae82ce34$exports)).version}`); let $77f9f78a03afd49a$var$npmConfig; function $77f9f78a03afd49a$var$parseCliArgs() { return ($parcel$interopDefault($jPguN$minimist))(process.argv.slice(2)); } function $77f9f78a03afd49a$var$runCommand(command) { $27d9f4d812c7c7d0$export$af88d00dbe7f521.log(`Running command: ${command}`); return $jPguN$child_process.execSync(command).toString(); } function $77f9f78a03afd49a$var$getNpmConfig() { if (!$77f9f78a03afd49a$var$npmConfig) { const npmConfigJson = $77f9f78a03afd49a$var$runCommand("npm config list --json"); $77f9f78a03afd49a$var$npmConfig = JSON.parse(npmConfigJson); } return $77f9f78a03afd49a$var$npmConfig; } function $77f9f78a03afd49a$var$removeTrailingSlash(input) { return input.trim().replace(/\/?$/, ""); } function $77f9f78a03afd49a$export$b9447825ec1417f9() { const cliArgs = $77f9f78a03afd49a$var$parseCliArgs(); const registry = cliArgs.registry || $77f9f78a03afd49a$var$getNpmConfig().registry; return $77f9f78a03afd49a$var$removeTrailingSlash(registry); } function $77f9f78a03afd49a$export$e9d7a5792f65b33() { return $77f9f78a03afd49a$var$getNpmConfig().userconfig; } function $77f9f78a03afd49a$export$6237095459cb2d90(registry, token) { const url = new $jPguN$url.URL(registry); const baseUrl = url.host + url.pathname; return `npm config set //${baseUrl}:_authToken "${token}"`; } function $77f9f78a03afd49a$export$84ad69a37df73f4e(token) { const registry = $77f9f78a03afd49a$export$b9447825ec1417f9(); const command = $77f9f78a03afd49a$export$6237095459cb2d90(registry, token); $77f9f78a03afd49a$var$runCommand(command); } function $87e457a694cdb107$export$3d55ba16968d5eca(id) { return $0ff0f9ccaab5f0b2$export$42fcb85fa5803dac + "/" + (id || ":id?"); } function $87e457a694cdb107$export$d63ade3310945c4c(id) { return $0ff0f9ccaab5f0b2$export$9e960429933a7149 + (id ? "/" + id : ""); } function $19c91c785fe801aa$export$5f35a513ba5a4846(status, message) { switch(status){ case "success": $27d9f4d812c7c7d0$export$af88d00dbe7f521.log("All done! We've updated your npm configuration."); break; default: $27d9f4d812c7c7d0$export$af88d00dbe7f521.error(message); break; } } function $554c647dad55cbdd$export$9dc0174526f4c7e3() { return [ "It seems you are using the default npm registry.", "Please update it to your Verdaccio URL by either running:", "", "npm config set registry <URL>", "", "or by using the registry argument", "", `npx ${$0ff0f9ccaab5f0b2$export$3a689f099db7e338} --registry <URL>`, ]; } function $554c647dad55cbdd$export$3c268eaaecf1c199() { $554c647dad55cbdd$export$9dc0174526f4c7e3().forEach((line)=>$27d9f4d812c7c7d0$export$af88d00dbe7f521.log(line) ); } function $554c647dad55cbdd$export$8e2f23d5ad99376b() { const registry = $77f9f78a03afd49a$export$b9447825ec1417f9(); if (registry.includes("registry.npmjs.org")) { $554c647dad55cbdd$export$3c268eaaecf1c199(); process.exit(1); } return registry; } const $f90607f94337d454$var$styles = ` html, body { padding: 0; margin: 0; height: 100%; background-color: #e0e0e0; color: #24292F; font-family: Helvetica, sans-serif; position: relative; text-align: center; } .wrap { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); } a { color: #3f51b5; } .img { filter: drop-shadow(0 0.5rem 0.5rem #24292F80); width: 100px; } `.trim().replace(/\s+/g, " "); const $f90607f94337d454$var$logo = `<svg class="img" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 100 100"><defs/><defs><filter id="a" width="139.6%" height="140.4%" x="-20%" y="-12%" filterUnits="objectBoundingBox"><feOffset dy="4" in="SourceAlpha" result="shadowOffsetOuter1"/><feGaussianBlur in="shadowOffsetOuter1" result="shadowBlurOuter1" stdDeviation="2.5"/><feComposite in="shadowBlurOuter1" in2="SourceAlpha" operator="out" result="shadowBlurOuter1"/><feColorMatrix in="shadowBlurOuter1" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.0906646286 0"/></filter><filter id="c" width="167.9%" height="272.7%" x="-34%" y="-50%" filterUnits="objectBoundingBox"><feOffset dy="4" in="SourceAlpha" result="shadowOffsetOuter1"/><feGaussianBlur in="shadowOffsetOuter1" result="shadowBlurOuter1" stdDeviation="2.5"/><feColorMatrix in="shadowBlurOuter1" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.0906646286 0"/></filter><path id="b" d="M48 17L33 47h-9L0 0h15l13 25 5-8h15z"/><path id="d" d="M35 11h-7V9h8l2-3h-6V4h7l1-2h-4V0h20l-6 11H35z"/></defs><g fill="none" fill-rule="evenodd"><rect width="100" height="100" fill="#000" rx="37"/><g transform="translate(22 30)"><use fill="#000" filter="url(#a)" xlink:href="#b"/><use fill="#FFF" fill-opacity=".6" xlink:href="#b"/></g><g transform="translate(22 30)"><use fill="#000" filter="url(#c)" xlink:href="#d"/><use fill="#FFF" xlink:href="#d"/></g><path fill="#FFF" d="M55 77h-9L22 30h15l21 41z"/></g></svg>`; function $f90607f94337d454$export$54abf82a1c28d398(body, withBackLink) { const backButton = withBackLink ? `<p><a href="/">Go back</a></p>` : ""; return `<!DOCTYPE html> <html lang="en"> <head> <title>${$0ff0f9ccaab5f0b2$export$18d4026d1ea86bb1}</title> <style>${$f90607f94337d454$var$styles}</style> </head> <body> <div class="wrap"> ${$f90607f94337d454$var$logo} ${body} ${backButton} </div> </body> </html>`; } function $f90607f94337d454$export$1c5ed2c43abe9c5(error, withBackLink) { return $f90607f94337d454$export$54abf82a1c28d398(`<h1>Sorry :(</h1> <p>${error?.message || error}</p>`, withBackLink); } const $56726ac9886ce408$var$withBackLink = false; const $56726ac9886ce408$var$successPage = $f90607f94337d454$export$54abf82a1c28d398(`<h1>All done!</h1> <p>We've updated your npm configuration.</p> <p><code>${$77f9f78a03afd49a$export$e9d7a5792f65b33()}</code></p>`, $56726ac9886ce408$var$withBackLink); function $56726ac9886ce408$export$f93e7cc9911d107c(status, message, res) { res.setHeader("Content-Type", "text/html"); switch(status){ case "success": res.status(200); res.send($56726ac9886ce408$var$successPage); break; default: res.status(500); res.send($f90607f94337d454$export$1c5ed2c43abe9c5(message, $56726ac9886ce408$var$withBackLink)); break; } } const $00359fa519f78a4e$var$registry = $554c647dad55cbdd$export$8e2f23d5ad99376b(); const $00359fa519f78a4e$var$authorizeUrl = $00359fa519f78a4e$var$registry + $87e457a694cdb107$export$3d55ba16968d5eca($0ff0f9ccaab5f0b2$export$32fbdff0ec95e1c6); const $00359fa519f78a4e$var$server = ($parcel$interopDefault($jPguN$express))().get("/", (req, res)=>{ let status = req.query.status; let message = req.query.message; const token = decodeURIComponent(req.query.token); // We use `!status` for compatibility with plugin version <=2.3.0 // where there was no error handling and status differentiation yet. if (!status) status = "success"; try { if (status === "success") $77f9f78a03afd49a$export$84ad69a37df73f4e(token); } catch (error) { status = "error"; message = error.message; $27d9f4d812c7c7d0$export$af88d00dbe7f521.error(message); } $56726ac9886ce408$export$f93e7cc9911d107c(status, message, res); $19c91c785fe801aa$export$5f35a513ba5a4846(status, message); $00359fa519f78a4e$var$server.close(); process.exit(status === "success" ? 0 : 1); }).listen($0ff0f9ccaab5f0b2$export$3c6c1020e175037c, ()=>{ ($parcel$interopDefault($jPguN$open))($00359fa519f78a4e$var$authorizeUrl); }); //# sourceMappingURL=index.js.map