Giter VIP home page Giter VIP logo

notifme-sdk's People

Contributors

abhishek-plivo avatar armiiller avatar aydrian avatar bdav24 avatar dependabot[bot] avatar dinerville avatar github-actions[bot] avatar greenkeeper[bot] avatar jnoleau avatar mjlescano avatar mjsisley avatar mrfrase3 avatar p16 avatar semantic-release-bot avatar terebentina avatar theconnman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

notifme-sdk's Issues

requiring 'notifme-sdk' results in error

when using require to import 'notifme-sdk' an error occur when trying to create a client.

the solution for me was:

const NotifmeSdk = require("notifme-sdk").default;

Custom email headers

If I want to supply a custom header, will I have to implement a custom email handler, or does SMTP provider have this functionality?

How to run the project?

Hello,
I am having the following issue when I try to run the project after adding NotifmeSDK in my fresh new Node js project.
TypeError: NotifmeSdk is not a constructor
at
index.mjs:3:20
at ModuleJob.run (node:internal/modules/esm/module_job:175:25)
at async Loader.import (node:internal/modules/esm/loader:178:24)
at async Object.loadESM (node:internal/process/esm_loader:68:5)

A step by step guideline would have been helpful.

Cannot read property 'levels' of undefined - Winston during yarn jest

I have a project setup with typescript, jest and using notifme-sdk for notifications.

Running yarn jest command is giving below error.

TypeError: Cannot read property 'levels' of undefined
    at Object.patchedCreate [as createLogger] (D:\workspace\iq\app\node_modules\diagnostic-channel-publishers\dist\src\winston.pub.js:110:35)
    at new Logger (D:\workspace\iq\app\node_modules\notifme-sdk\lib\util\logger.js:25:42)
    at Object.<anonymous> (D:\workspace\iq\app\node_modules\notifme-sdk\lib\util\logger.js:65:19)
    at Module._compile (internal/modules/cjs/loader.js:1156:30)
    at Module._compile (D:\workspace\iq\app\node_modules\pirates\lib\index.js:99:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
    at newLoader (D:\workspace\iq\app\node_modules\pirates\lib\index.js:104:7)
    at Object.newLoader [as .js] (D:\workspace\iq\app\node_modules\pirates\lib\index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:1000:32)
    at Function.Module._load (internal/modules/cjs/loader.js:899:14)
    at Module.require (internal/modules/cjs/loader.js:1042:19)
    at Module.patchedRequire [as require] (D:\workspace\iq\app\node_modules\diagnostic-channel\dist\src\patchRequire.js:14:46)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (D:\workspace\iq\app\node_modules\notifme-sdk\lib\sender.js:43:15)
    at Module._compile (internal/modules/cjs/loader.js:1156:30)
    at Module._compile (D:\workspace\iq\app\node_modules\pirates\lib\index.js:99:24)

error

when I import the package and use it as written in the readme file .. it throws this error:

TypeError: NotifmeSdk is not a constructor

Telegram integration

Telegram its opensource and very used, i think it would be a good alternative for secure and cheap notifications.

SMS/Voice from number should be dynamic

The SMS/Voice from number should be a a string|function.

Why? When using a strategy (such as fallback) the from number will likely be tied to a provider. For example you might have one number for Twilio and another number for Plivo. Additionally this configuration should not be moved to the provider since it would be naive to assume that you only have 1 number you can send from in any Provider (aka you could have multiple numbers in Twilio). Therefore because of these reasons the from phone number should either be a string or a function that returns the string.

Proposed example:

import NotifmeSdk from 'notifme-sdk'

const dynamicFromNumber = function(provider){
  switch(provider.type){
    case "twilio": return "555-555-5555";
    case "plivo": return "444-444-4444";
  }
}

const notifmeSdk = new NotifmeSdk({}) // empty config = all providers are set to console.log
notifmeSdk
  .send({sms: {from: dynamicFromNumber, to: '+15000000001', text: 'Hello, how are you?'}})
  .then(console.log)

Database channel ?

Can we add database channel ? So I can save notifications in my DB through this.

Nestjs Implementation

Hello is there a Nestjs Wrapper for Notifme?. Or can you optionally give me pointers on how to implement this in Nestjs?

Adding providers externally via NPM

I think if you guys provided a way to add providers via NPM, it would be great. My case for it is AWS services like SES (Simple E-mail Service) and SNS (Simple Notification Service, for SMS).

I was going to add AWS SDK but adding stuff to package.json to add providers seems not be scalable. Of course, AWS API works with HTTP calls but I for one don't have any experience with that.

If you agree, I would love to help making notfme extendable and discuss the best way to implement it.

How to add different `from` Email for different providers?

Hi,
I'm trying to have multiple providers, and trying to give different from emails for each of them.

here is what i'm trying:

                {
                    type: "smtp",
                    pool: true,
                    host: config.SMTP.HOST,
                    port: 465,
                    secure: true, // use TLS
                    auth: {
                        user: config.SMTP.USER,
                        pass: config.SMTP.PASSWORD
                    }
                },
                {
                    type: "sendgrid",
                    apiKey: config.SENDGRID
                }
            ]

can i pass from field in each provider here in above segment?
right now i'm passing it inside

  notifmeSdk
            .send({
                ...payload
            })

but in this way, i'm only able to send email with single provider, as for me every email provider is having different from emails.

Slack integration

Hi, Could we get slack notifs as well?
I suppose we could do it with a custom webpush provider atm, right?

Multi provider strategy

Make generic the strategy attached to a channel.

The idea is to be able to define a function implementing the strategy. A strategy takes all provider in input and return a "new" provider.

channels {
  sms: {
    providers: [...]
    multiProviderStrategy: string /* actual*/  
            | (SmsProviderInstance[]) => ((req) => Promise<string>)
  }
}

Refactor existing strategies would be easy

fallback : (providers) => // try with the first and recursively try on error
round-robin (no-fallback) : (providers) => provider[n]

Adding in In-App Notifications or tying them to web-push?

I'm looking at this exciting tool your team has been working on and hoping to adopt it, however I have a question after reading through the documentation.

Is there any way to tie this into my web-app? I saw web-push but wasn't entirely sure how this works?

Essentially I would like to have something similar to facebook or google plus as an option where I Have a bell that a user can click to view their notification history after the webpush has happened and be able to query their own personal notification history on a specific channel.

Is this something that exists? How would this work?

I didn't see any GET or websocket option in the documentation. If this is something that could be voted for I would cast my vote :)

I could see this as somekind of websocket provider

channel: My-App-Push-Channel -> (Store value for Later GET) -> Websocket Gateway -> App Subscribed to websocket gateway.

Vote for Sendgrid Email API

Hey, this library looks great at first look! Thanks to the authors for getting this together!

I'd like to vote for Sendgrid.

I need multiple notifications (Twilio + Sendgrid) for an upcoming project and would love to give this library a try. I may take a crack at a PR in the coming weeks if I can squeeze it in.

node-forge Prototype Pollution vulnerability

This package has a dependency towards [email protected] which has an upstream vulnerability towards node-forge: https://www.npmjs.com/advisories/1561

The vulnerability has been fixed upstream by [email protected] (latest release being [email protected])

Would it be possible to release a new version of this package bumping that dependency, to fix this vulnerability issue?

I have no experience with that dependency myself, but it is not a major release so I am expecting such a bump to be straightforward...?

Nothing in my browser nor in terminal

As in readme file I made changes to code.When I run the code with yarn run notifiction catcher as mentioned in readme file I am getting errors regarding yarn.So that I run the code with yarn run run-catcher then in terminal I am getting this

**

yarn run v0.27.5
$ notification-catcher
NotificationCatcher webapp running at http://0.0.0.0:1080
NotificationCatcher SMTP Server running at 0.0.0.0:1025

**

When I run the following url in my browser http://localhost:1080 I am getting notifme page but I am not getting a message(as shown in readme file) which I am sending in code.

Slack messages

Hi,
I have a slack application that my customers install in their workspace, and I want to send them messages using notifme-sdk, how can I configure this?

Error require in Sailjs 1.x

Hi, I used this package for notification feature but when I tried to require const NotifmeSdk = require("notifme-sdk").default;
and called new NotifmeSdk({}), I cannot lift the sailjs app. I got this error {"code":"include-all:COULD_NOT_REQUIRE","raw":{},"filepath":"/home/nguyenhung/Documents/Git/notifier/api/controllers/noti/async.js","level":"error","message":"Failed to lift app:","severity":"error"}.
I think the reason is es6 syntax. How can I resolve this?
Thank you.

send() should return a Promise

callbacks and errbacks are not nice, they happen out of context making it difficult to react differently on each send request.

IMHO rather than a global callback/errback, the send() method should return a Promise that resolves with the result of rejects with an Error (or custom Error child depending the failure).

