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

vanilla-aas

v0.1.2

Published

A package that integrates with AAS and CAMS. This all revolves around initially retrieving the **sid** and subsequently using that **sid** to authorize requests. The **sid** also gets stored in a cookie once logged in via AAS (blue screen login page)

Downloads

1

Readme

@census/vanilla-aas

A package that integrates with AAS and CAMS. This all revolves around initially retrieving the sid and subsequently using that sid to authorize requests. The sid also gets stored in a cookie once logged in via AAS (blue screen login page)

Features

  • Login via AAS
  • Retrieve CAMS permissions
  • Logout via AAS

Dependencies

Depends on the server having implemented one of the following AAS auth packages:

Install or Update of this package

Warning: Developers, if you are installing this package to your laptop, you will need to run the commands below via the Bash CLI. Running them via Power Shell or cmd, may not yield the expected results. To get the Bash CLI you will need toinstall Git for Windows via SWG

Install

npm install git+https://git.econ.census.gov/solar/npm-packages/vanilla/aas

Update

npm update git+https://git.econ.census.gov/solar/npm-packages/vanilla/aas

Configuration

| Property | Type | Required | Value | Example | | ----------- | ----------- | --- | -- | -- | | baseUrl | string | yes| The location of the census/laravel-aas implementation | https://this.backend.census.gov/api | | authRedirectUrl | string | yes | Where to redirect the user once login has been completed. | https://this.frontend.census.gov/#/auth/ | | headers | object | no | Additional headers to add to our request | [ { 'key1: 'value1' }, { 'key2': 'value2' } ] |

Usage

Import Package and create instance

import CensusAas from '@census/vanilla-aas'
const censusAas = new CensusAas({ 
  baseUrl: 'https://this.backend.census.gov/api', 
  authRedirectUrl: 'https://this.frontend.census.gov/auth', 
  headers: [
    { 'key1': 'value1' },
    { 'key2': 'value2' }
  ] 
});
Vue.prototype.$censusAas = censusAas;

Get User Information

censusAas.getUser(function (err, response) {

  if (err) {
    console.error('Error occured', err)
    return;
  }

  console.log('Success!', response);
});

Logout

censusAas.logout()

Response

{
  "forbidden": <true  | false >,
  "user": {
    "jbondid": "abcde012",
    "logged": 1,
    "sid": "12345678901234567890123456",
    "firstName": "First",
    "lastName": "Last",
    "niceName": "First Last",
    "division": "EAD",
    "email": "[email protected]",
    "phone": "301-763-XXXX",
    "superuser": 1,
    "office": "CENHQ-347uqie",
    "cams": {
      "groups": [
        "Group 1",
		"Group 2",
      ],
      "roles": [
        "Role 1",
		"Role 2"
      ],
      "permissions": [
        "Permission 1",
        "Permission 2"
      ]
    },
    "last_logged_at": "2021-09-27 20:21:23"
  }
}

Examples

Vue

Example: Solar / Boilerplates / vue2-vuetify-boilerplate · GitLab (census.gov)

.env

VUE_APP_AUTH_API_BASE_URL="https://this.backend.census.gov/api"
VUE_APP_AUTH_REDIRECT=https://this.frontend.census.gov/#/auth/

main.js

import Vue from 'vue'
import router from './router'
import App from './App.vue'

// AAS connectivity
import CensusAas from '@census/vanilla-aas'
const censusAas = new CensusAas({ 
  baseUrl: process.env.VUE_APP_AUTH_API_BASE_URL, 
  authRedirectUrl: process.env.VUE_APP_AUTH_REDIRECT, 
  headers: [
    { 'key1': 'value1' },
    { 'key2': 'value2' }
  ] 
});
Vue.prototype.$censusAas = censusAas;

new Vue({
  render: h => h(App),
  router,
  store: store,
  async beforeCreate() {
    const self = this
    
    censusAas.getUser(function (err, response) {
    
      if (err) {
		    console.error(err);
        return
      }

      // response contains user
      console.log(response)
    });

  },
}).$mount('#app')

router/index.js

import Vue from 'vue'
import Router from 'vue-router'
import Cookies from 'js-cookie'

Vue.use(Router);

let router = new Router({
    routes: [

        //AUTH
        {
            path: '/auth/:sid',
            redirect: to => {
                const {
                    query
                } = to;
                Cookies.set('sid', to.params.sid);
                return {
                    path: '/',
                    query: query
                }
            }
        }
    ]
})

export default router;

Developpers

To install a specific branch, use the following command (where <branch_name> is the name of the branch you want to pull:

npm install "git+https://git.econ.census.gov/solar/npm-packages/vanilla/aas#<branch_name>"