1.0.13 • Published 3 years ago

@certik/encrypt-decrypt-ssr v1.0.13

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Encryption/Decryption for SSR NEXT_DATA

Description

In NEXT_DATA, important data is stored in order to hydrate the page during server side rendering. We cannot remove NEXT_DATA as it is required, but it leaves us vulnerable to data crawlers and scrapers who can publically access the data. This library can be used to encrypt NEXT_DATA pageProps during getStaticProps and getServerSideProps data fetching and to decrypt it in default page components.

Install

Run the following command to install:

yarn add @certik/encrypt-decrypt-ssr

Usage

For default page component:

import { withSSRDecrypt } from "@certik/encrypt-decrypt-ssr";

// Wrap the default page component alongside the secret encrypt key to decrypt and use the encrypted NEXT_DATA page props
function PageComponent({ ... }) {
    ...
}

export default withSSRDecrypt(PageComponent);

For server side:

import { withEncryptSSR } from "@certik/encrypt-decrypt-ssr";

// Wrap getStaticProps or getServerSideProps data fetching functions
export const getStaticProps: GetStaticProps = withEncryptSSR(async () => { ... });

or

export const getServerSideProps: GetServerSideProps = withEncryptSSR(async () => { ... });

Development

Edit source code in /src directory. Support Javascript, Typescript, JSX, and TSX.

Linting and Formatting

yarn lint
yarn format

Publish

Compile source code by running:

yarn build

Then publish package:

yarn publish --access public
1.0.11

3 years ago

1.0.10

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago