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

@test3207/mscba

v1.0.8

Published

Client for authentication with Microsoft Azure AD using OAuth2.0 with certificate

Downloads

15

Readme

Certificate Based Authentication Client With Microsoft Identity Platform

This is a personal project developed to provide certificate-based authentication with Microsoft accounts, as an alternative until the Microsoft Entra ID team provides an official solution/SDK. This project functions similarly to how msal-node handles other authentication methods such as acquireTokenByUsernamePassword.

Before using this project, you may want to explore the official authentication methods provided by Microsoft to determine if certificate-based authentication is necessary for your needs.

This project implements a Node.js client for authenticating with Microsoft accounts using certificates. For more information on the authentication flow, refer to the OAuth 2.0 authorization code flow documentation. To understand how to configure certificate-based authentication in your tenant, refer to the certificate-based authentication guide.

Does this package still work? Please check the status here! Livesite test status

Usage

Installation

npm install @test3207/mscba

Example

import { CBAClient } from "@test3207/mscba";
import fs from "fs";
const pfxBuffer = fs.readFileSync("path/to/certificate.pfx");

const client = new CBAClient(
  "[email protected]", // UPN
  "00000000-0000-0000-0000-000000000000", // Client ID
  pfxBuffer, // Buffer containing the PFX certificate. Notice that private key is required.
  ["https://graph.microsoft.com/User.Read"], // Scopes of resources to accessm. This is an example to access graph API
  "00000000-0000-0000-0000-000000000000" // Tenant ID, required if the client app is not multi-tenant
);

client.getAccessTokenAsync().then((accessTokenResponse) => {
  console.log(accessTokenResponse.expires_in); // around an hour in seconds
  console.log(accessTokenResponse.access_token); // now you can use it for your requests
});

Others

This project is a temporary solution, so I have only implemented the straightforward "happy path". Converting error information into readable content is quite challenging, given that many things could potentially go awry, and the error messages are in HTML format rather than JSON. You are welcome to add logs yourself for debugging purposes. If the Entra team does not provide a solution within a year, I will consider adding the necessary error handling myself. Alternatively, you are also welcome to contribute; PRs are appreciated!