Skip to content

amnzera/ofuscate-graphql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Installation

npm i ofuscate-graphql --save-dev

The purpose

  • This package is to obfuscate graphql-tag in the production application code, not in the payload

How use this package

  • First Step: Add 'key' in file environment.
  • Example:
export const environment = {
    key: "your-key",
    ...
}
  • Second step: Your file must end with the .query.ts extension

  • Example:

your-file.query.ts OR your-file.mutation.ts

  • And your querys must be "const export":
export const your_query = gql`
    query your_query {
    ...
    }
`
  • Third step: Run the command before the final build of the project

  • Example:

node node_modules/ofuscate-graphql/index.mjs

  • You can also add this command in the 'script' of 'package.json'

"build": "node node_modules/ofuscate-graphql/index.mjs && ng build"

  • After being encrypted by 'CryptoJS' you can decrypt it before making the request

  • Example:

import * as CriptoJS from 'crypto-js'
import { gql } from "graphql-tag"

removeCryptography(my_query: string) {
    const decrypted = CryptoJS.AES.decrypt(my_query, environment.key);
    const decryptedQuery = decrypted.toString(CryptoJS.enc.Utf8);
    return gql(decryptedQuery);
}
  • ATTENTION step remember this command will rewrite your graphql-tag

Additional Details

Credits

These definitions were written by Alexandre_Nunes.

GitHub Ofuscate-graphql.

About

Package to ofuscate graphql in project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published