Coder Social home page Coder Social logo

ilijanl / graphql-codegen-signed-operation Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 1.0 186 KB

GraphQL codegen plugin for signing operation with some secret

Home Page: https://github.com/ilijaNL/graphql-codegen-signed-operation

License: MIT License

JavaScript 6.56% TypeScript 93.44%
codegen graphql nodejs security typescript graphql-codegen

graphql-codegen-signed-operation's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

nahn20

graphql-codegen-signed-operation's Issues

Unable to reproduce hash on local fork of repository

I'm working on a pull request for #1 but am unable to reproduce the same hash for a single operation.

Steps:

  1. Clone this repository
  2. yarn install and yarn build
  3. Delete graphql-codegen-signed-operation directory in the relevant node_modules previously installed (by npm install)
  4. Create a link to the local fork ln -s ../../graphql-codegen-signed-operation
  5. Run npx graphql-codegen --config codegen.ts

I have about 28 hashes that are generated by this plugin and strangely enough, only a single one has a different hash when attempting to reproduce locally. Here's a copy of the definition:

export const UPDATE_CLIENT_PROFILE = gql`
	mutation UpdateClientProfile(
		$firstName: String
		$lastName: String
		$birthdate: AWSDate
	) {
		updateClientProfile(
			firstName: $firstName
			lastName: $lastName
			birthdate: $birthdate
		) {
			userId
			firstName
			lastName
			birthdate
		}
	}
`;

Deleting the link and reinstalling the package with npm install generates the old hash.

Signed hash mismatch for fragments when using with AppSync Lambda authorizer

Love the plugin, but have been having issues verifying any requests with fragments. I'm using AppSync and am handling the validation within a Lambda authorizer. Given how annoying AppSync is, there's a good chance this is an issue specific to using the event.requestContext.queryString parameter provided. Here's an example of how we're using it:

		const stableQuery = printExecutableGraphQLDocument(parse(queryString));
		const expectedHash = createHmac("sha256", gqlSecret)
			.update(stableQuery)
			.digest("hex");
		console.log(expectedHash, hash);

And here's an examples of outputs to demonstrate that it works correctly with no fragments.

INFO	mutation ClientUpdate($input: MutationClientUpdateInput!) { clientUpdate(input: $input) }
INFO	2b6d3034ce59d737df0024ac903c9f02042bf86f341a289f97c4f4962f8658a2 2b6d3034ce59d737df0024ac903c9f02042bf86f341a289f97c4f4962f8658a2

And an example in which it breaks with a fragment.

INFO	fragment UserFragment on User { __typename colorTheme firstName lastName profilePicture { __typename blurHash url } profilePictureBlurHash relationshipType userId } query GetClientProfile { getClientProfile { __typename birthdate numFriends relationshipType userType ...UserFragment } }
INFO	ca7205cc9e733197724e2d0a35d68df73a1cfcfbadeb899be84b6b3de9d2f2c2 f842207215a93954b6473054cb1aa4fd3438e731946d4cddd84463ca9df26839

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.