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

spws-proxy

v1.0.10

Published

A SharePoint 2010 Web Service Proxy Server

Downloads

24

Readme

spws-proxy

A SharePoint 2010 Web Service Proxy Server that uses NTLM authentication.

Installation

$ npm i spws-proxy
$ npm i -g nodemon

Getting Started

Create a spws.proxy.config.js file in the root of your directory.

It is strongly recommended that you use environment variables or add spws.proxy.config.js .gitignore.

const config = {
  // The base URL of your SharePoint site
  baseUrl: "http://contoso/",
  // Windows username
  username: "john.smith",
  // Windows password
  password: "password1",
  // SharePoint Domain
  domain: "xyz",
  // Host
  host: "localhost",
  // Port
  port: 3050,
    // Object containing logging options
  logging: {
    // If true, responses from SharePoint will be logged in the console
    responses: true,
  },
};

module.exports = config;

How to run commands

Run directly from the command line.

$ nodemon ./node_modules/spws-proxy

You may find it easier to add the swps-proxy command to the scripts object in your package.json file and call it from an npm run script.

{
  "scripts": {
    "spws-proxy": "nodemon ./node_modules/spws-proxy"
  }
}

The proxy may only need to ran for specific reasons such as testing. In the example below a npm package named 'concurrently' is used to run the proxy and jest at the same time.

{
  "scripts": {
    "test":"concurrently \"nodemon ./node_modules/spws-proxy\" \"jest --watch\"",
  }
}

Testing with Jest

Testing SharePoint 2010 web services when using SPServices is difficult as it's not designed to with es6 modules.

To test using jest add the following code to the jest.setup.js (or however your just setup files are configured).

// Libraries
// Used for async requests
import "regenerator-runtime";

// This library exposes jQuery and SPervices to the window (uses for testing SPServices)
import "spsvcs";

// Import config
import config from "./spws.proxy.config";

// Set default webURL
window.$().SPServices.defaults.webURL = `//localhost:5050/http://mysite/sites/hr`;

// Or, set the default webURL with the config
window.$().SPServices.defaults.webURL = `//${config.host}:${config.port}/${config.baseUrl}/sites/hr`;

Alternate Authentication Methods

There are three ways to authenticate.

  1. Use the spws.proxy.config file to store credentials (recommended).
  2. Set the request headers in your web requests with the headers
    1. username
    2. password
  3. Using command line arguments

Request Headers

This method is not scure and should never be used for production applications.

The example below shows how to set the request headers.

xhr = new XMLHttpRequest();
xhr.open(
  "GET",
  `/sites/testing/_vti_bin/ListData.svc/UserInformationList(1)`,
  false
);
xhr.setRequestHeader("username", `john.smith`);
xhr.setRequestHeader("username", `password1`);

Command Line

$ nodemon ./node_modules/spws-proxy username=\"john.smith\" password=\"password1\"