We provide packages that makes it super easy to interact with the Sauron API. They completely abstract away the complexity of authentication and interacting with the GraphQL APIs.
Installation
npm i -g @gandalf-network/eyeofsauroneyeofsauron generate
This will generate an eyeofsauron folder in your project root directory.
Every request to the Sauron API needs to be authenticated using your privateKey. This is required to validate that the data request is truly coming from your application.
The packages above handle all of this authentication stuff automagically! You might want to consider using them
instead.
1
Prepare the signature
Start by creating a digital signature of your request’s body. You’ll need to hash the body of your request using
SHA-256 and then sign the hash with ECDSA using your privateKey.
2
Encode the signature
After signing, encode the digital signature using Base64.
3
Add signature header
Add the Base64-encoded signature to the request’s headers with the key X-Gandalf-Signature.
Securing your privateKey is extremely important. All requests to Sauron should be made server-side.
See example code snippets:
Every Query or Mutation in the Sauron GraphQL API is accessible in the helper packages as a function/method. You can read about all
Queries, Mutations & Types in the Schema Reference.