
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
@taghub/api
Advanced tools
This is a JavaScript module wrapping the [TagHub API](https://gitlab.taghub.net/documentation/devdocs/wikis/home).
This is a JavaScript module wrapping the TagHub API.
It makes use of JavaScript modules and async/await and is designed to work both on the web and with NodeJS.
Requirements
Web: Tested with `create-react-app` (webpack).
NodeJS: 13.5+ and "type": "module" in package.json.
npm install --save @taghub/api
import { login, getProjects } from '@taghub/api'
const credentials = await login('username', 'password')
const projects = await getProjects(credentials)
Most API calls take an options object as one of their parameters. Some of these options are common and are listed below.
param type descrption
--
init boolean If `true` the options will be stored in module state
consumerKey string Passed as the `TAGHUB_CONSUMER_KEY` header for API calls (required)
accessKey string Passed as the `TAGHUB_ACCESS_KEY` header for API calls (required)
endpoint string Used as base URL (optional) - overwrite any attempt at detecting the environemnt
.init(options)
Init will store options in the module state for future calls.
Useful so you only have to pass the consumerKey
once.
Example:
import { init } from '@taghub/api'
init({ consumerKey: '123' })
.login(username, password, options)
Logs the user into TagHub. Returns an object with an accessKey
parameter that can be used for access to other APIs.
Passing init: true
in options will also store accessKey
in module state.
Example:
import { login } from '@taghub/api'
await login('username', 'password', { consumerKey: '123', init: true })
.loginSSO(username, ssoKey, updateUserOptions, options)
Logs the user into TagHub from a SSO key which is linked to a Company.
Returns an object with an accessKey
parameter that can be used for access to other APIs.
Passing init: true
in options will also store accessKey
in module state.
updateUserOptions
contains options to update the user:
createIfNotExists
: boolean
If true
it will create a user if it does not exist.
firstName
: string
It will update the user's first name on every login.
lastName
: string
It will update the user's last name on every login.
roles
: array
It will update the project-role relationship on every login. Of shape: [{ project, role }]
.
Example:
import { login } from '@taghub/api'
await loginSSO('username', 'ssoKey', {}, { consumerKey: '123', init: true })
Updating user properties:
await loginSSO('username', 'ssoKey', {
createIfNotExists: true,
firstName: 'Bob',
lastName: 'Sponge',
roles: [
{ project: 'Norway', role: 'Spectator' },
{ project: 'USA', role: 'Administrator' }
]
}, { consumerKey: '123', init: true })
.getProjects(options)
Get a list of the projects the current user has access to.
Example:
import { login, getProjects } from '@taghub/api'
await login('username', 'password', { consumerKey: '123', init: true })
const projects = await getProjects()
.getItems(project_uuid, options={}, fetchparams={})
Get a list of items for the passed project.
Options:
param type descrption
--
query object Object containing query params to pass to items call (optional)
fetchAll boolean Fetch all items in then project (might be heavy and take a long time)
Example:
import { login, getItems } from '@taghub/api'
await login('username', 'password', { consumerKey: '123', init: true })
const items = await getItems('project_uuid')
const equipment = await getItems('project_uuid', { query: { filter9: 1 }})
.getItem(project_uuid, epcString, options)
Get an item of a project.
Example:
import { login, getItem } from '@taghub/api'
await login('username', 'password', { consumerKey: '123', init: true })
const item = await getItem('project_uuid', 'epcString')
.getEvents(project_uuid, epcString, serviceId, options)
Get a list of events of a Service or all Services if serviceId
is not passed.
Options:
param type descrption
--
query object Object containing query params to pass to items call (optional)
query.startFrom number Index from where to start fetching events (latest events come first).
query.maxHits number Max number of events to fetch
Example:
import { login, getEvents } from '@taghub/api'
await login('username', 'password', { consumerKey: '123', init: true })
const items = await getEvents('project_uuid', 'epcString', 'serviceId')
const equipment = await getEvents('project_uuid', 'epcString', 'serviceId', { query: { startFrom: 0, maxHits: 5 }})
.getProjectMeta(project_uuid, options)
Get the metadata of a project. Information about enabled services etc.
Example:
import { login, getProjectMeta } from '@taghub/api'
await login('username', 'password', { consumerKey: '123', init: true })
const meta = await getProjectMeta('project_uuid')
.getProfiles(project_uuid, options)
Get a list of profiles of a project.
Options:
param type descrption
--
query object Object containing query params to pass to items call (optional)
Example:
import { login, getProfiles } from '@taghub/api'
await login('username', 'password', { consumerKey: '123', init: true })
const items = await getProfiles('project_uuid')
.getItemTypes(project_uuid, options)
Get a list of item types related to a project.
Example:
import { getItemTypes } from '@taghub/api'
const items = await getItemTypes('project_uuid')
enjoy.
FAQs
This is a JavaScript module wrapping the [TagHub API](https://gitlab.taghub.net/documentation/devdocs/wikis/home).
The npm package @taghub/api receives a total of 21 weekly downloads. As such, @taghub/api popularity was classified as not popular.
We found that @taghub/api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 10 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.