"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // pkg/dist-src/index.js var dist_src_exports = {}; __export(dist_src_exports, { oauthAuthorizationUrl: () => oauthAuthorizationUrl }); module.exports = __toCommonJS(dist_src_exports); function oauthAuthorizationUrl(options) { const clientType = options.clientType || "oauth-app"; const baseUrl = options.baseUrl || "https://github.com"; const result = { clientType, allowSignup: options.allowSignup === false ? false : true, clientId: options.clientId, login: options.login || null, redirectUrl: options.redirectUrl || null, state: options.state || Math.random().toString(36).substr(2), url: "" }; if (clientType === "oauth-app") { const scopes = "scopes" in options ? options.scopes : []; result.scopes = typeof scopes === "string" ? scopes.split(/[,\s]+/).filter(Boolean) : scopes; } result.url = urlBuilderAuthorize(`${baseUrl}/login/oauth/authorize`, result); return result; } function urlBuilderAuthorize(base, options) { const map = { allowSignup: "allow_signup", clientId: "client_id", login: "login", redirectUrl: "redirect_uri", scopes: "scope", state: "state" }; let url = base; Object.keys(map).filter((k) => options[k] !== null).filter((k) => { if (k !== "scopes") return true; if (options.clientType === "github-app") return false; return !Array.isArray(options[k]) || options[k].length > 0; }).map((key) => [map[key], `${options[key]}`]).forEach(([key, value], index) => { url += index === 0 ? `?` : "&"; url += `${key}=${encodeURIComponent(value)}`; }); return url; } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { oauthAuthorizationUrl });