| 186 | } |
| 187 | |
| 188 | func generateEventID() string { |
| 189 | b := make([]byte, 16) |
| 190 | if _, err := rand.Read(b); err != nil { |
| 191 | // crypto/rand failure means the OS RNG is broken; an |
| 192 | // all-zero event ID would collide across firings. Panic so |
| 193 | // the caller surfaces a 500 rather than silently emitting |
| 194 | // non-unique IDs. |
| 195 | panic(fmt.Sprintf("webhookpub: crypto/rand failed: %v", err)) |
| 196 | } |
| 197 | return "evt_" + hex.EncodeToString(b) |
| 198 | } |
| 199 | |
| 200 | // DeterministicEventID derives a stable event id from the trigger |
| 201 | // context. Per design §5.1, the input formula per event type is: |