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

node-ucwa

v1.0.4

Published

Setup a Http(s) server to proxy requests to UCWA via Node

Downloads

2

Readme

node-ucwa

Setup a Http(s) server to proxy requests to UCWA via Node

Purpose

UCWA exposes a frame-based mechanism for cross-domain communication for JavaScript which requires support for HTML5's postMessage. The iframe acts as a proxy between your application and UCWA and it will inject a header, X-Ms-Origin, which is checked against a cross-domain authorization list which is managed on the Lync Server. In cases where the devleoper does not have easy access to make changes to the Lync Server there aren't many options on how to work through this restriction.

This solution intends to provide a way to proxy requests to UCWA without appending X-Ms-Origin which is the behavior seen in any language communicating with UCWA other than JavaScript.

Version

  • 1.0.4
    • Less restrictive Access-Control-Allow-Origin (*)
  • 1.0.3
    • Fixed issue with Http server constructor not needing null as options parameter
    • Fixed issue with failing OPTIONS request missing CORS-related headers
    • Adding origin parameter to be used with Access-Control-Allow-Origin header
  • 1.0.2
    • Fixed issue running node-ucwa from a script
    • Updating certificate for localhost
  • 1.0.1
    • Removed dependency on express
    • Remove unused variables
    • Added redirects (307) when request isn't cased properly
    • Requests not to /proxy will fail 404
    • Non-POST requests to /proxy will result in 405
    • Code restructuring/cleanup
  • 1.0.0
    • Initial Release

How it Works

node> ucwa-proxy [--port --secure [--pfx --passphrase] --logging --origin]

  • --port - port to host server on (default 4666)
  • --secure - whether to host server as Http or Https (default true)
  • --pfx - path to PKCS#12 certificate file (default ./certs/node-ucwa.pfx)
  • --passphrase - optional certificate password (default '')
  • --logging - logs the request object prior to proxying (default false)
  • --origin - specify value for Access-Control-Allow-Origin header otherwise defaults to *

Structuring Proxy Requests

The request format expected by /proxy is as follows:

{
  url - url to proxy
  method - Http verb (get, post, put, delete),
  headers - optional collection of headers to apply to proxied request,
  data - optional request body
}

Simple Get

{
  "url": "https://lyncdiscover.domain.com",
  "method": "get"
}

Simple Post

{
  "url": "https://lync.domain.com/ucwa/oauth/v1/applications",
  "method": "post",
  "headers": {
    "authorization": "Bearer cwt=..."
  },
  "data": {
    "userAgent": "node-ucwa",
    "endpointId": "node",
    "culture": "en-US"
  }
}

Request Caveats

  • If no Content-Type header is provided for the proxied request it is assumed that data refers to application/json.
  • Content-Length does not need to be provided as it is calculated before sending based on the size of provided data object
  • If the request fails and Node returns an error it is currently defaulting to responding as if a 404 occurred (probably not the most correct)

Samples

Located in a Samples folder

Simple - Demonstration of proxying requests to UCWA including auto-discovery, authentication, application creation and deletion

Dependencies

  • fs - reading certificate files
  • minimist - commandline argument processing
  • http/https - hosting proxy server and issuing requests/responses
  • url - url processing