npm install fails if there is no git installed.

This is caused by a dependency in node-pushnotifications -> wns

Avoid using git dependencies and projects using git dependencies

npm WARN addRemoteGit     at getNotFoundError (/usr/lib/node_modules/npm/node_modules/which/which.js:13:12)
npm WARN addRemoteGit     at F (/usr/lib/node_modules/npm/node_modules/which/which.js:68:19)
npm WARN addRemoteGit     at E (/usr/lib/node_modules/npm/node_modules/which/which.js:80:29)
npm WARN addRemoteGit     at /usr/lib/node_modules/npm/node_modules/which/which.js:89:16
npm WARN addRemoteGit     at /usr/lib/node_modules/npm/node_modules/which/node_modules/isexe/index.js:44:5
npm WARN addRemoteGit     at /usr/lib/node_modules/npm/node_modules/which/node_modules/isexe/access.js:8:5
npm WARN addRemoteGit     at FSReqWrap.oncomplete (fs.js:114:15)
npm WARN addRemoteGit  git://github.com/alex-friedl/wns.git#660afd2 resetting remote /home/trooper/.npm/_git-remotes/git-github-com-alex-friedl-wns-git-660afd2-6861c264 because of error: { Error: not found: git
npm WARN addRemoteGit     at getNotFoundError (/usr/lib/node_modules/npm/node_modules/which/which.js:13:12)
npm WARN addRemoteGit     at F (/usr/lib/node_modules/npm/node_modules/which/which.js:68:19)
npm WARN addRemoteGit     at E (/usr/lib/node_modules/npm/node_modules/which/which.js:80:29)
npm WARN addRemoteGit     at /usr/lib/node_modules/npm/node_modules/which/which.js:89:16
npm WARN addRemoteGit     at /usr/lib/node_modules/npm/node_modules/which/node_modules/isexe/index.js:44:5
npm WARN addRemoteGit     at /usr/lib/node_modules/npm/node_modules/which/node_modules/isexe/access.js:8:5
npm WARN addRemoteGit     at FSReqWrap.oncomplete (fs.js:114:15) code: 'ENOGIT' }

nsp fails notifme-sdk due to https://nodesecurity.io/advisories/534

The current (1.4.0) notifme-sdk is caught by nsp due to https://nodesecurity.io/advisories/534

For sure, the root cause is node-gcm, but notifme-sdk get the nsp blame :-)
npm i nsp
nsp check --output summary

(+) 1 vulnerabilities found
Name Installed Patched Path More Info
debug 0.8.1 >= 2.6.9 < 3.0.0 || >= 3.1.0 [email protected] > [email protected] > [email protected] > [email protected] https://nodesecurity.io/advisories/534

FCM Config

I when using FCM push Please help me for id params in the config. What is the value for id in the below fcm. I tried secret server key and other keys bit I am not sure

new NotifmeSdk({
  channels: {
    push: {
      providers: [{
        type: 'fcm',
        id: 'xxxxx'
      }]
    }
  }
})

Sending messages to Telegram users

I would like to see if there are other people interested in adding more channels, in this case I believe that Telegram would be nice to have, please upvote if you are interested

Issue:

Telegram is not recognized as a channel.

Suggestion:

I used a library called node-telegram-bot-api to actually send the message to a telegram user and added it as a custom provider to the configuration of NotifmeSdk, the problem I noticed is that telegram is not a recognized channel, but if you give it recognized channel name (ex: email, sms, voice...etc) it will work, but this is not a good solution.

how to send a message to a telegram user?

  • You should start by creating a bot in telegram, there are several ways to do it, I used the 'Botfather' provided by telegram, which as you can imagine is a bot to create your custom bots.
  • Save the token that you are provided with as it will be the way to identify your bot in the code.
  • Initialize your library with the token
  • The user should initialize a conversation with your bot
  • This will expose a chatId that you can use later to send messages later
bot.on('message', (msg) => {
  const chatId = msg.chat.id;
  contactName = msg.chat.name // supposing you are storing this variable somewhere
    console.log(chatId)
});
  • Knowing the chat id, now you can send back messages to your subscribed users
    bot.sendMessage(chatId,Hi ${contactName}!);

Limitations

  • first issue is as mentioned earlier, telegram as a channel does not exist
  • the user should initiate contact with your bot before you can send any messages to them.
    The first point is the focus of this issue, the second is just how telegram works.

Solution

add telegram as a channel type.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.