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

@sassoftware/af-axios

v0.7.0

Published

Minimal Axios HTTP client wrapper with SAS authentication support

Downloads

158

Readme

SAS® af-axios

af-axios is a library used by afcli and Create SAS® App for handling and configuring axios for App Factory Cloud.

Usage

MSAL Provider

// Auth.js
import axios from 'axios';
import { useNavigate } from 'react-router';
import { MsalAuth } from '@sassoftware/af-axios/react';
import { MsalProvider } from '@azure/msal-react';

const clientId = 'myClientId'
const axiosInstance = axios.create({ baseUrl: 'https://myServer.com' })

const Auth = ({ children }) => {
  const navigate = useNavigate();
  const navigationClient = new CustomNavigationClient(navigate);
  msalInstance.setNavigationClient(navigationClient);

  return (
    <MsalProvider instance={msalInstance}>
      <MsalAuth
        axiosInstance={axiosInstance}
         authenticationRequest={{
          scopes: [`${clientId}/.default`],
        }}
      >
        {children}
      </MsalAuth>
    </MsalProvider>
  );
};

export default Auth;

You should be able to wrap your app (or specific routes) in Auth component and use useAxios hook to get an axios instance with Authorization header and 401 response handler.

For more information on how to provide msalInstance and CustomNavigationClient please see https://www.npmjs.com/package/@azure/msal-react

Af Authentication Provider

With environemnt and tenantId variabled
// index.js or app.js
import { AfAuthProvider } from '@sassoftware/af-axios/react';

// Or any other source for given variables
const { MSAL_CLIENT_ID, MSAL_ENVIRONMENT, MSAL_TENANT_ID, AF_URL } = import.meta.env; 

export const RootApp = () => (
  <ErrorBoundary>
    <Router>
      <AfAuthProvider
        url={AF_URL}
        clientId={MSAL_CLIENT_ID}
        environment={MSAL_ENVIRONMENT}
        tenantId={MSAL_TENANT_ID}
      >
        <App />
      </AfAuthProvider>
    </Router>
  </ErrorBoundary>
);
Custom msal instance
// index.js or app.js
import { AfAuthProvider } from '@sassoftware/af-axios/react';

// Or any other souce for given variables
const { MSAL_CLIENT_ID, AF_URL } = import.meta.env; 

const msalInstance = new PublicClientApplication({
  auth: {
    clientId: 'your client id',
    authority: `https://${your evironemnt}/${your tenant id}`,
  },
});

// any other msal configurations you may need

export const RootApp = () => (
  <ErrorBoundary>
    <Router>
      <AfAuthProvider
        url={AF_URL}
        clientId={MSAL_CLIENT_ID}
        msalInstance={msalInstance}
      >
        <App />
      </AfAuthProvider>
    </Router>
  </ErrorBoundary>
);

Local development

Running in a local project
  1. Run npm run build:release to create a build release
  2. Run npm pack to create a TAR archive file (.tgz). You should see the name of newly created file at the end of the output.
  3. Run npm install [.tgz path]. Make sure to replace [.tgz path] with a correct local path of a file created by npm pack command.
  4. Run your project

Cleanup

Previous set of commands will create a lot of files in the root of the project. To clean the files run git clean -d -f. Note that this command will remove all untracked files so a good idea might be a dry run with git clean -d -n before the actual cleanup.

Contributions

This project is currently intended for use by participants in the SAS Hackathon. During this event, the repository will refrain from accepting external contributions. However, we have plans to open source the project in the near future, at which point we will welcome contributions from the community.

Please note that after the SAS Hackathon concludes, this notice will be removed, and we will provide updated guidelines for contributing to the project once it becomes open source. We appreciate your understanding and look forward to collaborating with you in the future.