Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ospin/nexus

Package Overview
Dependencies
Maintainers
4
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ospin/nexus

OSPIN client sdk for calls to rest-like, JSON serving, HTTP API

  • 2.11.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by200%
Maintainers
4
Weekly downloads
 
Created
Source

codecov Maintainability

This documentation is likely to remain sparse, as it is for internal use and under development!

For additional documentation see our endpoint documentation


Table of Contents


Use Overview

The @ospin/nexus exposes a set of conveniences methods wrapping calls to the OSPIN AWS backend, JSON serving, rest-like, API. Unless a method is explicitly labeled as using a public endpoint, or otherwise stated, all nexus consumers must do the following before using the methods provided:

Configuration
const nexus = require('@ospin/nexus') // or import

nexus.connect({
  ENV: <oneOf['dev', 'staging', 'prod']>), // default: 'prod'
  AWS_REGION, // default: 'eu-central-1'
})
// -> { result, config }

// if you'd like to inspect the configuration object that `connect` is ultimately using:
nexus.createConfig() // <- returns the default configuration
nexus.createConfig({ ENV, AWS_REGION }) // <- returns a custom configuration
Authenticating as a User

With the nexus configured, a user can authenticate as their OSPIN AWS Cognito user:

const nexus = require('@ospin/nexus')

nexus.auth.signIn(<username>, <password>) // may require 2FA
Authenticating as a Device

With the nexus configured, a device can authenticate using its certificate:

const nexus = require('@ospin/nexus')

nexus.createConfig()
nexus.connect()

nexus.deviceAPI.authentication.setCredentials({
  deviceId: <deviceId>,
  pathToCert: <pathToCert>
})


nexus.deviceAPI.validateAuthorization()
// -> { sucess, status, data, errorMsg }


API Documentation

Modules and their Methods
nexus
├── auth
│    ├── signIn(<username>, <password>) // may require 2FA
│    ├── signOut()
│    ├── globalSignOut()
│    └── getCurrentSession()
├── user
│    ├── get(<userId>) // may require 2FA
│    ├── list()
│    ├── createDeletionRequest(<userId>)
│    ├── update(<userId>, <userParamsObj>)
│    └── notifications
│         └── putAll(<notificationObj>)
├── command
│    └── device
│         └── process
│               └── startProcess(<deviceId>, <processId>)
├── datapoints
│    └── get(<processId>, <reporterFctId>, <params>)
├── device
│    ├── list()
│    ├── create(<deviceParamsObj>)
│    ├── createHeidolphCoreGateway(<deviceParamsObj>)
│    └── certificate
│         └── get(<deviceId>)
├── log
|    └── device
|         └── deleteMany(<deviceId>)
├── process
|    ├── functionality
|    │    └── image
|    │          ├── create(<processId>, <fctId>, <body>)
|    │          └── list(<processId>, <fctId>, <opts>)
|    └── annotation
│         ├── create({ processId: <processId>, data: <dataObject> })
│         ├── delete({ processId: <processId>, annotationId: <annotationId> })
│         └── update({ processId: <processId>, annotationId: <annotationId>, data: <dataObject> })
└── deviceAPI
     ├── authentication
     |    ├── setCredentials({ deviceId, pathToCert })
     |    └── validateAuthorization()
     └── process
          ├── get(<processId>)
          └── functionality
               └── image
                    ├── createFromUri(<processId>, <fctId>, <body>)
                    └── createFromFile(<processId>, <fctId>, <body>)
All methods above return a standardized response object, e.g.:
const nexus = require('@ospin/nexus')

const {
  success: <boolean>,
  status: <100 - 500>, // HTTP response status code
  data: {}, // JSON safe object
  error: <errObj>, // the error if the request failed
  errorMsg: <string>, // a conveniently parsed error message
} = nexus.user.list()

Helper Methods
nexus
├── createConfig(connectionOpts) // See the #Configuration section above
└── connect(connectionOpts) // uses createConfig's returned object - sets the configuration to the nexus

Use Example

// getting the list representation of all devices (that the authenticated consumer is privileged to)
const nexus = require('@ospin/nexus')

nexus.connect()

const username = 'Nero Claudius Caesar Augustus Germanicus'
const password = 'BurnRomeToMakeANewPalace@Good-Plan-&-Ok-Password',

nexus.auth.signIn(username, password)

const {
  success: listDevicesWasSuccessful,
  data: devicesList,
  errorMsg: listDevicesErrorMsg,
  error: listDevicesError
} = nexus.device.list()

if (listDevicesWasSuccessful) {
  console.log(deviceList)
  // -> [ { ...deviceObj }, { ...deviceObj }, ... ]
} else {
  // kindly find out why...
  console.error(errorMsg)

  // ..or live up to the username and be an unforgiving and unyielding tyrant
  throw listDevicesError
  // -> 💣
}


Contributing

This repo employs the github action semantic-release, which, on approved PRs to main, sniffs the PR title/commit message to automatically bump the semantic versioning and publish the package to NPM.

All PRs to the main branch should indicate the semantic version change via the following options:

Available types:

  • feat: A new feature
  • fix: A bug fix
  • docs: Documentation only changes (unclear if this bumps version)
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  • refactor: A code change that neither fixes a bug nor adds a feature
  • perf: A code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
  • ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit

FAQs

Package last updated on 25 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc