npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vsts-device-flow-auth

v1.136.0

Published

Device Flow authentication package for Visual Studio Team Services

Downloads

42

Readme

Visual Studio Team Services Device Flow Authentication for Node.js

vsts-device-flow-auth is a small library that helps your Node.js application's users interactively authenticate to Visual Studio Team Services. It supports both Azure Active Directory-backed (AAD) and Microsoft Account-backed (MSA) Team Services accounts. When the authentication is complete, the Node.js application receives a personal access token to use on the Team Services user's behalf.

Install

$ npm install --save vsts-device-flow-auth

Usage

Create a DeviceFlowAuthenticator with the URI of the user's Team Services account. You will also need to provide your application's client id and redirect Uri. For information on how to register an application with Azure, see How to register an app with the v2.0 endpoint for details.

const authOptions: IDeviceFlowAuthenticationOptions = {
    clientId: '00000000-0000-0000-0000-000000000000',
    redirectUri: 'https://some-url.com'
};
const dfa: DeviceFlowAuthenticator = new DeviceFlowAuthenticator("https://my-corporate-account.visualstudio.com", authOptions);

Call GetDeviceFlowDetails() to acquire the device_code, verification_url and optional message for the user to authenticate with Team Services.

const obj: DeviceFlowDetails = await dfa.GetDeviceFlowDetails();

Call WaitForPersonalAccessToken() to get the token to use on the user's behalf.

const pat: string = await dfa.WaitForPersonalAccessToken();

Below is a short TypeScript example of how to use the package. A complete example can be found in the GitHub repository.

import { DeviceFlowAuthenticator, DeviceFlowDetails, IDeviceFlowAuthenticationOptions, IDeviceFlowTokenOptions } from 'vsts-device-flow-auth';

async function run() {
    const resourceUri: string = `https://my-corporate-account.visualstudio.com`;
    //const resourceUri: string = `https://my-personal-account.visualstudio.com`;

    const authOptions: IDeviceFlowAuthenticationOptions = {
        clientId: '00000000-0000-0000-0000-000000000000',
        redirectUri: 'https://some-url.com'
    };
    const tokenOptions: IDeviceFlowTokenOptions = {
        tokenDescription: `vsts-device-flow-auth test app: ${resourceUri} on ${os.hostname()}`,
    };
    const dfa: DeviceFlowAuthenticator = new DeviceFlowAuthenticator(resourceUri, authOptions, tokenOptions);

    const obj: DeviceFlowDetails = await dfa.GetDeviceFlowDetails();
    console.log(`message: ${obj.Message}`);
    console.log(`user code: ${obj.UserCode}`);
    console.log(`verify url: ${obj.VerificationUrl}`);

    console.log(`Go do the Device Flow authentication...`);
    console.log(``);

    const pat: string = await dfa.WaitForPersonalAccessToken();
    console.log(pat);
}

run();

Support

Support for this project is provided on our GitHub Issue Tracker. You can submit a bug report, a feature request or participate in discussions.

Contributing

To contribute to this project, see the Contributing Guide.

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Privacy Statement

The Microsoft Visual Studio Product Family Privacy Statement describes the privacy statement of this software.

License

This extension is licensed under the MIT License. Please see the third-party notices file for additional copyright notices and license terms applicable to portions of the software.