learn-auth-sdk 0.2.0 → 0.2.1

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/cli/index.js +21 -10
  2. package/package.json +1 -1
package/dist/cli/index.js CHANGED
@@ -193,11 +193,23 @@ async function loginCommand(options = {}) {
193
193
  throw new Error("Failed to generate device code");
194
194
  }
195
195
  const deviceData = await deviceResponse.json();
196
- console.log("\nTo authorize this device:");
197
- console.log(`1. Visit: ${deviceData.verification_uri}`);
198
- console.log(`2. Enter code: ${deviceData.user_code}`);
199
- console.log(`3. Complete 2FA verification`);
200
- console.log("\nOpening browser...\n");
196
+ console.log(`
197
+ Log in on ${baseUrl}`);
198
+ console.log("Login at:");
199
+ console.log(deviceData.verification_uri_complete);
200
+ console.log("\nPress ENTER to open in the browser...");
201
+ const readline = await import("readline");
202
+ const rl = readline.createInterface({
203
+ input: process.stdin,
204
+ output: process.stdout
205
+ });
206
+ await new Promise((resolve) => {
207
+ rl.question("", () => {
208
+ rl.close();
209
+ resolve();
210
+ });
211
+ });
212
+ console.log("Opening browser...\n");
201
213
  await openBrowser(deviceData.verification_uri_complete);
202
214
  let deviceAuthorized = false;
203
215
  const interval = deviceData.interval * 1e3;
@@ -244,14 +256,13 @@ async function loginCommand(options = {}) {
244
256
  throw new Error(errorData.message || "Failed to send 2FA code");
245
257
  }
246
258
  console.log("2FA code sent to your email.\n");
247
- const readline = await import("readline");
248
- const rl = readline.createInterface({
259
+ const rl2 = readline.createInterface({
249
260
  input: process.stdin,
250
261
  output: process.stdout
251
262
  });
252
263
  const tfaCode = await new Promise((resolve) => {
253
- rl.question("Enter 2FA code from email: ", (answer) => {
254
- rl.close();
264
+ rl2.question("Enter 2FA code from email: ", (answer) => {
265
+ rl2.close();
255
266
  resolve(answer);
256
267
  });
257
268
  });
@@ -335,7 +346,7 @@ async function deployCommand() {
335
346
 
336
347
  // src/cli/index.ts
337
348
  var program = new Command();
338
- program.name("learn-auth").description("CLI tool for managing Auth settings").version("0.1.0");
349
+ program.name("learn-auth").description("CLI tool for managing Auth settings").version("0.2.0");
339
350
  program.command("login").description("Authenticate via browser").action(loginCommand);
340
351
  program.command("init").description("Initialize auth config").action(initCommand);
341
352
  program.command("config").description("Configure roles and protected pages").option("--roles <roles>", "Comma separated roles").option("--protect <page>", "Page URL to protect").option("--allowed-roles <roles>", "Roles allowed to view protected page").action(configCommand);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "learn-auth-sdk",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Open-source Auth SDK for decentralized tenant backends",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",