1.0.13 • Published 2 years ago

@certik/encrypt-decrypt-ssr v1.0.13

Weekly downloads
-
License
MIT
Repository
github
Last release
2 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

2 years ago

1.0.10

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago