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

unifiedpush-admin-client

v0.5.0

Published

Admin REST client for the AeroGear UnifiedPush Server

Downloads

5

Readme

Build Status Coverage Status

Unified Push Admin Client

A client for connecting to the AeroGear UnifiedPush servers admin REST API - https://aerogear.org/docs/specs/aerogear-unifiedpush-rest/#home

API Documentation

http://bucharest-gold.github.io/unifiedpush-admin-client/

Example

'use strict';

let adminClient = require('unifiedpush-admin-client');

let baseUrl = 'http://127.0.0.1:8080/ag-push';

let settings = {
    username: 'admin',
    password: 'admin'
};

adminClient(baseUrl, settings)
  .then((client) => {
    return client.applications.find()
      .then((applications) => {
        console.log('applications', applications);
      });
  })
  .catch((err) => {
    console.log('Error', err);
  });

Variants

The 0.2.0 release brings in the methods to interact with the Variants. To learn more about what exactly a variant is in terms of the Unified Push Server, checkout their docs here: https://aerogear.org/docs/unifiedpush/ups_userguide/index/#_useful_terminology

The find method for variants is similiar to the find method for applications. The difference is that you need to specify a type along with the pushAppId

Example of Find all Variants for Type for a Push Application(note: we are only showing a snippet of code here. assume we have the client object already)

const variantOptions = {
  pushAppId: 'PUSH_APPLICATION_ID',
  type: 'android'
};


client.variants.find(variantOptions).then((variants) => {
  console.log(variants); // will show the list of android variants
});

For the available Device Types, there is a constant called client.DEVICE_TYPES for convience, https://github.com/bucharest-gold/unifiedpush-admin-client/blob/master/lib/device-types.js

Create example:

const variantOptions = {
  pushAppId: 'PUSH_APPLICATION_ID',
  name: 'My Cool App',
  type: 'android',
  android: {
    googleKey: 'SOME_GOOGLE_API_KEY',
    projectNumber: 'SOME_GOOGLE_PROJECT_NUMBER'
  }
};

client.variants.create(variantOptions).then((variant) => {
  console.log(variant); // will be the created variant with some extra meta-data added
});

This above example specifies the type as android, so we therefore must have an anrdoid object with the specific thing an android variant needs.

If the type was adm for Amazom push, then we would need an adm object with those specific options

Boostrapping

There is also a convience method under applications called client.applications.boostrap.

Use can create a Push Application with Variants in one shot. Check the documentation for all available options, but here is a quick example:

const bootstrapper = {
        pushApplicationName: 'Boostrap All',
        androidVariantName: 'Android Name',
        androidGoogleKey: '12345',
        androidProjectNumber: '54321',
        iosVariantName: 'iOS Name',
        iosPassphrase: 'redhat',
        iosCertificate: __dirname + '/../../build/test-ios-cert.p12',
        simplePushVariantName: 'SimplePush Name',
        windowsVariantName: 'Windows Name',
        windowsType: 'wns',
        windowsSid: '12345',
        windowsClientSecret: 'secret',
        admVariantName: 'ADM Name',
        admClientId: '12345',
        admClientSecret: 'secret'
    };

    client.applications.bootstrap(bootstrapper).then((app) => {
      console.log(app);
    });

Notable Changes from 0.2.0 to 0.3.0

  • All Variant Types have been implemented
  • Integration Tests added

Server Setup

At the moment, you must enable "Direct Access Grants" on the UnifiedPush Server for this to work.

Note on Testing

For testing we are using a slightly modified version of the UnifiedPush Server. It is based off of this PR: https://github.com/aerogear/aerogear-unifiedpush-server/pull/677 and uses scenario 3. The modified built war is located here: https://github.com/lholmquist/aerogear-unified-push-server/releases/tag/0.0.1

The reason for doing this allows us to more easily script the setup/testing process. The only thing that PR really does is decouple keycloak and the UPS, it does not change how the REST endpoints work, just how to authenticate to them.

Once that PR is merged then we can point to the official release.

Running the build/start-server.sh and build/start-kc-server.sh will setup both the unified push server and keycloak server for local testing