Giter Club home page Giter Club logo

user-data-for-fraud-prevention's Introduction

user-data-for-fraud-prevention

user-data-for-fraud-prevention logo

CircleCI Coverage Status NPM Version semantic-release Contributions welcome code style: prettier

All Contributors

Description

This is an npm library to detect some browser or device details of the user such as Timezone, screen sizes, browser configuration etc. Such details are often required to be sent by software providers to the tax authority in their country to prevent fraud.

Eg: The Tax Authority in the UK (HMRC) requires software providers using some of their APIs to provide consistent headers known as Fraud Prevention headers. This node module collects such information for you in the format required.

Each top level folder in src/js has its own README with more specific information around the use case. E.g. HMRC README

How to use

Usage instructions can be found here

How to test

Instructions for testing the changes can be found here

Contributing

We do not allow contributors to claim issues. If you find something interesting you can contribute to the repo, feel free to raise a PR. We do not require you to let us know in advance.

  1. Fork the repo
  2. Install dependencies locally by running yarn
  3. Make your changes
  4. Make sure it builds using yarn build
  5. Run the tests (you added tests, right?) with yarn test
  6. Test your changes in your consuming code or using our demo project: Run yarn link
  7. Ensure the code coverage is the same or higher than before your changes
  8. Ensure commit message is properly formatted: type(subject): input. Eg: chore(prettier): update prettier to 2.x
  9. Create a PR to the master branch
  10. Codeowners will automatically be requested to review, so no need to tag on your PR

Expected Project Structure

The structure shown here is how your code should be organised in the repository

implementation folder should be renamed according to the problem you are solving for eg. the code for HMRC in UK is in the folder named hmrc.

Project
└──src
     └──js
        └──common                // Common and non specific code shoud be put in this folder
        └──implementation       // Implementation specific code for solving problem should be in this folder

How contributors get added to the README

There are two ways to add yourself as a contributor to this repo:

  1. Call @all-contributors bot by adding this following comment in a PR: @all-contributors please add [username] for [contributions]. Please refer to the docs for more info.
  2. Use the all-contributors-cli by running npx all-contributors add [username] [contributions]. Please refer to the docs for more info.

All parameters are required. See the Emoji Key (Contribution Types Reference) for a list of valid contribution types.

License

License

Changelog

Please see our CHANGELOG

Other Languages

README in other languages:

  1. Simplified Chinese
  2. Traditional Chinese
  3. Spanish
  4. German
  5. Hindi

Contributors

Rachel Quan
Rachel Quan

🔧 📖
Reuben
Reuben

📖 👀 ⚠️ 💬 💻
Susmitha Kodamarthi
Susmitha Kodamarthi

📖 👀 ⚠️ 💬 💻
Mayank Khanna
Mayank Khanna

💻
Jitin Maherchandani
Jitin Maherchandani

💻
D. Ben Knoble
D. Ben Knoble

💻
Yashasvi Misra
Yashasvi Misra

📖
vvijayalakshmi21
vvijayalakshmi21

📖 🚧
Tyler Krupicka
Tyler Krupicka

💻 🔌
burzynnn
burzynnn

⚠️ 💻
Christy Jacob
Christy Jacob

📖 💻
Josh Harrison
Josh Harrison

📖 💻
Johan Aludden
Johan Aludden

💻
Andrew Lisowski
Andrew Lisowski

💻
Abderrahim SOUBAI-ELIDRISI
Abderrahim SOUBAI-ELIDRISI

📖
Derek Louis
Derek Louis

📖
Sheetal Singala
Sheetal Singala

📖
Salil Cuncoliencar
Salil Cuncoliencar

📖
Ayushi
Ayushi

📖
Swastika Gupta
Swastika Gupta

📖
someOne404
someOne404

📖
Jochen Rui
Jochen Rui

🌍
Peter Maidens
Peter Maidens

💻 📖 🚧

user-data-for-fraud-prevention's People

Contributors

allcontributors[bot] avatar anuragb26 avatar ayushisood avatar benknoble avatar christyjacob4 avatar dbrown2207 avatar dependabot[bot] avatar dereklouis avatar dhanasekharm avatar hipstersmoothie avatar jakubburzynski avatar jggoyaljayati avatar jitinmaher avatar johanaludden avatar joshharrison626 avatar khanna98 avatar rachelquan avatar reubenae avatar riyajohn avatar salilbc avatar semantic-release-bot avatar sharmaabhinav avatar simran88 avatar skodamarthi avatar someone404 avatar soub4i avatar swastyy avatar tylerkrupicka avatar vvijayalakshmi21 avatar yashasvimisra2798 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

user-data-for-fraud-prevention's Issues

Update demo section in readme with steps for testing

