oauth-init 0.12.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.
- package/dist/index.js +38 -46
- package/package.json +15 -1
package/dist/index.js
CHANGED
|
@@ -1848,7 +1848,7 @@ ${l}
|
|
|
1848
1848
|
} }).prompt();
|
|
1849
1849
|
|
|
1850
1850
|
// src/index.ts
|
|
1851
|
-
import
|
|
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
|
-
|
|
9443
|
-
|
|
9444
|
-
|
|
9445
|
-
|
|
9446
|
-
|
|
9447
|
-
|
|
9448
|
-
|
|
9449
|
-
|
|
9450
|
-
|
|
9451
|
-
|
|
9452
|
-
|
|
9453
|
-
|
|
9454
|
-
|
|
9455
|
-
|
|
9456
|
-
|
|
9457
|
-
|
|
9458
|
-
|
|
9459
|
-
|
|
9460
|
-
|
|
9461
|
-
|
|
9462
|
-
|
|
9463
|
-
|
|
9464
|
-
|
|
9465
|
-
|
|
9466
|
-
|
|
9467
|
-
|
|
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
|
-
}
|
|
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
|
-
}
|
|
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 =
|
|
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 =
|
|
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.
|
|
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",
|
|
@@ -14,6 +14,20 @@
|
|
|
14
14
|
"prepare": "bun run build",
|
|
15
15
|
"test": "bun test"
|
|
16
16
|
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"cli",
|
|
19
|
+
"oauth",
|
|
20
|
+
"oauth2",
|
|
21
|
+
"authentication",
|
|
22
|
+
"auth",
|
|
23
|
+
"google",
|
|
24
|
+
"github",
|
|
25
|
+
"credentials",
|
|
26
|
+
"setup",
|
|
27
|
+
"interactive",
|
|
28
|
+
"bun",
|
|
29
|
+
"typescript"
|
|
30
|
+
],
|
|
17
31
|
"dependencies": {
|
|
18
32
|
"@clack/prompts": "^1.0.1",
|
|
19
33
|
"@types/bun": "^1.3.9",
|