I've made a react component that hides sensitive information in your app.
ItayLisaey

ItayLisaey @itaylisaey

Joined:
Aug 11, 2021

I've made a react component that hides sensitive information in your app.

Publish Date: Apr 24 '22
154 39

Did you ever want to showcase a site you have worked on or a new feature you just published in a production system but were unable to do so because of the fear of exposing sensitive information?

SafeView is a component that allows you to hide sensitive information in your app visually, for presentation purposes, and more.

example-gif

In order to hide an element all you need to do is to target it using the data-safe attribute.

const MyComponent = () => {
    return (
        <div>
            <span data-safe>
                // Sensitive info
            <span>
        </div>
    )
}
Enter fullscreen mode Exit fullscreen mode

And then when you want to hide press Shift + S.

There is basically no setup involved other than wrapping your app with the <SafeView> component.

The library is super simple and light-weight and is available at NPM.

"SafeView" on NPM

"SafeView" on Github

if you have any question and/or suggestion I would love to answer in the comments. :)

Comments 39 total

  • Liad Altif
    Liad AltifApr 24, 2022

    been here since day one 🥳

  • shalevb108
    shalevb108Apr 24, 2022

    Very useful and convenient to work just a pleasure!

  • alxizr
    alxizrApr 24, 2022

    Super cool, very useful and unbelievably easy 👌 😀 👍

  • LiorVainer
    LiorVainerApr 24, 2022

    Used in a personal project of mine and helped me very much with presentation of the project

  • Christian Kozalla
    Christian KozallaApr 24, 2022

    Is this similar to using feature flags?

    • Larson
      LarsonApr 24, 2022

      No. Feature flags are normally used to ignore specific parts of your code in the deployment so they wont get shipped.

      SafeView "hides" existing components.

      SafeView is a component that allows you to hide sensitive information in your app visually, for presentation purposes, and more.

      visually

      they still exist when you look in your developer tools.

      • hidden_dude
        hidden_dudeApr 24, 2022

        Hmm then it's not really secure or "safe".
        It's just activating and deactivating.

        • RobbieGM
          RobbieGMApr 24, 2022

          What did you think the point of it was?

          • hidden_dude
            hidden_dudeApr 25, 2022

            I don't know.. but "safe" doesn't seem like the right word to use here.

            • Christian Kozalla
              Christian KozallaApr 25, 2022

              When I read the title of the post, "sensitive information" makes me think of API secrets..

              If I want to hide something visually, I can provide a global CSS ID for the same purpose myself...

              • Grant Riordan
                Grant RiordanApr 25, 2022

                My thought exactly , I'd rather have a component which perhaps encrypts the data or redacts it on toggle or component render.

                • hidden_dude
                  hidden_dudeApr 25, 2022

                  yeah.. i was thinking something similar.

                  • ItayLisaey
                    ItayLisaeyApr 25, 2022

                    Sorry about that, didn't mean to mislead anyone.
                    I think I clearly state in the library that it is only for visual purposes it is NOT secure in anyway by design.

                    • hidden_dude
                      hidden_dudeApr 25, 2022

                      Of course not. I just suggest you change the name to "activate" or "hide" rather than "safe". Because "safe" gives the impression of being a security feature.

                      But good work and kudos for your efforts.

      • ItayLisaey
        ItayLisaeyApr 25, 2022

        Thanks Lars, SafeView purpose is not to secure your sensitive information.

        You can look at it more like a showcase/presentaion helper.

      • Darkø Tasevski
        Darkø TasevskiApr 27, 2022

        Feature flags are normally used to ignore specific parts of your code in the deployment so they wont get shipped.

        You sure about that @larsonnn ?

        From my experience so far, the code behind the feature flags is shipped, but is not available to the user in the production. Talking from the the frontend perspective though, not sure if in native development we can remove code behind the disabled feature flags in compile step.

        • Christian Kozalla
          Christian KozallaApr 28, 2022

          We're using feature flags like in a simple if else statement. So the code is shipped and we can switch the flag on and off at runtime.

          I'm sure a compile step could remove the code behind the flag, but then you couldn't toggle the flags at runtime

          Thanks for sharing your experience :)

  • SauhardoSengupta
    SauhardoSenguptaApr 24, 2022

    Amazing, this will be really usefull

  • Larson
    LarsonApr 24, 2022

    It's simple, that's the best of it.

  • Nitzan Hen
    Nitzan HenApr 24, 2022

    Cool idea! Seems simple to use and useful. Bookmarked for a time of need 📌

  • Ali Zaidi
    Ali ZaidiApr 24, 2022

    Wow this is pretty cool !! Will try using it in my projects

  • Stephanie Handsteiner
    Stephanie HandsteinerApr 25, 2022

    It's not a good idea to obfuscate sensitive information with CSS, aside from the obvious point that the data is still there and one only has to deactivate CSS in order to deactivate the blur filter, this kind of blur is not actually safe to hide information, just look at the preview image in your article's header.

    • ItayLisaey
      ItayLisaeyApr 25, 2022

      Your'e right about that one, the library isn't focused around security at all.

      The idea is to enable a quick safe preview for customers/client at a presention or a meeting without revealing sensitive information.

  • Grant Riordan
    Grant RiordanApr 25, 2022

    As other have said the functionality would be better to redact / encrypt the sensitive data.

    Other suggestion could be to rename the component as then it could be used across React and React Native. (react native already has a SafeView component.

    • ItayLisaey
      ItayLisaeyApr 25, 2022

      Interesting, didn't knew about that..
      I think you can import the component by a different name.

      import SafeView as MyComponent from "safeview"

      • Grant Riordan
        Grant RiordanApr 25, 2022

        Apologies ReactNative is called SafeAreaView but point still stands

  • ItayLisaey
    ItayLisaeyApr 25, 2022

    How do you suppose to implement that? What will the hook provide?

    I thought about that earlier but eventually decided to go with the attribute approach because it looks cleaner.

  • ItayLisaey
    ItayLisaeyApr 25, 2022

    You're definitely right about that one,
    but from my experience the stage/dev isn't always accessible to people outside the dev/product team

  • Abraham
    AbrahamApr 25, 2022

    Lol...I opened the article cause I wanted to know the new tech that helps me hide sensitive data with client side javascript. 😏

  • ItayLisaey
    ItayLisaeyApr 25, 2022

    thanks! looks great.
    mind you the key combination and different filters are already available and can be customized using the component (more on that in the library readme).

  • Maria Campbell
    Maria CampbellApr 27, 2022

    And this sensitive info actually does not appear in the HTML? Where does it end up?

    • ItayLisaey
      ItayLisaeyApr 28, 2022

      The sensitive information is still available in the DOM.

      As I've mentioned before the library's serves only to hide the sensitive information visibly, for presentation purposes.

      • Maria Campbell
        Maria CampbellApr 28, 2022

        Understood. So then basically not helpful regarding sensitive info as I thought. Just wanted confirmation. Thanks!

  • EECOLOR
    EECOLORApr 28, 2022

    Hello,

    Am I correct in thinking that simply adding the following CSS would have the exact same effect?

    *[data-safe] {
        filter: blur(.3rem) !important;
    }
    
    Enter fullscreen mode Exit fullscreen mode

    If that is the case I think it would be better to not use an external library with its associated security and maintenance cost.

    • ItayLisaey
      ItayLisaeyApr 28, 2022

      You are definitely correct.
      I actually said exactly that on some of the posts I wrote.
      The reason I made it into a library is for my personal comfort and it fits my use cases.

      You are more than welcome to use any of the code in library without using it through npm.

Add comment