![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
@notifi-network/notifi-node
Advanced tools
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!
This SDK allows you to interact with Notifi Tenant specific services, such as creating users, sending notifications. It is particularly useful when you want to have a custom server-side application. For example, sending notifications automatically when a certain event occurs.
To authenticate with Notifi Node SDK to get the valid auth token, it requires specific server credentials,
SID
andSecret
. You can get these credentials from Notifi Admin Panel --> Account Settings --> Account Keys (top right corner) -->Show Sid/Secret
. If you not yet have an Notifi tenant account, feel free to register a new tenant at Notifi Admin Panel for free.
Install @notifi-network/notifi-node
package using npm or yarn:
# NPM
npm install @notifi-network/notifi-node
# Yarn
yarn add @notifi-network/notifi-node
The NotifiNodeClient
instance behaves as an proxy of NotifiService
which is a wrapper around the Notifi GraphQL API. By interacting with NotifiNodeClient
, we can perform various admin leven server methods such as creating users, sending notifications, etc.
It requires to pass in GraphqlClient
, DataPlaneClient
and SubscriptionService
instances in order to instantiate a NotifiService
object. The NotifiService
object is then passed to the NotifiClient
constructor. Example:
import {
NotifiClient,
createGraphQLClient,
createNotifiService,
} from '@notifi-network/notifi-node';
const gqlClient = createGraphQLClient();
const dpapiClient = createDataplaneClient();
const subService = createNotifiSubscriptionService();
const notifiService = createNotifiService(graphqlClient, subService);
// Instantiate a NotifiNodeClient
const client = new NotifiNodeClient(notifiService);
NOTE:
GraphqlClient
is used to interact with the Notifi GraphQL Mutations and Queries.DataPlaneClient
is used to interact with the Notifi Data Plane API.SubscriptionService
is used to interact with the Notifi Subscription Service.
In order to utilize the NotifiNodeClient methods, we firstly need to call the logIn
by passing the tenant SID
and Secret
mentioned above. This method initializes the NotifiNodeClient and returns a token
and expiry
.
If we already have a valid token, we can directly call initialize
method by passing the token.
const sid = 'your-notifi-tenant-sid';
const secret = 'your-notifi-tenant-secret';
// Either login
const { token, _expiry } = await client.logIn({
sid,
secret,
});
// Or,iff already have a valid token, directly initialize client
await client.initialize(token);
You can obtain the client status by calling client.status
.
NotifiNodeclientUninitializedState
NotifiNodeclientInitializedState
// uninitialized
const { status } = client.status;
// initialized
const { status, jwt } = client.status;
NOTE: Make sure not to expose the
SID
,Secret
andToken (jwt)
publicly. Otherwise, it could be abused by malicious users.
const { status } = client.status;
if (!status === 'initialized') throw new Error('Client not initialized');
const userId = await client.createTenantUser(token, {
walletBlockchain: 'ETHEREUM', // Or other notifi supported blockchain: https://docs.notifi.network/notifi-sdk-ts/modules/_internal_.html#WalletBlockchain
walletPublicKey: 'user-wallet-public-key',
});
// You can start sending notifications to this user
Use publishFusionMessage
method to send one or more messages to the users. The example below sends a notification to the all users who have subscribed to the event-type-id
.
if (!status === 'initialized') throw new Error('Client not initialized');
const messagePayloads = [
{
eventTypeId: 'event-type-id',
variablesJson: {
/** Could be any shape of object according to the need of template */
fromAddress: 'from-wallet-address',
toAddress: 'to-wallet-address',
amount: 'amount',
currency: 'ETH',
},
// Passing `specificWallets` optionally if you want to send to specific users. By default, it sends to all users who have subscribed to the `event-type-id`.
// specificWallets: [{
// walletBlockchain: 'ETHEREUM',
// walletPublicKey: 'user-wallet-public-key',
// }]
},
];
const result = await client.publishFusionMessage(fusionMessages);
NOTE:
- The
variablesJson
parameter is the set of variables that will be used when rendering your templates. If you have a variablefromAddress
, for example, you can display it in the template with the expression{{ eventData.fromAddress }}
Use getActiveAlerts
method to get all active alerts under the tenant.
const first = 10; // Number of alerts to fetch
const after = 'the-cursor'; // Cursor to fetch the alerts after
const result = client.getActiveAlerts({ first, after, fusionEventIds });
You can get the cursor (in PageInfo) from the
result
object to fetch the next set of alerts.
Using addEventListener
method allows to monitor the tenantActiveAlertChanged
event.
Listening to event
const id = client.addEventListener(
'tenantActiveAlertChanged',
eventHandler,
errorHandler,
);
const eventHandler = (event) => {
console.info('Event received:', event);
};
const errorHandler = (error: Error) => {
console.error('Error occurred', error);
};
Removing event listener
client.removeEventListener('tenantActiveAlertChanged', id);
We welcome and appreciate your contributions! Please review our contribution guidelines before getting started.
To ensure a smooth contribution process, please follow the steps below to confirm that all tests pass before submitting your changes:
.env.example
file and rename it to .env
.npm run test
to execute all tests.If your contribution includes a new feature, you may also want to create a dedicated test case within the __tests__/NotifiNodeClient.test.ts
file to validate its functionality.
@notifi-network/notifi-node
package on express.js server.FAQs
Server-initiated operations with Notifi
The npm package @notifi-network/notifi-node receives a total of 279 weekly downloads. As such, @notifi-network/notifi-node popularity was classified as not popular.
We found that @notifi-network/notifi-node demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 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
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.