verdaccio-passport-google-oauth-ui
Version:
<h1 align="center"> 📦🔐 Verdaccio Google OAuth </h1>
251 lines (213 loc) • 13.7 kB
JavaScript
#!/usr/bin/env node
var $6DKQV$express = require("express");
var $6DKQV$open = require("open");
var $6DKQV$picocolors = require("picocolors");
var $6DKQV$child_process = require("child_process");
var $6DKQV$minimist = require("minimist");
var $6DKQV$url = require("url");
function $parcel$interopDefault(a) {
return a && a.__esModule ? a.default : a;
}
var $d3fc45f844772ec5$exports = {};
$d3fc45f844772ec5$exports = JSON.parse("{\"$schema\":\"http://json.schemastore.org/package\",\"name\":\"verdaccio-passport-google-oauth-ui\",\"version\":\"0.1.10\",\"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\":{\"url\":\"git+https://github.com/okayasu/verdaccio-passport-google-oauth-ui.git\"},\"license\":\"MIT\",\"author\":\"Masanori Okayasu\",\"main\":\"dist/server/index.js\",\"bin\":{\"verdaccio-passport-google-oauth-ui\":\"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\":\"run-s update start\",\"docker\":\"bash run docker_\",\"fix\":\"run-s format 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\":\"run-s prepack copy\",\"watch\":\"nodemon --watch src --watch verdaccio.yaml --ext ts,css,yaml --exec \\\"bun dev\\\"\"},\"dependencies\":{\"@verdaccio/core\":\"^8.0.0-next-8.31\",\"@verdaccio/url\":\"^13.0.0-next-8.31\",\"copy-to-clipboard\":\"^3.3.3\",\"dotenv\":\"^17.3.1\",\"express\":\"^5.1.0\",\"global-agent\":\"^3.0.0\",\"lodash\":\"^4.17.23\",\"minimist\":\"^1.2.8\",\"open\":\"^11.0.0\",\"ow\":\"^3.1.1\",\"passport\":\"^0.7.0\",\"passport-google-oauth\":\"^2.0.0\",\"picocolors\":\"^1.1.1\"},\"devDependencies\":{\"@parcel/config-default\":\"^2.16.4\",\"@parcel/transformer-typescript-tsc\":\"^2.16.4\",\"@types/express\":\"^5.0.3\",\"@types/global-agent\":\"^3.0.0\",\"@types/lodash\":\"^4.17.24\",\"@types/minimist\":\"^1.2.5\",\"@types/node\":\"^24.12.0\",\"@types/passport\":\"^1.0.17\",\"@types/passport-google-oauth\":\"^1.0.45\",\"@verdaccio/types\":\"^13.0.0-next-8.11\",\"@vitest/coverage-v8\":\"^4.0.18\",\"browserslist\":\"^4.28.1\",\"core-js\":\"^3.48.0\",\"nodemon\":\"^3.1.14\",\"npm-run-all2\":\"^8.0.4\",\"parcel\":\"^2.16.4\",\"prettier\":\"^3.8.1\",\"process\":\"^0.11.10\",\"timekeeper\":\"^2.3.1\",\"type-fest\":\"^5.4.4\",\"typescript\":\"^5.9.3\",\"verdaccio\":\"^6.3.1\",\"verdaccio-htpasswd\":\"^13.0.0-next-8.31\",\"vite-tsconfig-paths\":\"^6.1.1\",\"vitest\":\"^4.0.18\"},\"peerDependencies\":{\"verdaccio\":\">=6\"},\"engines\":{\"node\":\">=20\"},\"publishConfig\":{\"registry\":\"https://registry.npmjs.org/\"},\"targets\":{\"client\":{\"source\":\"src/client/verdaccio-6.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 $1fdeffa608173849$export$3a689f099db7e338 = (0, (/*@__PURE__*/$parcel$interopDefault($d3fc45f844772ec5$exports))).name;
const $1fdeffa608173849$export$18d4026d1ea86bb1 = (0, (/*@__PURE__*/$parcel$interopDefault($d3fc45f844772ec5$exports))).name.replace("verdaccio-", "");
const $1fdeffa608173849$export$42fcb85fa5803dac = "/-/oauth/authorize";
const $1fdeffa608173849$export$9e960429933a7149 = "/-/oauth/callback";
const $1fdeffa608173849$export$cf98473208e53590 = $1fdeffa608173849$export$42fcb85fa5803dac;
const $1fdeffa608173849$export$bd46c9d2d39fc9 = "/";
const $1fdeffa608173849$export$3c6c1020e175037c = 8239;
const $1fdeffa608173849$export$32fbdff0ec95e1c6 = "cli";
const $1fdeffa608173849$export$b3d17af05dbcae2f = "/oauth/authorize";
const $1fdeffa608173849$export$827c2d0b213c39b9 = [
"$all",
"@all",
"$authenticated",
"@authenticated"
];
const $b5c1042701d60118$var$prefix = (0, ($parcel$interopDefault($6DKQV$picocolors))).blue(`[${(0, $1fdeffa608173849$export$18d4026d1ea86bb1)}]`);
function $b5c1042701d60118$var$toString(arg) {
if (typeof arg === "string") return arg;
if (typeof arg === "object") try {
return JSON.stringify(arg);
} catch {
// ignore
}
return String(arg);
}
const $b5c1042701d60118$export$af88d00dbe7f521 = {
log: (...args)=>{
console.log($b5c1042701d60118$var$prefix, args.map($b5c1042701d60118$var$toString).join(" "));
},
debug: (...args)=>{
console.debug($b5c1042701d60118$var$prefix, (0, ($parcel$interopDefault($6DKQV$picocolors))).gray(args.map($b5c1042701d60118$var$toString).join(" ")));
},
error: (...args)=>{
console.error($b5c1042701d60118$var$prefix, (0, ($parcel$interopDefault($6DKQV$picocolors))).red(args.map($b5c1042701d60118$var$toString).join(" ")));
}
};
$b5c1042701d60118$export$af88d00dbe7f521.log(`Version: ${(0, (/*@__PURE__*/$parcel$interopDefault($d3fc45f844772ec5$exports))).name}@${(0, (/*@__PURE__*/$parcel$interopDefault($d3fc45f844772ec5$exports))).version}`);
let $1183ffd67d0cc5bd$var$npmConfig;
function $1183ffd67d0cc5bd$var$parseCliArgs() {
return (0, ($parcel$interopDefault($6DKQV$minimist)))(process.argv.slice(2));
}
function $1183ffd67d0cc5bd$var$runCommand(command) {
(0, $b5c1042701d60118$export$af88d00dbe7f521).log(`Running command: ${command}`);
return (0, $6DKQV$child_process.execSync)(command).toString();
}
function $1183ffd67d0cc5bd$var$getNpmConfig() {
if (!$1183ffd67d0cc5bd$var$npmConfig) {
const npmConfigJson = $1183ffd67d0cc5bd$var$runCommand("npm config list --json");
$1183ffd67d0cc5bd$var$npmConfig = JSON.parse(npmConfigJson);
}
return $1183ffd67d0cc5bd$var$npmConfig;
}
function $1183ffd67d0cc5bd$var$removeTrailingSlash(input) {
return input.trim().replace(/\/?$/, "");
}
function $1183ffd67d0cc5bd$export$b9447825ec1417f9() {
const cliArgs = $1183ffd67d0cc5bd$var$parseCliArgs();
const registry = cliArgs.registry || $1183ffd67d0cc5bd$var$getNpmConfig().registry;
return $1183ffd67d0cc5bd$var$removeTrailingSlash(registry);
}
function $1183ffd67d0cc5bd$export$e9d7a5792f65b33() {
return $1183ffd67d0cc5bd$var$getNpmConfig().userconfig;
}
function $1183ffd67d0cc5bd$export$6237095459cb2d90(registry, token) {
const url = new (0, $6DKQV$url.URL)(registry);
const baseUrl = url.host + url.pathname;
return `npm config set //${baseUrl}:_authToken "${token}"`;
}
function $1183ffd67d0cc5bd$export$84ad69a37df73f4e(token) {
const registry = $1183ffd67d0cc5bd$export$b9447825ec1417f9();
const command = $1183ffd67d0cc5bd$export$6237095459cb2d90(registry, token);
$1183ffd67d0cc5bd$var$runCommand(command);
}
function $f663f50707cffa49$export$3d55ba16968d5eca(id) {
return (0, $1fdeffa608173849$export$42fcb85fa5803dac) + "/" + (id || ":id?");
}
function $f663f50707cffa49$export$d63ade3310945c4c(id) {
return (0, $1fdeffa608173849$export$9e960429933a7149) + (id ? "/" + id : "");
}
function $dabaf2027254d594$export$5f35a513ba5a4846(status, message) {
switch(status){
case "success":
(0, $b5c1042701d60118$export$af88d00dbe7f521).log("All done! We've updated your npm configuration.");
break;
default:
(0, $b5c1042701d60118$export$af88d00dbe7f521).error(message);
break;
}
}
function $005dad821726ae75$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 ${(0, $1fdeffa608173849$export$3a689f099db7e338)} --registry <URL>`
];
}
function $005dad821726ae75$export$3c268eaaecf1c199() {
$005dad821726ae75$export$9dc0174526f4c7e3().forEach((line)=>(0, $b5c1042701d60118$export$af88d00dbe7f521).log(line));
}
function $005dad821726ae75$export$8e2f23d5ad99376b() {
const registry = (0, $1183ffd67d0cc5bd$export$b9447825ec1417f9)();
if (registry.includes("registry.npmjs.org")) {
$005dad821726ae75$export$3c268eaaecf1c199();
process.exit(1);
}
return registry;
}
const $c7abc211818da8d6$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 $c7abc211818da8d6$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 $c7abc211818da8d6$export$54abf82a1c28d398(body, withBackLink) {
const backButton = withBackLink ? `<p><a href="/">Go back</a></p>` : "";
return `<!DOCTYPE html>
<html lang="en">
<head>
<title>${0, $1fdeffa608173849$export$18d4026d1ea86bb1}</title>
<style>${$c7abc211818da8d6$var$styles}</style>
</head>
<body>
<div class="wrap">
${$c7abc211818da8d6$var$logo}
${body}
${backButton}
</div>
</body>
</html>`;
}
function $c7abc211818da8d6$export$1c5ed2c43abe9c5(error, withBackLink) {
return $c7abc211818da8d6$export$54abf82a1c28d398(`<h1>Sorry :(</h1>
<p>${error?.message || error}</p>`, withBackLink);
}
const $f3208b5c6da3c562$var$withBackLink = false;
const $f3208b5c6da3c562$var$successPage = (0, $c7abc211818da8d6$export$54abf82a1c28d398)(`<h1>All done!</h1>
<p>We've updated your npm configuration.</p>
<p><code>${(0, $1183ffd67d0cc5bd$export$e9d7a5792f65b33)()}</code></p>`, $f3208b5c6da3c562$var$withBackLink);
function $f3208b5c6da3c562$export$f93e7cc9911d107c(status, message, res) {
res.setHeader("Content-Type", "text/html");
switch(status){
case "success":
res.status(200);
res.send($f3208b5c6da3c562$var$successPage);
break;
default:
res.status(500);
res.send((0, $c7abc211818da8d6$export$1c5ed2c43abe9c5)(message, $f3208b5c6da3c562$var$withBackLink));
break;
}
}
const $8c9ff3b529c51a73$var$registry = (0, $005dad821726ae75$export$8e2f23d5ad99376b)();
const $8c9ff3b529c51a73$var$authorizeUrl = $8c9ff3b529c51a73$var$registry + (0, $f663f50707cffa49$export$3d55ba16968d5eca)((0, $1fdeffa608173849$export$32fbdff0ec95e1c6));
const $8c9ff3b529c51a73$var$server = (0, ($parcel$interopDefault($6DKQV$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") (0, $1183ffd67d0cc5bd$export$84ad69a37df73f4e)(token);
} catch (error) {
status = "error";
message = error.message;
(0, $b5c1042701d60118$export$af88d00dbe7f521).error(message);
}
(0, $f3208b5c6da3c562$export$f93e7cc9911d107c)(status, message, res);
(0, $dabaf2027254d594$export$5f35a513ba5a4846)(status, message);
$8c9ff3b529c51a73$var$server.close();
process.exit(status === "success" ? 0 : 1);
}).listen((0, $1fdeffa608173849$export$3c6c1020e175037c), ()=>{
(0, ($parcel$interopDefault($6DKQV$open)))($8c9ff3b529c51a73$var$authorizeUrl);
});
//# sourceMappingURL=index.js.map