Skip to content

Aligned command with tailscale login flow #428

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: staging
Choose a base branch
from

Conversation

aryanjassal
Copy link
Member

@aryanjassal aryanjassal commented Jun 23, 2025

Description

Issues Fixed

Tasks

  • 1. Update command to match RPC
  • 2. Update tests
  • 3. Add auto-open browser or optionally print the URL if browser can't be automatically detected

Final checklist

  • Domain specific tests
  • Full tests
  • Updated inline-comment documentation
  • Lint fixed
  • Squash and rebased
  • Sanity check the final build

@aryanjassal aryanjassal self-assigned this Jun 23, 2025
Copy link

linear bot commented Jun 23, 2025

ENG-620

@aryanjassal aryanjassal changed the title chore: aligned command with tailscale login flow Aligned command with tailscale login flow Jun 24, 2025
Copy link
Contributor

@shafiqihtsham shafiqihtsham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I just left some questions about things I was confused with. Just a bit of nitpicking as well with the command description and what is shown to the user. Otherwise this looks good to merge.

import * as binUtils from '../utils/index.js';
import * as binOptions from '../utils/options.js';
import * as errors from '../errors.js';

class CommandLogin extends CommandPolykey {
constructor(...args: ConstructorParameters<typeof CommandPolykey>) {
super(...args);
this.name('login');
this.description('Login to a platform with Polykey identity');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be `Login to a platform with your Polykey identity', just for user clarity.

const targetURL = new URL(
url.endsWith('/') ? url.slice(0, url.length) : url,
);
const subPath: string = options.returnURLPath ?? '/oauth2/oidc';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this check is needed anymore, because the command only expects the url now. So this can just be
const subPath = '/oauth2/oidc. Or is this for future cases, where the user should also provide the specific endpoint as well?

headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ token: compactHeader }),
});
process.stderr.write('Opening URL in browser...\n');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is all client facing code as the user will be reading this of course. So I think for clarity this should be changed to
Attempting to open this URL in your browser... just so the flow of the command is easier to understand for the user.

@@ -13,7 +13,7 @@
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"moduleResolution": "NodeNext",
"module": "ESNext",
"module": "NodeNext",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I mentioned this already in MatrixAI/Polykey#912 (review), but yeah I believe it should stay ESNext.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants