@kalisio/kdk-notify
v1.1.0
Published
Module to support notifications (push, emails, etc.) for Kalisio applications and services
Downloads
14
Readme
kNotify
Basic utils to support notifications (push, emails, etc.) for KDK-based applications and services
Installation
npm install @kalisio/kdk-notify --save
// Or with Yarn
yarn add @kalisio/kdk-notify
Documentation
The kDocs are loaded with awesome stuff and tell you everything you need to know about using and configuring it.
Tests
Mailer
To make test run we need two gmail accounts:
[email protected]
used as email sender[email protected]
used as user test email
When testing identity change we also use the
[email protected]
address as user test email. However to avoid creating a new account in Google you simply have add an alias for this address to the[email protected]
account.
The first email account should authorise connection by email/password on https://myaccount.google.com/lesssecureapps. Before that the domain admin should allow him to manage this setting (Admin Console > Security > General > Less secure apps settings). To avoid changing it for all users first create a group, add the user to the group and let the group manage less secure apps setting.
The second email account requires OAuth2 to be able to read emails using the GMail API. The simplest way is by creating a service account for a JWT-based authentication. Interesting issue to make all the configuration work can be found here, notably you have to delegate domain-wide authority to the service account in order to authorize your app to access user data on behalf of users and authorise the client ID of the service account with scopes https://mail.google.com/,https://www.googleapis.com/auth/gmail.readonly
.
Standard OAuth2 with refresh token might also be used as detailed here and here.
Details on how to use Google APIs from Node.js here.
Some anti-virus or firewalls softwares intercept HTTPS traffic, decrypting it, and then encrypting it using a self-signed certificate causing a "Self-Signed Certificate in Certificate Chain" error. If so deactivate the SSL analysys in your software, this might help.
Pusher
Push notifications rely on sns-mobile, which has a nice tutorial. To get an API access/secret key you need to create a new user in IAM with a role giving access to SNS like AmazonSNSFullAccess but in production you should control access more precisely.
Since 2017 Google Cloud Messaging (GCM) has become Firebase Cloud Messaging (FCM), to generate an API key follow this issue and enter the server key when creating the SNS application on AWS. Although you use the Firebase console you should also see the created API through the Google Cloud console.
License
Copyright (c) 2017 Kalisio
Licensed under the MIT license.