Here are the steps to test:

  • Run yarn link in user-data-for-fraud-prevention
  • Clone the demo project, in there:
  • Run yarn
  • Run yarn start
  • Run yarn demo
  • Run yarn link "user-data-for-fraud-prevention"

Now you can make changes in user-data-for-fraud-prevention locally and they will instantly reflect in the demo project.

You can check the browser console for errors.

Export window size details header for HMRC (Gov-Client-Window-Size)

Is your feature request related to a problem? Please describe.
Currently, we are constructing all the HMRC headers as part of getFraudPreventionHeaders function in https://github.com/intuit/user-data-for-fraud-prevention/blob/master/src/js/hmrc/mtdFraudPrevention.js.

We want to provide the flexibility for users to choose the headers they want from this library independently, instead of providing all of them as a bunch.

Describe the solution you'd like
We want an exported function for Gov-Client-Window-Size header. Add the functionality to call getWindowSize function and construct Gov-Client-Window-Size header value in the format required by HMRC.

Improve Contributing section of ReadMe

Point 6 of Contributing section in ReadMe can be improved by adding links for documentation directly under yarn link and npm linkdirectly.

Also it would be good to add an additional point there with a link to our demo project:

Test your changes in your consuming code or using our demo project by running yarn link or npm link.

Export screen details header for HMRC (Gov-Client-Screens)

Is your feature request related to a problem? Please describe.
Currently, we are constructing all the HMRC headers as part of getFraudPreventionHeaders function in https://github.com/intuit/user-data-for-fraud-prevention/blob/master/src/js/hmrc/mtdFraudPrevention.js.

We want to provide the flexibility for users to choose the headers they want from this library independently, instead of providing all of them as a bunch.

Describe the solution you'd like
We want an exported function for Gov-Client-Screens header. Add the functionality to call getScreenData function and construct Gov-Client-Screens header value in the format required by HMRC.

Remove the duplicate npm version badge from readme

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:
1.
1.
1.

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Info (please complete the following information):
Any information about your environment you believe is relevant e.g. node version

Additional context
Add any other context about the problem here.

Add typescript support

Is your feature request related to a problem? Please describe.
As an engineer, I want to be able to write my code in typescript, so I can find out possible bugs at compile time.

