Skip to content

Wrapper to easily generate "X-Request-Auth" header for Mesh sites in golang.

Notifications You must be signed in to change notification settings

ibadus/hawk-mesh-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

hawk mesh go 🌟

status: working ✅

💬 Description

Wrapper to easily generate "X-Request-Auth" header for Mesh sites in golang. Based on hawk-go.

Getting Started

Import the module :

import (
    "github.com/ibadus/hawk-mesh-go"
)

🤔 Usage :

headers, err := hawk.GenerateHeaders("GET", url, key, secret)
headers, err := hawk.GenerateHeaders("PUT", url, key, secret)
headers, err := hawk.GenerateHeadersWithPayload("POST", url, key, secret, string(payload))
headers, err := hawk.GenerateHeadersWithPayload("PUT", url, key, secret, string(payload))

You can find key, secret, apikey in the Mesh-Keys.txt click here. Python solution also available in the repo linked.

🔔 Examples :

Create a GET "X-Request-Auth" header

key := "f2188a5b06"
secret := "8bb6bd51c83f2ec9821e1bda5c77b25b"
url := "https://prod.jdgroupmesh.cloud/stores/jdsportsfr/" + "..."

headers, err := hawk.GenerateHeaders("GET", url, key, secret)
if err != nil {
	return
}
hawkHeader := map[string]string{"X-Request-Auth": headers}

Create a POST "X-Request-Auth" header

key := "f2188a5b06"
secret := "8bb6bd51c83f2ec9821e1bda5c77b25b"
url := "https://prod.jdgroupmesh.cloud/stores/jdsportsfr/" + "..."
payload := []byte(fmt.Sprintf(`
    "Value1": "%s",
    "Value2": "%s",
`, "v1", "v2"))

headers, err := hawk.GenerateHeadersWithPayload("POST", url, key, secret, string(payload))
if err != nil {
	return
}
hawkHeader := map[string]string{"X-Request-Auth": headers}

Create a PUT "X-Request-Auth" header

key := "f2188a5b06"
secret := "8bb6bd51c83f2ec9821e1bda5c77b25b"
url := "https://prod.jdgroupmesh.cloud/stores/jdsportsfr/" + "..."
payload := []byte(fmt.Sprintf(`
    "Value1": "%s",
    "Value2": "%s",
`, "v1", "v2"))

headers, err := hawk.GenerateHeadersWithPayload("PUT", url, key, secret, string(payload))
if err != nil {
	return
}
hawkHeader := map[string]string{"X-Request-Auth": headers}

Let's test

package main

import (
	"fmt"
	"github.com/ibadus/hawk-mesh-go"
)

func main() {
	fmt.Println("Let's try")
	key := "f2188a5b06"
	secret := "8bb6bd51c83f2ec9821e1bda5c77b25b"
	url := "https://prod.jdgroupmesh.cloud/stores/jdsportsfr/"

	headers, err := hawk.GenerateHeaders("GET", url, key, secret)
	if err != nil {
		return
	}
	fmt.Println("X-Request-Auth:", headers)
}

About

Wrapper to easily generate "X-Request-Auth" header for Mesh sites in golang.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages