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

uwgws

v5.4.5

Published

Client Library for University of Washington's Groups Web Service

Downloads

7

Readme

UW Groups Web Service

This implements some of the v2 UW Groups Webservice endpoints. Each endpoint is queried using convienent options to build the final request to GWS.

This module assumes you have gone through all the required steps to gain and verify access as documented in their wiki.

Note: Version 4.0.0 and later require Node 8 Note: Version 5.0.0 and later use the GWS v3 JSON API. Responses from this library may be different because of changes in the GWS API output.

Installation

npm install uwgws

USE

First setup a config object to hold variables for your x509 cert and key as well as some optional caching of responses from the service. Cache options are detailed in the micro-cache node module.

The certInfo object should only contain either a file or an s3 object. If you include both, only the file object will be picked up.

let uwgws = require('uwgws');

let config = {
  baseUrl:   'https://iam-ws.u.washington.edu:7443/group_sws/v2/',
  cacheExt:  '.json',
  cacheMode: 'wild',
  cachePath: './cache/',
  certInfo:  {
    file: {
      cert: 'path-to-local/cert.pem',
      key:  'path-to-local/key.key'
    }
    // s3: {
    //   certBucket: 'Your certificate bucket here',
    //   certKey:    'Your certificate key here',
    //   keyBucket:  'Your key bucket here',
    //   keyKey:     'Your key key here'
    // }
  },
  logLevel: 'info'
};

await uwgws.initialize(config);

Now query for memberships for the desired group name or regid. Set effective: true if you want effective membership, otherwise false or not at all.

let options = {
  effective: true,
  id: 'uw_foster_staff_it_developers_nodegws-test'
};

let result = await uwgws.membership.get(options);
console.log(result);

Using a local cache

The cacheMode can be set to any one of the following modes. This uses the micro-cache node module as a local file system cache.

  • wild: all requests go out to the internet over HTTP, nothing is loaded from cache, and nothing is saved to the cache.
  • dryrun: Loads files from cache if it exists, uses HTTP calls when cache doesn't exist, doesn't save to the cache.
  • record: Loads files from the cache and saves new files to the cache.

Logging

This module uses log4js for all logging. Set an environment variable to a valid log level such as LOG_LEVEL=debug node script.js. Alternatively, the log level can be set using the logLevel property of the node-gws config.

Endpoint Implementation

All links below go to the official service documentation. The code block refers to the implemented method in this module.

Fully Supported

All of the uwgws methods return a promise for a result object that contains the following elements:

Return Object Element | Meaning ---------- | --------------- statusCode | This element represents the HTTP statusCode of the API response. data | This is the data element returned by the GWS API. If no data element is returned by the API, this will be an empty object. error | Boolean value represents the presence or absence of a business logic error. For example, adding an invalid netid to a valid group returns a statusCode of 200 but error = true. message | Array of error details returned by the API. Some operations return an "error" message when successful. notFound | Array of invalid UW Net IDs when adding members to a valid group. An add operation will return a status code of 200, a message of OK and the error element will be set to true when the notFound element is present.

All of the options parameters are outlined in src/modules/[endpoint].

Endpoint | Implementation ------------- | ------------- Membership - Get | uwgws.membership.get(options) Membership - Update | uwgws.membership.add(options) Membership - Replace | uwgws.membership.replaceMembership(options) Membership - Delete | uwgws.membership.del(options) Group - Create | uwgws.group.create(options) Group - Delete | uwgws.group.del(options) Group - History | uwgws.group.history(options) Search - Query | uwgws.search.query(options)

LDAP cache

The group service behind the GWS API uses LDAP caches to improve reliability and response time for some requests. The caches may take several seconds to update after changes to GWS are made. This can cause inconsistency in that you may not 'read what you wrote' during the time the cache is invalid.

If you need to ensure cache consistency, you can add sync: true to the options of group create and membership add operations. Note: query sting GWS is expecting is /?synchronized not /?synchronized=true

Development

git clone [email protected]:UWFosterIT/node-gws.git
cd node-gws
# create a branch as needed. don't work on master
npm install
cp test/setup/config-sample.js test/setup/config.js
# put appropriate values in the new config.js
npm test

It is recommended that you use the eval environment (https://eval.groups.uw.edu/group_sws/v3/) when developing/testing to avoid making lasting changes. And the search test will occasionally timeout if you are using prod.