Describe the solution you'd like
Typescript being a supported language in this repo

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
This was attempted before (#28) but due to a series of merge conflicts, was closed without merging. I recommend approaching this in a piecemeal fashion. However, the previous PR is a good reference point for this work still.

Export browser plugins header for HMRC (Gov-Client-Browser-Plugins)

Is your feature request related to a problem? Please describe.
Currently, we are constructing all the HMRC headers as part of getFraudPreventionHeaders function in https://github.com/intuit/user-data-for-fraud-prevention/blob/master/src/js/hmrc/mtdFraudPrevention.js.

We want to provide the flexibility for users to choose the headers they want from this library independently, instead of providing all of them as a bunch.

Describe the solution you'd like
We want an exported function for Gov-Client-Browser-Plugins header. Add the functionality to fetch browser plugins and construct Gov-Client-Browser-Plugins header value in the format required by HMRC.

Add Gov-Client-Public-IP-Timestamp header to HMRC headers

Is your feature request related to a problem? Please describe.
Refer to HMRC documentation here to know the info we need to send as part of this header: https://developer.service.hmrc.gov.uk/guides/fraud-prevention/connection-method/web-app-via-server/#gov-client-public-ip-timestamp

Describe the solution you'd like
Add a function to fetch timestamp when public IP address is collected using https://api.ipify.org as part of Gov-Client-Public-IP header and use that function to generate Gov-Client-Public-IP-Timestamp header needed by HMRC for fraud prevention.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Add code to generate UUID for one of the HMRC headers

Enhance this library to generate value for a new HMRC header: Gov-Client-Device-ID

You can generate an universally unique identifier (UUID), also known as a globally unique identifier (GUID), to use as a device ID

HMRC's documentation for this header can be found here: https://developer.service.hmrc.gov.uk/guides/fraud-prevention/connection-method/web-app-via-server/

Expected format:
Gov-Client-Device-ID: beec798b-b366-47fa-b1f8-92cede14a1ce

Add Linting to Prepush Hooks

Is your feature request related to a problem? Please describe.

Linting is a step during the build that can cause the build to break. While this is definitely a good thing that helps keep the code quality high, it could easily catch contributors off guard since the documentation does not mention it anywhere and it is not automatically enforced before build time.

Describe the solution you'd like

I would like to see the linting run automatically before code is pushed so that contributors know what to expect from the build.

Describe alternatives you've considered

Alternatively, we could also add it as a step to the documentation, however I am more in favour of automating things when we can.

Additional context

Linting is done in the build here.

Export browser user-agent details header for HMRC (Gov-Client-Browser-JS-User-Agent)

Is your feature request related to a problem? Please describe.
Currently, we are constructing all the HMRC headers as part of getFraudPreventionHeaders function in https://github.com/intuit/user-data-for-fraud-prevention/blob/master/src/js/hmrc/mtdFraudPrevention.js.

We want to provide the flexibility for users to choose the headers they want from this library independently, instead of providing all of them as a bunch.

Describe the solution you'd like
We want an exported function for Gov-Client-Browser-JS-User-Agent header. Add the functionality to call getUserAgent() and construct Gov-Client-Browser-JS-User-Agent value in the format required by HMRC.

Pass the actual error instead of just a string as part of promise rejections

Currently for the errors in getDeviceLocalIPAsString function

export const getDeviceLocalIPAsString = () => {
we are only passing some error strings and not the actual stacktrace for the error. Construct an object that includes both the string and the actual error and pass it as a param to the reject. This will help consumers to understand what the actual error incase if there is an error.

Export timezone details header for HMRC (Gov-Client-Timezone)

Is your feature request related to a problem? Please describe.
Currently, we are constructing all the HMRC headers as part of getFraudPreventionHeaders function in https://github.com/intuit/user-data-for-fraud-prevention/blob/master/src/js/hmrc/mtdFraudPrevention.js.

We want to provide the flexibility for users to choose the headers they want from this library independently, instead of providing all of them as a bunch.

Describe the solution you'd like
We want an exported function for Gov-Client-Timezone header. Add the functionality to call getTimezone() and construct Gov-Client-Timezone header value in the format required by HMRC.

Export browser Do Not Track header for HMRC (Gov-Client-Browser-Do-Not-Track)

Is your feature request related to a problem? Please describe.
Currently, we are constructing all the HMRC headers as part of getFraudPreventionHeaders function in https://github.com/intuit/user-data-for-fraud-prevention/blob/master/src/js/hmrc/mtdFraudPrevention.js.

We want to provide the flexibility for users to choose the headers they want from this library independently, instead of providing all of them as a bunch.

Describe the solution you'd like
We want an exported function for Gov-Client-Browser-Do-Not-Track header. Add the functionality to call getBrowserDoNotTrackStatus function and construct Gov-Client-Browser-Do-Not-Track header value in the format required by HMRC.

Add Gov-Client-Browser-JS-User-Agent header to HMRC headers

Is your feature request related to a problem? Please describe.

Refer to HMRC documentation here to know the info we need to send as part of this header: https://developer.service.hmrc.gov.uk/guides/fraud-prevention/connection-method/web-app-via-server/#gov-client-browser-js-user-agent

Describe the solution you'd like
Add a function to fetch useragent using navigator.userAgent and use that function to generate Gov-Client-Browser-JS-User-Agent header needed by HMRC for fraud prevention.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Create README.md for HMRC Fraud headers

At the moment, information on how to use the HMRC fraud headers functions are contained within the project's main README. It would be best to have a seperate one and link to it from the main.

Yeoman generator for new feature

Is your feature request related to a problem? Please describe.
As a engineer trying to add a new implementation for my problem space, I'd like a generator to automatically scaffold out the files for me

Describe the solution you'd like
Say california state taxes require similar information to HMRC about the user's device. You want to leverage the work in js/common, but you need to format it differently to how HMRC want it.

Essentially you need to clone the HMRC folder https://github.com/intuit/user-data-for-fraud-prevention/tree/master/src/js/hmrc but with your own name and then rewrite the functions.

It would be good to have a yeoman generator script you can call which automatically scaffolds this all out.

https://yeoman.io/learning/index.html

Describe alternatives you've considered
A good MVP would be a README section for this specific problem more clearly detailing out the structure required.

Additional context
Add any other context or screenshots about the feature request here.

Discuss ownership of this repo going forward

Context: @skodamarthi and I co-founded this repo, including all the work to open source it from a previously internal only repo at Intuit.

I am no longer at Intuit, and no longer even work within a domain in which I can use this repo. Recently, @pmaidens has taken on the overwhelming bulk of work in improving the quality of this repository.

I propose that we add @pmaidens as a co-owner of this repo. I am happy to either remain or step down.

Excess downloads when using npm or yarn

Describe the bug
When downloading the distributed package from npm repository using npm or yarn, many babel dependencies are downloaded as well. This slows down installation and also adds a lot of files which aren't needed to use the library.
A second issue is the src files are only partially downloaded, so if a user wants to read the source, or directly use the src to reduce bundling uuid dependency twice for example, it throws an error as required files are not found.

To Reproduce
Steps to reproduce the behavior:

  1. run yarn add user-data-for-fraud-prevention

Expected behavior
Only the required node modules are downloaded
Either all or no source files are downloaded

Screenshots
Package json:
image

Downloaded node modules:
image

None of these are required except for user-data-for-fraud-prevention as the distributed code has been completely bundled by webpack. uuid may make sense if the src files are intended to be used.

Info (please complete the following information):
Any information about your environment you believe is relevant e.g. node version

Additional context
Add any other context about the problem here.

Add ES6 support (migrate from module.exports to export const)

At the moment we use module.exports in this repo occasionally, for example here https://github.com/intuit/user-data-for-fraud-prevention/blob/master/src/js/index.js#L6 . It would be better to have ES6 style export const ... instead.

A stack overflow on this topic https://stackoverflow.com/questions/40294870/module-exports-vs-export-default-in-node-js-and-es6 likely this will require some babel configuration.

Tutorial https://egghead.io/lessons/javascript-how-to-write-a-javascript-library-adding-es6-support

This can be tested with using yarn-link locally.

Add Gov-Client-Public-IP header to HMRC headers

Is your feature request related to a problem? Please describe.
Refer to HMRC documentation here to know the info we need to send as part of this header: https://developer.service.hmrc.gov.uk/guides/fraud-prevention/connection-method/web-app-via-server/#gov-client-public-ip

Describe the solution you'd like
Add a function to fetch public IP address using https://api.ipify.org and use that function to generate Gov-Client-Public-IP header needed by HMRC for fraud prevention.

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Export device ID details header for HMRC (Gov-Client-Device-ID)

Is your feature request related to a problem? Please describe.
Currently, we are constructing all the HMRC headers as part of getFraudPreventionHeaders function in https://github.com/intuit/user-data-for-fraud-prevention/blob/master/src/js/hmrc/mtdFraudPrevention.js.

We want to provide the flexibility for users to choose the headers they want from this library independently, instead of providing all of them as a bunch.

Describe the solution you'd like
We want an exported function for Gov-Client-Device-ID header. Add the functionality to call generateClientDeviceID() and construct Gov-Client-Device-ID header value in the format required by HMRC.

Export local IP address details header for HMRC (Gov-Client-Local-IPs)

Is your feature request related to a problem? Please describe.
Currently, we are constructing all the HMRC headers as part of getFraudPreventionHeaders function in https://github.com/intuit/user-data-for-fraud-prevention/blob/master/src/js/hmrc/mtdFraudPrevention.js.

We want to provide the flexibility for users to choose the headers they want from this library independently, instead of providing all of them as a bunch.

Describe the solution you'd like
We want an exported function for Gov-Client-Local-IPs header. Add the functionality to call getDeviceLocalIPAsString() and construct Gov-Client-Local-IPs header value in the format required by HMRC.

Add documentation in additional languages

Is your feature request related to a problem? Please describe.
This project could be more inclusive if the readme was available in multiple languages.

Describe the solution you'd like
Create copies of README.md in the project root, named appropriately e.g. README_SPANISH.md and linked to from the main readme. Something is better than nothing, so provided a single section of the readme is fully translated, that is sufficient to create a new file.

Describe alternatives you've considered
I'm open to other ideas on how we can make this project more inclusive, and any improvements to the process described above.

Additional context
Add any other context or screenshots about the feature request here.

Remove moment.js as a dependency

Started this work here #6 as an example

We use a single function from moment's massive library. The benefit here is to reduce the bundle size; ideally by removing any dependency on moment.js

Export screen and window details for HMRC integrations

Is your feature request related to a problem? Please describe.
Sometimes we need to send the details of the screen and window as separate headers, at the moment we get a single screen and window value from the headers.

Describe the solution you'd like
I want to have the possibility to get screen width, hight, color depth and scaling as well as the window width and height.

Describe alternatives you've considered
Splitting the value supplied in the SCREEN and WINDOW headers.

Additional context
Add any other context or screenshots about the feature request here.

Export local IPs collection timestamp details header for HMRC (Gov-Client-Local-IPs-Timestamp)

Is your feature request related to a problem? Please describe.
Currently, we are constructing all the HMRC headers as part of getFraudPreventionHeaders function in https://github.com/intuit/user-data-for-fraud-prevention/blob/master/src/js/hmrc/mtdFraudPrevention.js.

We want to provide the flexibility for users to choose the headers they want from this library independently, instead of providing all of them as a bunch.

Describe the solution you'd like
We want an exported function for Gov-Client-Local-IPs-Timestamp header. Add the functionality to fetch timestamp details for local IP address collection and construct Gov-Client-Local-IPs-Timestamp header value in the format required by HMRC.

Remove "auto" related dependencies

We tried adding "auto" to auto-generate releases, but it didn't work as expected. We reverted the changes done to circleCI config file as part of #74 for this. However, the changes done in package.json were not reverted. Please remove all "auto" related code in package.json as we are not using this.

Remove usages of npm

And only use yarn. E.g. should not have a yarn.lock file and a package-lock.json file.

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.