https://github.com/coston/react-obfuscate
An intelligent React component to obfuscate any contact link!
https://github.com/coston/react-obfuscate
email infosec obfuscation react
Last synced: about 1 year ago
JSON representation
An intelligent React component to obfuscate any contact link!
- Host: GitHub
- URL: https://github.com/coston/react-obfuscate
- Owner: coston
- License: mit
- Created: 2017-07-11T18:29:32.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2024-08-24T16:40:22.000Z (almost 2 years ago)
- Last Synced: 2025-03-29T14:12:27.764Z (over 1 year ago)
- Topics: email, infosec, obfuscation, react
- Language: TypeScript
- Homepage: https://react-obfuscate.coston.io
- Size: 4.42 MB
- Stars: 118
- Watchers: 3
- Forks: 17
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# react-obfuscate
[](https://coveralls.io/github/coston/react-obfuscate?branch=master)

[](https://www.npmjs.com/package/react-obfuscate)
[](https://www.npmjs.com/package/react-obfuscate)

## Demo & Examples
Live demo: [react-obfuscate.coston.io](https://react-obfuscate.coston.io)
## How it works
The user passes the contact link as an `email`, `tel`, `sms`, `facetime`, or `href` prop. The component obfuscates href data until a hover, click, or focus event. Links are given their proper URL schemes (mailto, facetime, etc.) The link is rendered in reverse in the dom, but reversed again with css. This making the link useless for spammers, but user friendly on screen.
## Why
The world needs obfuscated links that display the link in a friendly way.
## Installation
```bash
npm install --save react-obfuscate
```
### Input
```js
import React from 'react';
import Obfuscate from 'react-obfuscate';
export default () => (
Phone:
Email:{' '}
);
```
### Output
#### Robot Interaction
```html
Phone:
4321-454-502
Email:
oi.notsoc@olleh
```
#### Human Interaction
```js
Phone: 205-454-1234
Email: hello@coston.io
```
## Common Options
| Prop | Type | Default | Description |
| ---------- | -------- | ------- | -------------------------------------------- |
| `email` | `string` | `null` | email address of the intended recipient |
| `headers` | `object` | `null` | subject, cc, bcc, body, etc |
| `tel` | `string` | `null` | telephone number of the intended recipient |
| `sms` | `string` | `null` | sms number of the intended recipient |
| `facetime` | `string` | `null` | facetime address of the intended recipient |
| `href` | `string` | `null` | Obfuscate any other URL type (e.g. WhatsApp) |
## Uncommon Options
| Prop | Type | Default | Description |
| ------------------- | ---------- | -------------- | -------------------------------------------------------------- |
| `linkText` | `string` | `'obfuscated'` | add custom pre-interaction href attribute placeholder text |
| `obfuscate` | `boolean` | `true` | set to false to disable obfuscation |
| `obfuscateChildren` | `boolean` | `true` | set to false to disable obfuscation of children |
| `element` | `string` | `'a'` | use if you want to override the default `a` tag |
| `onClick` | `function` | `null` | called prior to setting location (e.g. for analytics tracking) |
## Development
```bash
npm start
```
## Consecutive Obfuscate/inline elements
react-obfuscate is an inline element. Using consecutive inline elements inside a block element causes an issue with the `bidi-override` reversal on Chrome. To prevent this,
add any text between the elements, wrap `` with another element (like ``), or add `style={{display:'inline-block'}}` to prevent any issues.
Example Case:
```js
```
## Obfuscating custom elements with the `element` prop
With the `element` prop, users can obfuscate any element, like paragraphs or headers. Changing the dom element also removes the href and onClick props. Custom styling is required due to handling of right-to-left direction styles. Usually, adding `style={{textAlign:'left'}}` will suffice.
Example Case:
```js
This paragraph is more secret than others.
```
## Children
By default, objects **are not** reversed in the dom, but other types are. The `obfuscateChildren` prop set will disabled this functionality when set to `false`. If the child is an object, like html elements are, it will be rendered normally.
##### Example Use Case
```js
```
## Contributors
react-obfuscate is awesome thanks to these community members:
- [coston](https://github.com/coston)
- [bostrom](https://github.com/bostrom)
- [timmygee](https://github.com/timmygee)
- [mic](https://github.com/mic)
- [ravinggenius](https://github.com/ravinggenius)
- [charlesbdudley](https://github.com/charlesbdudley)
- [dalbitresb12](https://github.com/dalbitresb12)
## Contributing
Please help make this react component better. Feel free to submit an issue, or contribute through a pull request.
## License
Licensed under the MIT license.