Giter Club home page Giter Club logo

notifications-node-client's Introduction

notifications-node-client's People

Contributors

36degrees avatar alexnuttall avatar bandesz avatar benthorner avatar blesseddev avatar crystalpea avatar danboscaro avatar dependabot[bot] avatar gov-cjwaszczuk avatar idavidmcdonald avatar imdadahad avatar jonathanglassman avatar karlchillmaid avatar kentsanggds avatar klssmith avatar leohemsted avatar minglis avatar nickcolley avatar quis avatar rjbaker avatar saimaghafoor avatar samuelhwilliams avatar servingupaces avatar sfount avatar snyk-bot avatar tombye avatar zuzak avatar

Stargazers

 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

notifications-node-client's Issues

Allow setting notifyProductionAPI

Hi All

We're currently working on a 🇨🇦version of the Notify service.

The problem:

I recently did a test of the Node Client API and noticed the endpoint is hardcoded.

notifyProductionAPI = 'https://api.notifications.service.gov.uk'

Ideally we would like to avoid creating forks of all the client libraries (the endpoint is also hardcoded in the other client libs I looked at).

The ask:

Wondering if you would accept a Pull Request which would allow that variable to be set via an environment variable while defaulting to your endpoint if that variable not available / set.

i.e.

notifyProductionAPI = the_env_var || 'https://api.notifications.service.gov.uk'  

Is there an example setup somewhere

Hi,

Trying to find a working example of this setup including how to setup/generate a token.

Any examples would be great we hit a 403 as we aren't sure of token setup.

setProxy takes a string not an object

In your documentation you have instructions on how to set the proxy as:

proxyConfig = { host: proxyHost, port: proxyPort } notifyClient.setProxy(proxyConfig)

However the setProxy command only takes a string:

* @param {String} url

It is the setProxy on the APIClient that accepts an object:

setProxy: function(proxyConfig){

Can you please advise which is the correct way for setting the proxy host and port? I think the documentation will need updating to make this clearer?

Leaked global in api_client.js

When running hapi/lab tests on an application using notifications-node-client[1] the tests were reporting the following error:

The following leaks were detected:version

This error is flagging leaked globals.

debugging lead me to this line in client/api_client.js:

var restClient = require('axios').default,
   _ = require('underscore'),
     createGovukNotifyToken = require('../client/authentication.js'),
      notifyProductionAPI = 'https://api.notifications.service.gov.uk'
     version = require('../package.json').version;

i believe there is a comma missing on the penultimate line (adding the comma resolves the test run error for me). I have a workaround but wanted to flag my findings.

[1] https://github.com/NeXt-Warning-System/xws-contact-web

`sendSms`, `sendEmail` and `sendLetter` parameters documentation doesn't match actual implementation

Documentation for the sendEmail method states that it accepts 5 parameters:

  • templateId (required)
  • emailAddress (required)
  • personalisation (required)
  • reference (required)
  • emailReplyToId (optional)

However, in practice, this method actually accepts 3 parameters:

  • templateId (required)
  • emailAddress (required)
  • options (optional)

options should be an object, and may optionally contain any of the following keys:

  • personalisation
  • reference
  • emailReplyToId

The same applies to sendSms and sendLetter methods.


According to the changelog, the methods were changed in 2017. But the documentation is out of date since it doesn't reflect these changes.

Types?

declare module "notifications-node-client" {
  class NotifyClient {
    constructor(apiKey: string);
    sendEmail(
      templateId: string,
      emailAddress: string,
      options: {
        personalisation: any;
        reference: string;
        emailReplyToId?: string;
      }
    ): Promise<any>;
    sendSms(
      templateId: string,
      phoneNumber: string,
      options?: NotificationSendOptions
    ): Promise<any>;
    sendLetter(
      templateId: string,
      options?: NotificationSendOptions
    ): Promise<any>;
    sendPrecompiledLetter(
      reference: string,
      pdfFile: string | Buffer,
      postage?: string
    ): Promise<any>;
    getNotificationById(notificationId: string): Promise<any>;
    getNotifications(
      templateType?: string,
      status?: string,
      reference?: string,
      olderThanId?: string
    ): Promise<any>;
    getPdfForLetterNotification(notificationId: string): Promise<Buffer>;
    getTemplateById(templateId: string): Promise<any>;
    getTemplateByIdAndVersion(
      templateId: string,
      version: number
    ): Promise<any>;
    getAllTemplates(templateType?: string): Promise<any>;
    previewTemplateById(
      templateId: string,
      personalisation?: any
    ): Promise<any>;
    getReceivedTexts(olderThan?: string): Promise<any>;
    setProxy(proxyConfig: any): void;
    prepareUpload(fileData: any, options?: FileUploadOptions): any;
  }

  export = {
    NotifyClient: NotifyClient,
  };

  export interface NotificationSendOptions {
    personalisation?: any;
    reference?: string;
    emailReplyToId?: string;
    smsSenderId?: string;
  }

  export interface FileUploadOptions {
    isCsv?: boolean;
    confirmEmailBeforeDownload?: boolean;
    retentionPeriod?: number;
  }
}


Perhaps consider publishing just types so an npm install with:
npm i --save-dev @types/notifications-node-client is possible?

remove crypto dependency

Hi,

Please could you remove the crypto dependency (as it is no longer supported) and switch to the build in node.js crypto?
https://nodejs.org/api/crypto.html

warning notifications-node-client > [email protected]: This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in.

thanks

request dependency does not install

I've just installed this package and even though it declares request as a dependency it does not install it.
I notice that request-promise declares request as a peer dependency. Could it be that this overrides it? Which sounds wrong to me.
Anyway - the work around is to install request as a top level dependency. So perhaps this needs to be made clear in the install instructions.

Prototype Pollution Vulnerability

What

Snyk has discovered a vulnerability within this library:

✗ Low severity vulnerability found on [email protected]
- desc: Prototype Pollution
- info: https://snyk.io/vuln/npm:hoek:20180212
- from: [email protected] > [email protected] > [email protected] > [email protected] > [email protected] > [email protected]
No direct dependency upgrade can address this issue.
Run `snyk wizard` to explore remediation options.

https://github.com/alphagov/notifications-node-client/blob/master/package.json#L13

We're using jsonwebtoken in a newer version which doesn't produce the above warning.

We didn't attempt to bump it for this library, so I don't know what the blowback would be.

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.