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

@braveulysses/scim2

v0.1.3

Published

Simple SCIM 2 for JavaScript

Downloads

9

Readme

Build Status

scim2-js

This is a simple JavaScript library for SCIM 2 applications. SCIM 2 is a set of standards that defines a schema for representing identities and a REST API for creating, retrieving, updating, and deleting them.

This library's feature set is not exhaustive and covers a limited set of common cases. These include:

  • Parsing a JSON document into a SCIM resource object.
    • Getting attribute values from a SCIM object using SCIM paths like userName or emails[value eq "[email protected]"]. (Not supported: filters containing multiple expressions)
  • Modifying a SCIM resource object.
  • Building a PATCH request.

This library will help you parse SCIM responses and formulate certain kinds of requests, but it doesn't actually provide an HTTP client, since numerous generic options are already available that work well. For example, see Axios, whatwg-fetch, or isomorphic-fetch.

If you're looking for a SCIM 2 library with more comprehensive support for the SCIM 2 standard, see the UnboundID SCIM 2 SDK for Java. I'm not aware of a comparable JavaScript SDK.

Installation

npm install @braveulysses/scim2-js

Or

yarn add @braveulysses/scim2-js

API

See the generated API docs.

Example

import { Resource, Patch, Constants } from 'scim2-js';

const url = 'https://example.com/scim/v2/Users/7f93b9ae-85ce-4bce-baf8-1c18f25ace64';
const accessToken = '...';
const expectedUsername = '...';

// This example uses the Fetch API, but the request mechanism is up to you.
fetch(url, {
  method: 'get',
  headers: {
    'Authorization': 'Bearer ' + accessToken,
    'Accept': Constants.SCIM_MEDIA_TYPE
  }
}).then(function(response) {
  return response.json();
}).then(function(json) {
  const user = new Resource(json);
  expect(user.id()).toEqual('7f93b9ae-85ce-4bce-baf8-1c18f25ace64');
  expect(user.schemas()).toContain('urn:ietf:params:scim:schemas:core:2.0:User');
  expect(user.get('userName')).toEqual(expectedUsername);
  
  // Modify an attribute.
  const phoneNumbers = user.get('phoneNumbers');
  phoneNumbers.push({
    value: "+1 555 555 1234",
    type: "other",
    primary: false
  });
  user.set('phoneNumbers', phoneNumbers);
  // You could then apply the modification by replacing the resource with PUT.
  expect(user.get('phoneNumbers')).toEqual(phoneNumbers);
  
  // Alternatively, you could build a partial modification request...
  const patch = Patch.patchRequest(
    Patch.addOperation('phoneNumbers', {
      value: "+1 555 555 1234",
      type: "other",
      primary: false
    })
  );
  // ... and then apply the modification by sending a PATCH request.
});

API

License

This is licensed under the Apache License 2.0.