oauth-init 0.13.0 → 0.14.0

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.
Files changed (2) hide show
  1. package/dist/index.js +38 -46
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1848,7 +1848,7 @@ ${l}
1848
1848
  } }).prompt();
1849
1849
 
1850
1850
  // src/index.ts
1851
- import path8 from "path";
1851
+ import path7 from "path";
1852
1852
  import fs6 from "fs";
1853
1853
 
1854
1854
  // node_modules/is-plain-obj/index.js
@@ -9371,8 +9371,6 @@ Opening: ${brandUrl}`);
9371
9371
  }
9372
9372
 
9373
9373
  // src/lib/github-provider.ts
9374
- import { writeFile as writeFile2, unlink } from "fs/promises";
9375
- import path7 from "path";
9376
9374
  import http from "http";
9377
9375
  function logStep2(message) {
9378
9376
  if (!globalConfig.quiet)
@@ -9417,7 +9415,6 @@ class GitHubAuthProvider {
9417
9415
  return Ne("Setup aborted.");
9418
9416
  const PORT = 3004;
9419
9417
  const REDIRECT_URI = `http://localhost:${PORT}/callback`;
9420
- const tempPath = path7.join(process.cwd(), "github-setup.html");
9421
9418
  const manifest = {
9422
9419
  name: "oauth-init-app",
9423
9420
  url: "http://localhost:3000",
@@ -9439,48 +9436,43 @@ class GitHubAuthProvider {
9439
9436
  </body>
9440
9437
  </html>
9441
9438
  `;
9442
- try {
9443
- await writeFile2(tempPath, htmlContent);
9444
- logStep2("GitHub App Configuration");
9445
- logMessage2("Opening GitHub with your manifest...");
9446
- if (!globalConfig.noOpen) {
9447
- await open_default(tempPath);
9448
- }
9449
- return new Promise((resolve) => {
9450
- const server = http.createServer(async (req, res) => {
9451
- const url = new URL(req.url, `http://localhost:${PORT}`);
9452
- const code = url.searchParams.get("code");
9453
- if (code) {
9454
- res.end("<h1>Success!</h1><p>You can close this tab and return to the CLI.</p>");
9455
- const s = bt2();
9456
- s.start("Exchanging code for secrets...");
9457
- try {
9458
- const { stdout } = await execa("curl", [
9459
- "-X",
9460
- "POST",
9461
- `https://api.github.com/app-manifests/${code}/conversions`
9462
- ]);
9463
- const credentials = JSON.parse(stdout);
9464
- const { client_id, client_secret } = credentials;
9465
- s.stop("Credentials received!");
9466
- await saveCredentials(client_id, client_secret, "github", saveOption);
9467
- server.close();
9468
- resolve();
9469
- } catch {
9470
- s.error("Failed to convert manifest code.");
9471
- server.close();
9472
- resolve();
9473
- }
9439
+ logStep2("GitHub App Configuration");
9440
+ logMessage2("Opening GitHub with your manifest...");
9441
+ return new Promise((resolve) => {
9442
+ const server = http.createServer(async (req, res) => {
9443
+ const url = new URL(req.url, `http://localhost:${PORT}`);
9444
+ const code = url.searchParams.get("code");
9445
+ if (code) {
9446
+ res.end("<h1>Success!</h1><p>You can close this tab and return to the CLI.</p>");
9447
+ const s = bt2();
9448
+ s.start("Exchanging code for secrets...");
9449
+ try {
9450
+ const { stdout } = await execa("curl", [
9451
+ "-X",
9452
+ "POST",
9453
+ `https://api.github.com/app-manifests/${code}/conversions`
9454
+ ]);
9455
+ const credentials = JSON.parse(stdout);
9456
+ const { client_id, client_secret } = credentials;
9457
+ s.stop("Credentials received!");
9458
+ await saveCredentials(client_id, client_secret, "github", saveOption);
9459
+ server.close();
9460
+ resolve();
9461
+ } catch {
9462
+ s.error("Failed to convert manifest code.");
9463
+ server.close();
9464
+ resolve();
9474
9465
  }
9475
- }).listen(PORT);
9466
+ } else {
9467
+ res.writeHead(200, { "Content-Type": "text/html" });
9468
+ res.end(htmlContent);
9469
+ }
9470
+ }).listen(PORT, async () => {
9471
+ if (!globalConfig.noOpen) {
9472
+ await open_default(REDIRECT_URI);
9473
+ }
9476
9474
  });
9477
- } catch (err) {
9478
- R2.error(`Setup failed: ${err.message}`);
9479
- } finally {
9480
- try {
9481
- await unlink(tempPath);
9482
- } catch {}
9483
- }
9475
+ });
9484
9476
  }
9485
9477
  async setupOAuthApp(callbackUrl) {
9486
9478
  logStep2("Step 1: Create OAuth App on GitHub");
@@ -9526,7 +9518,7 @@ var AUTH_LIBRARIES = [
9526
9518
  { name: "iron-session", callbackPattern: "/api/auth/callback" }
9527
9519
  ];
9528
9520
  function detectAuthLibrary() {
9529
- const packageJsonPath = path8.join(process.cwd(), "package.json");
9521
+ const packageJsonPath = path7.join(process.cwd(), "package.json");
9530
9522
  if (!fs6.existsSync(packageJsonPath)) {
9531
9523
  return null;
9532
9524
  }
@@ -9619,7 +9611,7 @@ Examples:
9619
9611
  }
9620
9612
  globalConfig.quiet = flags.quiet;
9621
9613
  globalConfig.noOpen = flags.noOpen;
9622
- const projectDirectoryName = path8.basename(process.cwd());
9614
+ const projectDirectoryName = path7.basename(process.cwd());
9623
9615
  We(`
9624
9616
  ▗▄▖ ▗▄▖ ▗▖ ▗▖▗▄▄▄▖▗▖ ▗▖ ▗▄▄▄▖▗▖ ▗▖▗▄▄▄▖▗▄▄▄▖
9625
9617
  ▐▌ ▐▌▐▌ ▐▌▐▌ ▐▌ █ ▐▌ ▐▌ █ ▐▛▚▖▐▌ █ █
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oauth-init",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "CLI for setting up OAuth providers for your project",
5
5
  "license": "MIT",
6
6
  "type": "module",