New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@notifi-network/notifi-node

Package Overview
Dependencies
Maintainers
2
Versions
457
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@notifi-network/notifi-node

The node.js library for server-initiated pushes

  • 0.9.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
393
decreased by-38.3%
Maintainers
2
Weekly downloads
 
Created
Source

@notifi-networks/notifi-node

Node SDK for Notifi APIs.

This SDK is intended for use with Servers who have obtained a SID / Secret pair from Notifi. Please reach out to us for help on Discord!

Usage

Instantiating a NotifiClient

import {
  NotifiClient,
  NotifiEnvironment,
  createAxiosInstance,
} from '@notifi-network/notifi-node';
import axios from 'axios';

const env: NotifiEnvironment = 'Production'; // Or 'Development'
const axiosInstance = createAxiosInstance(axios, env);
const client = new NotifiClient(axiosInstance);

Creating a Tenant User

import {
  NotifiClient,
} from '@notifi-network/notifi-node';

const client: NotifiClient = getNotifiClient();

// Log in to obtain a token
const { token, expiry } = await client.logIn({ sid: MY_SID, secret: MY_SECRET });

// Use the token to create a tenant user
const userId = await client.createTenantUser(
  token,
  {
    walletBlockchain: 'NEAR', // Or 'SOLANA'
    walletPublicKey: 'juni-kim.near', // Or other address
  },
);
await persistUserIdSomehow(userId);

// Use the token and the user ID to subscribe the user to Direct Push alerts
const alertObject = await client.createDirectPushAlert(
  token,
  {
    userId,
    emailAddresses: [...userEmails],
    phoneNumbers: [...userPhoneNumbers], // Currently we only support US phone numbers e.g. '+1xxxAAAyyyy' (include +1)
  }
);
await persistAlertIdSomehow(userId, alertObject.id);

Sending a Direct Push Alert to a user

import {
  NotifiClient,
} from '@notifi-network/notifi-node';

const client: NotifiClient = getNotifiClient();

// Log in to obtain a token
const { token, expiry } = await client.logIn({ sid: MY_SID, secret: MY_SECRET });

// Use the token to send a message to anyone subscribed to that wallet
await client.sendDirectPush(token, {
  key: randomUUID(), // Idempotency key, use the same value for each unique event
  walletBlockchain: 'NEAR', // Or 'SOLANA'
  walletPublicKey: 'juni-kim.near', // Or other address
  message: 'Hello world',
});

FAQs

Package last updated on 22 Mar 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