10.0.1 • Published 1 year ago

uwsws v10.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
1 year ago

UW Student Web Service

This implements most of the v5 UW Student Webservice endpoints. Each endpoint is queried using convenient options to build the final request.

This module assumes you have gone through all the required steps to get access and verified that access as documented in the SWS wiki.

Note: Version 9.0.0 and later require Node 16 and only support ES6 modules at this time. CommonJS may be supported in the future.

USE

Installation

npm i uwsws

Configuration

Configuration options are passed as an object to the constructor.

organizationName

The organization name is a string that identifies your organization and will appear in the headers of requests to the UW SWS API. This helps when working with UW IT to debug your application.

baseUrl

The URL of the SWS server. You can use the test or production server.

auth: { cert: 'cert data', key: 'key data' }

The Student Web Service requires that you pass a valid UW x509 client certificate with all requests. The data returned from the request is restricted to what is authorized for your cert.

You can use the included certificate fetcher helpers to get cert and key data from local files, from an AWS S3 bucket, or you can create a custom fetcher.

uwSwsLogLevel

You can set the log level to silly, trace, debug, info, warn, error, fatal. If nothing is specified

import UwSws from 'uwsws';

const config = {
  organizationName: 'YOUR ORGANIZATION NAME',

  baseUrl: 'https://ws.admin.washington.edu/student/v5/',

  //uwSwsLogLevel: 'debug',

  // Change 'certData' property to the return value of the
  // 'readCertificate()' method if using a certFetcher helper.
  certData: {
    cert: 'PASS CERT STRING OR BUFFER HERE',
    key: 'PASS CERT STRING OR BUFFER HERE',
  },
};


const uwSws = new UwSws(config);

const termData = await uwSws.term.current();

console.log(termData);

Using the same config, get the intro to programming course for winter 2015.

let options = {
  year: 2015,
  quarter: 'winter',
  curriculum: 'cse',
  course: '142'
};

const courseData = await uwSws.course.get(options);

console.log(courseData);

For more use examples see the unit tests in __tests__/*.

For a full list of all the supported endpoints and options see src/endpoints/*.

If you find one that doesn't work or if an endpoint or option isn't supported, please create an issue.

Certificate Fetchers

This package includes a helper module to fetch client certificates using different methods. The built-in fetchers includes support for AWS S3 and the local file system. You can also create custom certificate fetchers. See the ./__tests__/certFetcher-test.ts file for a custom certFetcher example.

import { CertFetcherManager } from '../src/index';

// AWS S3 fetcher configuration options
const s3Config = {
  region: 'YOUR S3 REGION',
  certBucket: 'CERTIFICATE BUCKET NAME',
  certKey: 'CERTIFICATE KEY',
  keyBucket: 'KEY BUCKET NAME',
  keyKey: 'KEY KEY',
}

// Local file fetcher configuration options
const localConfig = {
      cert: 'PATH TO CERTIFICATE FILE',
      key: 'PATH TO KEY FILE',
    }

const certFetcherManager = new CertFetcherManager();

const s3Fetcher = certFetcherManager.getFetcher('s3');
const s3CertData = await s3Fetcher.readCertificate(s3Config);

const fileFetcher = certFetcherManager.getFetcher('file');
const fileCertData = await fileFetcher.readCertificate(localConfig);

// ... pass s3CertData or fileCertData to UwSws configuration object.

Endpoint Implementation

All of the UwSws methods return a promise for a result.

All links below go to the official service documentation. The code block refers to it's implementation in this module.

All of the option parameters are outlined in src/endpoint/* modules.

EndpointImplementation
CampusUwSws.campus.all()
College SearchUwSws.college.search(options)
CourseUwSws.course.get(options)
Course SearchUwSws.course.search(options)
Curriculum SearchUwSws.curriculum.search(options)
Department SearchUwSws.department.search(options)
EnrollmentUwSws.enrollment.getRegistrations(options)
Enrollment SearchUwSws.enrollment.getEnrolledTerms(options)
MajorUwSws.major.search(options)
PersonUwSws.person.get(regId)
Person SearchUwSws.person.search(options)
ProgramUwSws.program.get(options)
Program SearchUwSws.program.search(options)
Registration SearchUwSws.registration.search(options)
SectionUwSws.section.get(options)
Section SearchUwSws.section.search(options)
TermUwSws.term.next(), .previous(), .current(), currentAndNext(number?), and get(options)
Test ScoreUwSws.testScore.get(options)

Not Implemented

Most of these are not implemented due to additional security requirements beyond a simple 509 cert. Requirements such as permissions in ASTRA or x-uw-act-as permissions passed in the header. Feel free fork and make a pull request with working tests if you have those permissions. Others are simply planned for a future release.

extra security needed

not needed

Development

Copy __tests__/setup/config-sample.ts to __tests__/setup/config.ts and edit values as needed. Use the npm commands indicated in package.json.

npm test
10.0.0

1 year ago

10.0.1

1 year ago

9.0.2

1 year ago

9.0.1

2 years ago

9.0.0

2 years ago

8.0.0

4 years ago

7.1.1

5 years ago

7.1.0

6 years ago

7.0.0

6 years ago

6.2.0

7 years ago

6.1.1

7 years ago

6.1.0

8 years ago

6.0.3

8 years ago

6.0.2

8 years ago

6.0.1

8 years ago

6.0.0

8 years ago

5.0.0

8 years ago

4.5.1

8 years ago

4.5.0

8 years ago

4.4.0

8 years ago

4.3.1

8 years ago

4.3.0

8 years ago

4.2.0

8 years ago

4.1.0

8 years ago

4.0.0

8 years ago

3.0.0

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.2.0

8 years ago

1.1.0

8 years ago

1.0.1

9 years ago

1.0.0

9 years ago