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

@airspacelink/portal-apps-sdk

v1.4.0

Published

AirHub Portal apps SDK

Downloads

73

Readme

@airspacelink/portal-apps-sdk

Build status

Package name: Portal Apps SDK

Package author: Airspace Link

Installation:

npm install @airspacelink/portal-apps-sdk

Summary

The Portal Apps SDK enables developers to create Marketplace Apps for use within Portal Core. Portal Core handles user authentication and data access and passes requested information to the Marketplace Apps via invocation of SDK functions.

Technically, Marketplace Apps run inside an iframe context and the SDK uses Window.postMessage() and MessageEvents to send data back and forth between the Marketplace App and Portal Core.

The Portal Apps SDK uses a request-response model. Communication is initiated by the Marketplace App via SDK methods (request). All methods return a Promise which contains data sent from Portal Core when resolved (response).

SDK Methods

getUserInfo()

  • Parameters: none
  • Returns: Promise<UserInfo>
  • Description: Used to request the profile information for the logged in user. Promise will resolve with a value of type UserInfo.

EXAMPLE

import { AppsSDK } from '@airspacelink/portal-apps-sdk';

const portal = new AppsSDK();
portal.getUserInfo().then(userInfo => {
  console.log(JSON.stringify(userInfo));
});

/* logs:
{
  "email": "[email protected]",
  "firstName": "Bob",
  "lastName": "Jones",
  "phone": "+1 (555)-867-5309",
  "certificateNumber": "KLJLKJ0980980✈️",
  "certificateIssueDate": "2021-09-28"
}
*/

getSession()

  • Parameters: none
  • Returns: Promise<Session>
  • Description: Used to request the session context for the logged in user. Promise will resolve with a value of type Session.

EXAMPLE

import { AppsSDK } from '@airspacelink/portal-apps-sdk';

const portal = new AppsSDK();
portal.getSession().then(session => {
  console.log(JSON.stringify(session));
});

/* logs:
{
  "jurisdictions": [
    {
      "geoId": "01",
      "name": "AL"
    },
    {
      "geoId": "51",
      "name": "VA"
    }
  ],
  "org": {
    "id": "org_Wf44hhs3BLxqMS",
    "name": "Senatus Populusque Romanus"
  }
}
*/

getAccessToken()

  • Parameters: none
  • Returns: Promise<string>
  • Description: Used to request the access token assigned to the user upon authentication. Promise will resolve with a value of type string.

EXAMPLE

import { AppsSDK } from '@airspacelink/portal-apps-sdk';

const portal = new AppsSDK();
portal.getAccessToken().then(accessToken => {
  console.log(accessToken);
});

/* logs:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
*/

getAppContext()

  • Parameters: none
  • Returns: Promise<AppContext>
  • Description: Used to request the app execution context. Promise will resolve with a value of type AppContext.

EXAMPLE

import { AppsSDK } from '@airspacelink/portal-apps-sdk';

const portal = new AppsSDK();
portal.getAppContext().then(appContext => {
  console.log(appContext.slot);
});

/* logs:
{
  "kind": "default"
}
*/

Error Handling

Portal Apps SDK includes some classes that can be used to handle error conditions. If an underlying network request was cancelled, the SDK method will throw CmdCanceledError. If there was another type of failure, the SDK method will throw CmdFailedError which contains a message property that can be used to determine the underlying cause.

import { AppsSDK, CmdCanceledError, CmdFailedError } from '@airspacelink/portal-apps-sdk';

const portal = new AppsSDK();

portal.getUserInfo().catch(err => {
  if (err instanceof CmdCanceledError) {
    // Cmd cancelled
  }

  if (err instanceof CmdFailedError) {
    // Failed for some reason. Use the `message` property to determine cause.
    console.error(err.message);
  }
});

Copyright (c) 2023 Airspace Link