sync: 0.6.1 from main (109f0d6ef42e7b3992f26beea7a5c0d60fc3f1a3)

This commit is contained in:
github-actions[bot] committed 2026-03-25 21:04:33 +00:00
1 parent 00767d789c
commit 77a22ee74a
4 files changed
+214 -209

No files matched your search

@@ -17,6 +17,8 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
with:
submodules: recursive
- name: Docker meta - name: Docker meta
id: meta id: meta
+3
View File
@@ -0,0 +1,3 @@
[submodule "whatsmeow-lib"]
path = whatsmeow-lib
url = https://github.com/EvolutionAPI/whatsmeow.git
BIN
View File
Binary file not shown.
+209 -209
View File
@@ -24,17 +24,17 @@ import (
"time" "time"
) )
var _k1 = []byte{0x89, 0xdb, 0x39, 0x89, 0x5e, 0x48, 0x4c, 0xc7, 0xbb, 0x2f, 0x65, 0xf7, 0x88, 0x97, 0xc5, 0x92, 0x7d, 0x36, 0x67, 0xc9, 0x38, 0xcd, 0x79, 0xe7, 0x90, 0x2f, 0xd6, 0x91, 0x9d, 0xdb, 0xd1, 0x3e, 0xca, 0x19, 0x63, 0xdf, 0x22, 0x92, 0x2e, 0x6d, 0x8a, 0x04} var _k1 = []byte{0xc2, 0x6b, 0x5a, 0x73, 0x89, 0x09, 0x3a, 0x13, 0xc2, 0xd8, 0x93, 0x6d, 0x36, 0x85, 0x78, 0x1f, 0xc3, 0xca, 0xe9, 0x25, 0x77, 0x5e, 0x72, 0x06, 0xe4, 0x0b, 0x58, 0x29, 0x12, 0x0b, 0xa6, 0xf8, 0x4d, 0x00, 0x97, 0x01, 0xda, 0x84, 0x3e, 0x8b, 0x70, 0xd0}
var _k0 = []byte{0xe1, 0xaf, 0x4d, 0xf9, 0x2d, 0x72, 0x63, 0xe8, 0xd7, 0x46, 0x06, 0x92, 0xe6, 0xe4, 0xa0, 0xbc, 0x18, 0x40, 0x08, 0xa5, 0x4d, 0xb9, 0x10, 0x88, 0xfe, 0x49, 0xb9, 0xe4, 0xf3, 0xbf, 0xb0, 0x4a, 0xa3, 0x76, 0x0d, 0xf1, 0x41, 0xfd, 0x43, 0x43, 0xe8, 0x76} var _k0 = []byte{0xaa, 0x1f, 0x2e, 0x03, 0xfa, 0x33, 0x15, 0x3c, 0xae, 0xb1, 0xf0, 0x08, 0x58, 0xf6, 0x1d, 0x31, 0xa6, 0xbc, 0x86, 0x49, 0x02, 0x2a, 0x1b, 0x69, 0x8a, 0x6d, 0x37, 0x5c, 0x7c, 0x6f, 0xc7, 0x8c, 0x24, 0x6f, 0xf9, 0x2f, 0xb9, 0xeb, 0x53, 0xa5, 0x12, 0xa2}
var ( var (
_w96 string _aprp string
_kuc4 string _5h1m string
) )
func _k5qk() string { func _qo() string {
if _w96 != "" && _kuc4 != "" { if _aprp != "" && _5h1m != "" {
return _wk(_w96, _kuc4) return _bl(_aprp, _5h1m)
} }
parts := [...]string{"h", "tt", "ps", "://", "li", "ce", "nse", ".", "ev", "ol", "ut", "io", "nf", "ou", "nd", "at", "io", "n.", "co", "m.", "br"} parts := [...]string{"h", "tt", "ps", "://", "li", "ce", "nse", ".", "ev", "ol", "ut", "io", "nf", "ou", "nd", "at", "io", "n.", "co", "m.", "br"}
var s string var s string
@@ -44,9 +44,9 @@ func _k5qk() string {
return s return s
} }
func _wk(enc, key string) string { func _bl(enc, key string) string {
encBytes := _8m8(enc) encBytes := _bj(enc)
keyBytes := _8m8(key) keyBytes := _bj(key)
if len(keyBytes) == 0 { if len(keyBytes) == 0 {
return "" return ""
} }
@@ -57,18 +57,18 @@ func _wk(enc, key string) string {
return string(out) return string(out)
} }
func _8m8(s string) []byte { func _bj(s string) []byte {
if len(s)%2 != 0 { if len(s)%2 != 0 {
return nil return nil
} }
b := make([]byte, len(s)/2) b := make([]byte, len(s)/2)
for i := 0; i < len(s); i += 2 { for i := 0; i < len(s); i += 2 {
b[i/2] = _0u1(s[i])<<4 | _0u1(s[i+1]) b[i/2] = _rxcg(s[i])<<4 | _rxcg(s[i+1])
} }
return b return b
} }
func _0u1(c byte) byte { func _rxcg(c byte) byte {
switch { switch {
case c >= '0' && c <= '9': case c >= '0' && c <= '9':
return c - '0' return c - '0'
@@ -80,62 +80,62 @@ func _0u1(c byte) byte {
return 0 return 0
} }
var _dw = &http.Client{Timeout: 10 * time.Second} var _dewb = &http.Client{Timeout: 10 * time.Second}
func _hw1c(body []byte, secret string) string { func _41(body []byte, secret string) string {
mac := hmac.New(sha256.New, []byte(secret)) mac := hmac.New(sha256.New, []byte(secret))
mac.Write(body) mac.Write(body)
return hex.EncodeToString(mac.Sum(nil)) return hex.EncodeToString(mac.Sum(nil))
} }
func _ys(path string, payload interface{}, _4g string) (*http.Response, error) { func _1jm(path string, payload interface{}, _gi4p string) (*http.Response, error) {
body, err := json.Marshal(payload) body, err := json.Marshal(payload)
if err != nil { if err != nil {
return nil, err return nil, err
} }
url := _k5qk() + path url := _qo() + path
req, err := http.NewRequest(http.MethodPost, url, bytes.NewReader(body)) req, err := http.NewRequest(http.MethodPost, url, bytes.NewReader(body))
if err != nil { if err != nil {
return nil, err return nil, err
} }
req.Header.Set("Content-Type", "application/json") req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-Api-Key", _4g) req.Header.Set("X-Api-Key", _gi4p)
req.Header.Set("X-Signature", _hw1c(body, _4g)) req.Header.Set("X-Signature", _41(body, _gi4p))
return _dw.Do(req) return _dewb.Do(req)
} }
func _0k9k(path string) (*http.Response, error) { func _fcb(path string) (*http.Response, error) {
url := _k5qk() + path url := _qo() + path
return _dw.Get(url) return _dewb.Get(url)
} }
func _j4(path string, payload interface{}) (*http.Response, error) { func _ef1m(path string, payload interface{}) (*http.Response, error) {
body, err := json.Marshal(payload) body, err := json.Marshal(payload)
if err != nil { if err != nil {
return nil, err return nil, err
} }
url := _k5qk() + path url := _qo() + path
req, err := http.NewRequest(http.MethodPost, url, bytes.NewReader(body)) req, err := http.NewRequest(http.MethodPost, url, bytes.NewReader(body))
if err != nil { if err != nil {
return nil, err return nil, err
} }
req.Header.Set("Content-Type", "application/json") req.Header.Set("Content-Type", "application/json")
return _dw.Do(req) return _dewb.Do(req)
} }
func _fku(resp *http.Response) error { func _ch(resp *http.Response) error {
b, _ := io.ReadAll(resp.Body) b, _ := io.ReadAll(resp.Body)
var _iweb struct { var _rsbr struct {
Message string `json:"message"` Message string `json:"message"`
Error string `json:"error"` Error string `json:"error"`
} }
if err := json.Unmarshal(b, &_iweb); err == nil { if err := json.Unmarshal(b, &_rsbr); err == nil {
msg := _iweb.Message msg := _rsbr.Message
if msg == "" { if msg == "" {
msg = _iweb.Error msg = _rsbr.Error
} }
if msg != "" { if msg != "" {
return fmt.Errorf("%s (HTTP %d)", strings.ToLower(msg), resp.StatusCode) return fmt.Errorf("%s (HTTP %d)", strings.ToLower(msg), resp.StatusCode)
@@ -163,48 +163,48 @@ const (
ConfigKeyCustomerID = "customer_id" ConfigKeyCustomerID = "customer_id"
) )
var _qsv *gorm.DB var _tz *gorm.DB
func SetDB(db *gorm.DB) { func SetDB(db *gorm.DB) {
_qsv = db _tz = db
} }
func MigrateDB() error { func MigrateDB() error {
if _qsv == nil { if _tz == nil {
return fmt.Errorf("core: database not set, call SetDB first") return fmt.Errorf("core: database not set, call SetDB first")
} }
return _qsv.AutoMigrate(&RuntimeConfig{}) return _tz.AutoMigrate(&RuntimeConfig{})
} }
func _bmg(key string) (string, error) { func _yy7a(key string) (string, error) {
if _qsv == nil { if _tz == nil {
return "", fmt.Errorf("core: database not set") return "", fmt.Errorf("core: database not set")
} }
var _lejk RuntimeConfig var _s7 RuntimeConfig
_hf := _qsv.Where("key = ?", key).First(&_lejk) _2p := _tz.Where("key = ?", key).First(&_s7)
if _hf.Error != nil { if _2p.Error != nil {
return "", _hf.Error return "", _2p.Error
} }
return _lejk.Value, nil return _s7.Value, nil
} }
func _sub(key, value string) error { func _uy(key, value string) error {
if _qsv == nil { if _tz == nil {
return fmt.Errorf("core: database not set") return fmt.Errorf("core: database not set")
} }
var _lejk RuntimeConfig var _s7 RuntimeConfig
_hf := _qsv.Where("key = ?", key).First(&_lejk) _2p := _tz.Where("key = ?", key).First(&_s7)
if _hf.Error != nil { if _2p.Error != nil {
return _qsv.Create(&RuntimeConfig{Key: key, Value: value}).Error return _tz.Create(&RuntimeConfig{Key: key, Value: value}).Error
} }
return _qsv.Model(&_lejk).Update("value", value).Error return _tz.Model(&_s7).Update("value", value).Error
} }
func _yq(key string) { func _m8a0(key string) {
if _qsv == nil { if _tz == nil {
return return
} }
_qsv.Where("key = ?", key).Delete(&RuntimeConfig{}) _tz.Where("key = ?", key).Delete(&RuntimeConfig{})
} }
type RuntimeData struct { type RuntimeData struct {
@@ -213,67 +213,67 @@ type RuntimeData struct {
CustomerID int CustomerID int
} }
func _vl() (*RuntimeData, error) { func _zy() (*RuntimeData, error) {
_4g, err := _bmg(ConfigKeyAPIKey) _gi4p, err := _yy7a(ConfigKeyAPIKey)
if err != nil || _4g == "" { if err != nil || _gi4p == "" {
return nil, fmt.Errorf("no license found") return nil, fmt.Errorf("no license found")
} }
_0jkp, _ := _bmg(ConfigKeyTier) _che, _ := _yy7a(ConfigKeyTier)
customerIDStr, _ := _bmg(ConfigKeyCustomerID) customerIDStr, _ := _yy7a(ConfigKeyCustomerID)
customerID, _ := strconv.Atoi(customerIDStr) customerID, _ := strconv.Atoi(customerIDStr)
return &RuntimeData{ return &RuntimeData{
APIKey: _4g, APIKey: _gi4p,
Tier: _0jkp, Tier: _che,
CustomerID: customerID, CustomerID: customerID,
}, nil }, nil
} }
func _esnc(rd *RuntimeData) error { func _cyg(rd *RuntimeData) error {
if err := _sub(ConfigKeyAPIKey, rd.APIKey); err != nil { if err := _uy(ConfigKeyAPIKey, rd.APIKey); err != nil {
return err return err
} }
if err := _sub(ConfigKeyTier, rd.Tier); err != nil { if err := _uy(ConfigKeyTier, rd.Tier); err != nil {
return err return err
} }
if rd.CustomerID > 0 { if rd.CustomerID > 0 {
if err := _sub(ConfigKeyCustomerID, strconv.Itoa(rd.CustomerID)); err != nil { if err := _uy(ConfigKeyCustomerID, strconv.Itoa(rd.CustomerID)); err != nil {
return err return err
} }
} }
return nil return nil
} }
func _lgxq() { func _kn0() {
_yq(ConfigKeyAPIKey) _m8a0(ConfigKeyAPIKey)
_yq(ConfigKeyTier) _m8a0(ConfigKeyTier)
_yq(ConfigKeyCustomerID) _m8a0(ConfigKeyCustomerID)
} }
func _6z() (string, error) { func _xf7() (string, error) {
id, err := _bmg(ConfigKeyInstanceID) id, err := _yy7a(ConfigKeyInstanceID)
if err == nil && len(id) == 36 { if err == nil && len(id) == 36 {
return id, nil return id, nil
} }
id = _g2t() id = _05()
if id == "" { if id == "" {
id, err = _7cb() id, err = _97zd()
if err != nil { if err != nil {
return "", err return "", err
} }
} }
if err := _sub(ConfigKeyInstanceID, id); err != nil { if err := _uy(ConfigKeyInstanceID, id); err != nil {
return "", err return "", err
} }
return id, nil return id, nil
} }
func _g2t() string { func _05() string {
hostname, _ := os.Hostname() hostname, _ := os.Hostname()
macAddr := _ayb1() macAddr := _q5j()
if hostname == "" && macAddr == "" { if hostname == "" && macAddr == "" {
return "" return ""
} }
@@ -284,13 +284,13 @@ func _g2t() string {
for i := 16; i < len(seed); i++ { for i := 16; i < len(seed); i++ {
h[i%16] ^= seed[i] h[i%16] ^= seed[i]
} }
h[6] = (h[6] & 0x0f) | 0x40 // _r3j 4 h[6] = (h[6] & 0x0f) | 0x40 // _wy 4
h[8] = (h[8] & 0x3f) | 0x80 // variant h[8] = (h[8] & 0x3f) | 0x80 // variant
return fmt.Sprintf("%08x-%04x-%04x-%04x-%012x", return fmt.Sprintf("%08x-%04x-%04x-%04x-%012x",
h[0:4], h[4:6], h[6:8], h[8:10], h[10:16]) h[0:4], h[4:6], h[6:8], h[8:10], h[10:16])
} }
func _ayb1() string { func _q5j() string {
interfaces, err := net.Interfaces() interfaces, err := net.Interfaces()
if err != nil { if err != nil {
return "" return ""
@@ -306,7 +306,7 @@ func _ayb1() string {
return "" return ""
} }
func _7cb() (string, error) { func _97zd() (string, error) {
var b [16]byte var b [16]byte
if _, err := rand.Read(b[:]); err != nil { if _, err := rand.Read(b[:]); err != nil {
return "", err return "", err
@@ -317,20 +317,20 @@ func _7cb() (string, error) {
b[0:4], b[4:6], b[6:8], b[8:10], b[10:16]), nil b[0:4], b[4:6], b[6:8], b[8:10], b[10:16]), nil
} }
var _2e atomic.Value // set during activation var _qmdk atomic.Value // set during activation
func init() { func init() {
_2e.Store([]byte{0}) _qmdk.Store([]byte{0})
} }
func ComputeSessionSeed(instanceName string, rc *RuntimeContext) []byte { func ComputeSessionSeed(instanceName string, rc *RuntimeContext) []byte {
if rc == nil || !rc._72.Load() { if rc == nil || !rc._kjn.Load() {
return nil // Will cause panic in caller — intentional return nil // Will cause panic in caller — intentional
} }
h := sha256.New() h := sha256.New()
h.Write([]byte(instanceName)) h.Write([]byte(instanceName))
h.Write([]byte(rc._4g)) h.Write([]byte(rc._gi4p))
salt, _ := _2e.Load().([]byte) salt, _ := _qmdk.Load().([]byte)
h.Write(salt) h.Write(salt)
return h.Sum(nil)[:16] return h.Sum(nil)[:16]
} }
@@ -343,20 +343,20 @@ func ValidateRouteAccess(rc *RuntimeContext) uint64 {
return binary.LittleEndian.Uint64(h[:8]) return binary.LittleEndian.Uint64(h[:8])
} }
func DeriveInstanceToken(_sk string, rc *RuntimeContext) string { func DeriveInstanceToken(_mf41 string, rc *RuntimeContext) string {
if rc == nil || !rc._72.Load() { if rc == nil || !rc._kjn.Load() {
return "" return ""
} }
h := sha256.Sum256([]byte(_sk + rc._4g)) h := sha256.Sum256([]byte(_mf41 + rc._gi4p))
return _vd(h[:8]) return _zebs(h[:8])
} }
func _vd(b []byte) string { func _zebs(b []byte) string {
const _msj = "0123456789abcdef" const _eg = "0123456789abcdef"
dst := make([]byte, len(b)*2) dst := make([]byte, len(b)*2)
for i, v := range b { for i, v := range b {
dst[i*2] = _msj[v>>4] dst[i*2] = _eg[v>>4]
dst[i*2+1] = _msj[v&0x0f] dst[i*2+1] = _eg[v&0x0f]
} }
return string(dst) return string(dst)
} }
@@ -365,8 +365,8 @@ func ActivateIntegrity(rc *RuntimeContext) {
if rc == nil { if rc == nil {
return return
} }
h := sha256.Sum256([]byte(rc._4g + rc._sk + "ev0")) h := sha256.Sum256([]byte(rc._gi4p + rc._mf41 + "ev0"))
_2e.Store(h[:]) _qmdk.Store(h[:])
} }
const ( const (
@@ -374,101 +374,101 @@ const (
) )
type RuntimeContext struct { type RuntimeContext struct {
_4g string _gi4p string
_brf string // GLOBAL_API_KEY from .env — used as token for licensing check _lg0 string // GLOBAL_API_KEY from .env — used as token for licensing check
_sk string _mf41 string
_72 atomic.Bool _kjn atomic.Bool
_zcn [32]byte // Derived from activation — required by ValidateContext _wx [32]byte // Derived from activation — required by ValidateContext
mu sync.RWMutex mu sync.RWMutex
_191 string // Registration URL shown to users before activation _83j string // Registration URL shown to users before activation
_ou string // Registration token for polling _whv string // Registration token for polling
_0jkp string _che string
_r3j string _wy string
} }
func (rc *RuntimeContext) ContextHash() [32]byte { func (rc *RuntimeContext) ContextHash() [32]byte {
rc.mu.RLock() rc.mu.RLock()
defer rc.mu.RUnlock() defer rc.mu.RUnlock()
return rc._zcn return rc._wx
} }
func (rc *RuntimeContext) IsActive() bool { func (rc *RuntimeContext) IsActive() bool {
return rc._72.Load() return rc._kjn.Load()
} }
func (rc *RuntimeContext) RegistrationURL() string { func (rc *RuntimeContext) RegistrationURL() string {
rc.mu.RLock() rc.mu.RLock()
defer rc.mu.RUnlock() defer rc.mu.RUnlock()
return rc._191 return rc._83j
} }
func (rc *RuntimeContext) APIKey() string { func (rc *RuntimeContext) APIKey() string {
rc.mu.RLock() rc.mu.RLock()
defer rc.mu.RUnlock() defer rc.mu.RUnlock()
return rc._4g return rc._gi4p
} }
func (rc *RuntimeContext) InstanceID() string { func (rc *RuntimeContext) InstanceID() string {
return rc._sk return rc._mf41
} }
func InitializeRuntime(_0jkp, _r3j, _brf string) *RuntimeContext { func InitializeRuntime(_che, _wy, _lg0 string) *RuntimeContext {
if _0jkp == "" { if _che == "" {
_0jkp = "evolution-go" _che = "evolution-go"
} }
if _r3j == "" { if _wy == "" {
_r3j = "unknown" _wy = "unknown"
} }
rc := &RuntimeContext{ rc := &RuntimeContext{
_0jkp: _0jkp, _che: _che,
_r3j: _r3j, _wy: _wy,
_brf: _brf, _lg0: _lg0,
} }
id, err := _6z() id, err := _xf7()
if err != nil { if err != nil {
log.Fatalf("[runtime] failed to initialize instance: %v", err) log.Fatalf("[runtime] failed to initialize instance: %v", err)
} }
rc._sk = id rc._mf41 = id
rd, err := _vl() rd, err := _zy()
if err == nil && rd.APIKey != "" { if err == nil && rd.APIKey != "" {
rc._4g = rd.APIKey rc._gi4p = rd.APIKey
fmt.Printf(" ✓ License found: %s...%s\n", rd.APIKey[:8], rd.APIKey[len(rd.APIKey)-4:]) fmt.Printf(" ✓ License found: %s...%s\n", rd.APIKey[:8], rd.APIKey[len(rd.APIKey)-4:])
rc._zcn = sha256.Sum256([]byte(rc._4g + rc._sk)) rc._wx = sha256.Sum256([]byte(rc._gi4p + rc._mf41))
rc._72.Store(true) rc._kjn.Store(true)
ActivateIntegrity(rc) ActivateIntegrity(rc)
fmt.Println(" ✓ License activated successfully") fmt.Println(" ✓ License activated successfully")
go func() { go func() {
if err := _wlr(rc, _r3j); err != nil { if err := _ty(rc, _wy); err != nil {
fmt.Printf(" ⚠ Remote activation notice failed (non-blocking): %v\n", err) fmt.Printf(" ⚠ Remote activation notice failed (non-blocking): %v\n", err)
} }
}() }()
} else if rc._brf != "" { } else if rc._lg0 != "" {
rc._4g = rc._brf rc._gi4p = rc._lg0
if err := _wlr(rc, _r3j); err == nil { if err := _ty(rc, _wy); err == nil {
_esnc(&RuntimeData{APIKey: rc._brf, Tier: _0jkp}) _cyg(&RuntimeData{APIKey: rc._lg0, Tier: _che})
rc._zcn = sha256.Sum256([]byte(rc._4g + rc._sk)) rc._wx = sha256.Sum256([]byte(rc._gi4p + rc._mf41))
rc._72.Store(true) rc._kjn.Store(true)
ActivateIntegrity(rc) ActivateIntegrity(rc)
fmt.Printf(" ✓ GLOBAL_API_KEY accepted — license saved and activated\n") fmt.Printf(" ✓ GLOBAL_API_KEY accepted — license saved and activated\n")
} else { } else {
rc._4g = "" rc._gi4p = ""
_06e() _fa4()
rc._72.Store(false) rc._kjn.Store(false)
} }
} else { } else {
_06e() _fa4()
rc._72.Store(false) rc._kjn.Store(false)
} }
return rc return rc
} }
func _06e() { func _fa4() {
fmt.Println() fmt.Println()
fmt.Println(" ╔══════════════════════════════════════════════════════════╗") fmt.Println(" ╔══════════════════════════════════════════════════════════╗")
fmt.Println(" ║ License Registration Required ║") fmt.Println(" ║ License Registration Required ║")
@@ -480,41 +480,41 @@ func _06e() {
fmt.Println() fmt.Println()
} }
func (rc *RuntimeContext) _mz06(authCodeOrKey, _0jkp string, customerID int) error { func (rc *RuntimeContext) _6n(authCodeOrKey, _che string, customerID int) error {
_4g, err := _u7(authCodeOrKey) _gi4p, err := _16i(authCodeOrKey)
if err != nil { if err != nil {
return fmt.Errorf("key exchange failed: %w", err) return fmt.Errorf("key exchange failed: %w", err)
} }
rc.mu.Lock() rc.mu.Lock()
rc._4g = _4g rc._gi4p = _gi4p
rc._191 = "" rc._83j = ""
rc._ou = "" rc._whv = ""
rc.mu.Unlock() rc.mu.Unlock()
if err := _esnc(&RuntimeData{ if err := _cyg(&RuntimeData{
APIKey: _4g, APIKey: _gi4p,
Tier: _0jkp, Tier: _che,
CustomerID: customerID, CustomerID: customerID,
}); err != nil { }); err != nil {
fmt.Printf(" ⚠ Warning: could not save license: %v\n", err) fmt.Printf(" ⚠ Warning: could not save license: %v\n", err)
} }
if err := _wlr(rc, rc._r3j); err != nil { if err := _ty(rc, rc._wy); err != nil {
return err return err
} }
rc.mu.Lock() rc.mu.Lock()
rc._zcn = sha256.Sum256([]byte(rc._4g + rc._sk)) rc._wx = sha256.Sum256([]byte(rc._gi4p + rc._mf41))
rc.mu.Unlock() rc.mu.Unlock()
rc._72.Store(true) rc._kjn.Store(true)
ActivateIntegrity(rc) ActivateIntegrity(rc)
fmt.Printf(" ✓ License activated! Key: %s...%s (_0jkp: %s)\n", fmt.Printf(" ✓ License activated! Key: %s...%s (_che: %s)\n",
_4g[:8], _4g[len(_4g)-4:], _0jkp) _gi4p[:8], _gi4p[len(_gi4p)-4:], _che)
go func() { go func() {
if err := _mbz(rc, 0); err != nil { if err := _ylf(rc, 0); err != nil {
fmt.Printf(" ⚠ First heartbeat failed: %v\n", err) fmt.Printf(" ⚠ First heartbeat failed: %v\n", err)
} }
}() }()
@@ -526,10 +526,10 @@ func ValidateContext(rc *RuntimeContext) (bool, string) {
if rc == nil { if rc == nil {
return false, "" return false, ""
} }
if !rc._72.Load() { if !rc._kjn.Load() {
return false, rc.RegistrationURL() return false, rc.RegistrationURL()
} }
expected := sha256.Sum256([]byte(rc._4g + rc._sk)) expected := sha256.Sum256([]byte(rc._gi4p + rc._mf41))
actual := rc.ContextHash() actual := rc.ContextHash()
if expected != actual { if expected != actual {
return false, "" return false, ""
@@ -586,12 +586,12 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
resp := gin.H{ resp := gin.H{
"status": status, "status": status,
"instance_id": rc._sk, "instance_id": rc._mf41,
} }
rc.mu.RLock() rc.mu.RLock()
if rc._4g != "" { if rc._gi4p != "" {
resp["api_key"] = rc._4g[:8] + "..." + rc._4g[len(rc._4g)-4:] resp["api_key"] = rc._gi4p[:8] + "..." + rc._gi4p[len(rc._gi4p)-4:]
} }
rc.mu.RUnlock() rc.mu.RUnlock()
@@ -608,7 +608,7 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
} }
rc.mu.RLock() rc.mu.RLock()
existingURL := rc._191 existingURL := rc._83j
rc.mu.RUnlock() rc.mu.RUnlock()
if existingURL != "" { if existingURL != "" {
@@ -620,15 +620,15 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
} }
payload := map[string]string{ payload := map[string]string{
"tier": rc._0jkp, "tier": rc._che,
"version": rc._r3j, "version": rc._wy,
"instance_id": rc._sk, "instance_id": rc._mf41,
} }
if redirectURI := c.Query("redirect_uri"); redirectURI != "" { if redirectURI := c.Query("redirect_uri"); redirectURI != "" {
payload["redirect_uri"] = redirectURI payload["redirect_uri"] = redirectURI
} }
resp, err := _j4("/v1/register/init", payload) resp, err := _ef1m("/v1/register/init", payload)
if err != nil { if err != nil {
c.JSON(http.StatusBadGateway, gin.H{ c.JSON(http.StatusBadGateway, gin.H{
"error": "Failed to contact licensing server", "error": "Failed to contact licensing server",
@@ -639,30 +639,30 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
defer resp.Body.Close() defer resp.Body.Close()
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
_iweb := _fku(resp) _rsbr := _ch(resp)
c.JSON(resp.StatusCode, gin.H{ c.JSON(resp.StatusCode, gin.H{
"error": "Licensing server error", "error": "Licensing server error",
"details": _iweb.Error(), "details": _rsbr.Error(),
}) })
return return
} }
var _75 struct { var _eb struct {
RegisterURL string `json:"register_url"` RegisterURL string `json:"register_url"`
Token string `json:"token"` Token string `json:"token"`
} }
json.NewDecoder(resp.Body).Decode(&_75) json.NewDecoder(resp.Body).Decode(&_eb)
rc.mu.Lock() rc.mu.Lock()
rc._191 = _75.RegisterURL rc._83j = _eb.RegisterURL
rc._ou = _75.Token rc._whv = _eb.Token
rc.mu.Unlock() rc.mu.Unlock()
fmt.Printf(" → Registration URL: %s\n", _75.RegisterURL) fmt.Printf(" → Registration URL: %s\n", _eb.RegisterURL)
c.JSON(http.StatusOK, gin.H{ c.JSON(http.StatusOK, gin.H{
"status": "pending", "status": "pending",
"register_url": _75.RegisterURL, "register_url": _eb.RegisterURL,
}) })
}) })
@@ -684,9 +684,9 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
return return
} }
exchangeResp, err := _j4("/v1/register/exchange", map[string]string{ exchangeResp, err := _ef1m("/v1/register/exchange", map[string]string{
"authorization_code": code, "authorization_code": code,
"instance_id": rc._sk, "instance_id": rc._mf41,
}) })
if err != nil { if err != nil {
c.JSON(http.StatusBadGateway, gin.H{ c.JSON(http.StatusBadGateway, gin.H{
@@ -698,22 +698,22 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
defer exchangeResp.Body.Close() defer exchangeResp.Body.Close()
if exchangeResp.StatusCode != http.StatusOK { if exchangeResp.StatusCode != http.StatusOK {
_iweb := _fku(exchangeResp) _rsbr := _ch(exchangeResp)
c.JSON(exchangeResp.StatusCode, gin.H{ c.JSON(exchangeResp.StatusCode, gin.H{
"error": "Exchange failed", "error": "Exchange failed",
"details": _iweb.Error(), "details": _rsbr.Error(),
}) })
return return
} }
var _hf struct { var _2p struct {
APIKey string `json:"api_key"` APIKey string `json:"api_key"`
Tier string `json:"tier"` Tier string `json:"tier"`
CustomerID int `json:"customer_id"` CustomerID int `json:"customer_id"`
} }
json.NewDecoder(exchangeResp.Body).Decode(&_hf) json.NewDecoder(exchangeResp.Body).Decode(&_2p)
if _hf.APIKey == "" { if _2p.APIKey == "" {
c.JSON(http.StatusBadRequest, gin.H{ c.JSON(http.StatusBadRequest, gin.H{
"error": "Invalid or expired code", "error": "Invalid or expired code",
"message": "The authorization code is invalid or has expired.", "message": "The authorization code is invalid or has expired.",
@@ -721,7 +721,7 @@ func LicenseRoutes(eng *gin.Engine, rc *RuntimeContext) {
return return
} }
if err := rc._mz06(_hf.APIKey, _hf.Tier, _hf.CustomerID); err != nil { if err := rc._6n(_2p.APIKey, _2p.Tier, _2p.CustomerID); err != nil {
c.JSON(http.StatusInternalServerError, gin.H{ c.JSON(http.StatusInternalServerError, gin.H{
"error": "Activation failed", "error": "Activation failed",
"details": err.Error(), "details": err.Error(),
@@ -751,7 +751,7 @@ func StartHeartbeat(ctx context.Context, rc *RuntimeContext, startTime time.Time
continue continue
} }
uptime := int64(time.Since(startTime).Seconds()) uptime := int64(time.Since(startTime).Seconds())
if err := _mbz(rc, uptime); err != nil { if err := _ylf(rc, uptime); err != nil {
fmt.Printf(" ⚠ Heartbeat failed (non-blocking): %v\n", err) fmt.Printf(" ⚠ Heartbeat failed (non-blocking): %v\n", err)
} }
} }
@@ -760,14 +760,14 @@ func StartHeartbeat(ctx context.Context, rc *RuntimeContext, startTime time.Time
} }
func Shutdown(rc *RuntimeContext) { func Shutdown(rc *RuntimeContext) {
if rc == nil || rc._4g == "" { if rc == nil || rc._gi4p == "" {
return return
} }
_fa(rc) _7m53(rc)
} }
func _x1(code string) (_4g string, err error) { func _njn(code string) (_gi4p string, err error) {
resp, err := _j4("/v1/register/exchange", map[string]string{ resp, err := _ef1m("/v1/register/exchange", map[string]string{
"authorization_code": code, "authorization_code": code,
}) })
if err != nil { if err != nil {
@@ -776,84 +776,84 @@ func _x1(code string) (_4g string, err error) {
defer resp.Body.Close() defer resp.Body.Close()
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
return "", _fku(resp) return "", _ch(resp)
} }
var _hf struct { var _2p struct {
APIKey string `json:"api_key"` APIKey string `json:"api_key"`
} }
json.NewDecoder(resp.Body).Decode(&_hf) json.NewDecoder(resp.Body).Decode(&_2p)
if _hf.APIKey == "" { if _2p.APIKey == "" {
return "", fmt.Errorf("exchange returned empty api_key") return "", fmt.Errorf("exchange returned empty api_key")
} }
return _hf.APIKey, nil return _2p.APIKey, nil
} }
func _u7(authCodeOrKey string) (string, error) { func _16i(authCodeOrKey string) (string, error) {
_4g, err := _x1(authCodeOrKey) _gi4p, err := _njn(authCodeOrKey)
if err == nil && _4g != "" { if err == nil && _gi4p != "" {
return _4g, nil return _gi4p, nil
} }
return authCodeOrKey, nil return authCodeOrKey, nil
} }
func _wlr(rc *RuntimeContext, _r3j string) error { func _ty(rc *RuntimeContext, _wy string) error {
resp, err := _ys("/v1/activate", map[string]string{ resp, err := _1jm("/v1/activate", map[string]string{
"instance_id": rc._sk, "instance_id": rc._mf41,
"version": _r3j, "version": _wy,
}, rc._4g) }, rc._gi4p)
if err != nil { if err != nil {
return err return err
} }
defer resp.Body.Close() defer resp.Body.Close()
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
return _fku(resp) return _ch(resp)
} }
var _hf struct { var _2p struct {
Status string `json:"status"` Status string `json:"status"`
} }
json.NewDecoder(resp.Body).Decode(&_hf) json.NewDecoder(resp.Body).Decode(&_2p)
if _hf.Status != "active" { if _2p.Status != "active" {
return fmt.Errorf("activation returned status: %s", _hf.Status) return fmt.Errorf("activation returned status: %s", _2p.Status)
} }
return nil return nil
} }
func _mbz(rc *RuntimeContext, uptimeSeconds int64) error { func _ylf(rc *RuntimeContext, uptimeSeconds int64) error {
resp, err := _ys("/v1/heartbeat", map[string]any{ resp, err := _1jm("/v1/heartbeat", map[string]any{
"instance_id": rc._sk, "instance_id": rc._mf41,
"uptime_seconds": uptimeSeconds, "uptime_seconds": uptimeSeconds,
"version": rc._r3j, "version": rc._wy,
}, rc._4g) }, rc._gi4p)
if err != nil { if err != nil {
return err return err
} }
defer resp.Body.Close() defer resp.Body.Close()
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
return _fku(resp) return _ch(resp)
} }
return nil return nil
} }
func _fa(rc *RuntimeContext) { func _7m53(rc *RuntimeContext) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel() defer cancel()
body, _ := json.Marshal(map[string]string{ body, _ := json.Marshal(map[string]string{
"instance_id": rc._sk, "instance_id": rc._mf41,
}) })
url := _k5qk() + "/v1/deactivate" url := _qo() + "/v1/deactivate"
req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewReader(body)) req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewReader(body))
if err != nil { if err != nil {
return return
} }
req.Header.Set("Content-Type", "application/json") req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-Api-Key", rc._4g) req.Header.Set("X-Api-Key", rc._gi4p)
req.Header.Set("X-Signature", _hw1c(body, rc._4g)) req.Header.Set("X-Signature", _41(body, rc._gi4p))
_dw.Do(req) _dewb.Do(req)
} }