Skip to content

Commit 6032527

Browse files
authored
Merge branch 'main' into enhancement/websub-deprecation
2 parents 6a1ce04 + ccf153e commit 6032527

File tree

2 files changed

+46
-32
lines changed

2 files changed

+46
-32
lines changed

cmd/events.go

+18-3
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func init() {
8383
// flags for forwarding functionality/changing payloads
8484
triggerCmd.Flags().StringVarP(&forwardAddress, "forward-address", "F", "", "Forward address for mock event.")
8585
triggerCmd.Flags().StringVarP(&transport, "transport", "T", "eventsub", fmt.Sprintf("Preferred transport method for event. Defaults to /EventSub.\nSupported values: %s", events.ValidTransports()))
86-
triggerCmd.Flags().StringVarP(&secret, "secret", "s", "", "Webhook secret. If defined, signs all forwarded events with the SHA256 HMAC.")
86+
triggerCmd.Flags().StringVarP(&secret, "secret", "s", "", "Webhook secret. If defined, signs all forwarded events with the SHA256 HMAC and must be 10-100 characters in length.")
8787

8888
// per-topic flags
8989
triggerCmd.Flags().StringVarP(&toUser, "to-user", "t", "", "User ID of the receiver of the event. For example, the user that receives a follow. In most contexts, this is the broadcaster.")
@@ -101,13 +101,13 @@ func init() {
101101
// retrigger flags
102102
retriggerCmd.Flags().StringVarP(&forwardAddress, "forward-address", "F", "", "Forward address for mock event.")
103103
retriggerCmd.Flags().StringVarP(&eventID, "id", "i", "", "ID of the event to be refired.")
104-
retriggerCmd.Flags().StringVarP(&secret, "secret", "s", "", "Webhook secret. If defined, signs all forwarded events with the SHA256 HMAC.")
104+
retriggerCmd.Flags().StringVarP(&secret, "secret", "s", "", "Webhook secret. If defined, signs all forwarded events with the SHA256 HMAC and must be 10-100 characters in length.")
105105
retriggerCmd.MarkFlagRequired("id")
106106

107107
// verify-subscription flags
108108
verifyCmd.Flags().StringVarP(&forwardAddress, "forward-address", "F", "", "Forward address for mock event.")
109109
verifyCmd.Flags().StringVarP(&transport, "transport", "T", "eventsub", fmt.Sprintf("Preferred transport method for event. Defaults to EventSub.\nSupported values: %s", events.ValidTransports()))
110-
verifyCmd.Flags().StringVarP(&secret, "secret", "s", "", "Webhook secret. If defined, signs all forwarded events with the SHA256 HMAC.")
110+
verifyCmd.Flags().StringVarP(&secret, "secret", "s", "", "Webhook secret. If defined, signs all forwarded events with the SHA256 HMAC and must be 10-100 characters in length.")
111111
verifyCmd.MarkFlagRequired("forward-address")
112112
}
113113

@@ -119,6 +119,11 @@ func triggerCmdRun(cmd *cobra.Command, args []string) {
119119

120120
if transport == "websub" {
121121
fmt.Println(websubDeprecationNotice)
122+
return
123+
}
124+
125+
if secret != "" && (len(secret) < 10 || len(secret) > 100) {
126+
fmt.Println("Invalid secret provided. Secrets must be between 10-100 characters")
122127
return
123128
}
124129

@@ -161,6 +166,11 @@ func triggerCmdRun(cmd *cobra.Command, args []string) {
161166
func retriggerCmdRun(cmd *cobra.Command, args []string) {
162167
if transport == "websub" {
163168
fmt.Println(websubDeprecationNotice)
169+
return
170+
}
171+
172+
if secret != "" && (len(secret) < 10 || len(secret) > 100) {
173+
fmt.Println("Invalid secret provided. Secrets must be between 10-100 characters")
164174
return
165175
}
166176

@@ -184,6 +194,11 @@ func verifyCmdRun(cmd *cobra.Command, args []string) {
184194

185195
if transport == "websub" {
186196
fmt.Println(websubDeprecationNotice)
197+
return
198+
}
199+
200+
if secret != "" && (len(secret) < 10 || len(secret) > 100) {
201+
fmt.Println("Invalid secret provided. Secrets must be between 10-100 characters")
187202
return
188203
}
189204

docs/event.md

+28-29
Original file line numberDiff line numberDiff line change
@@ -57,27 +57,24 @@ Used to either create or send mock events for use with local webhooks testing.
5757

5858
**Flags**
5959

60-
Flag | Shorthand | Description | Example | Required? (Y/N)
61-
---------------------|-----------|---------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------|-----------------
62-
`--forward-address` | `-F` | Web server address for where to send mock events. | `-F https://localhost:8080` | N
63-
`--transport` | `-T` | The method used to send events. Default is `eventsub`. | `-T eventsub` | N
64-
`--to-user` | `-t` | Denotes the receiver's TUID of the event, usually the broadcaster. | `-t 44635596` | N
65-
`--from-user` | `-f` | Denotes the sender's TUID of the event, for example the user that follows another user or the subscriber to a broadcaster. | `-f 44635596` | N
66-
`--gift-user` | `-g` | Used only for subcription-based events, denotes the gifting user ID | `-g 44635596` | N
67-
`--secret` | `-s` | Webhook secret. If defined, signs all forwarded events with the SHA256 HMAC. | `-s testsecret` | N
68-
`--count` | `-c` | Count of events to fire. This can be used to simulate an influx of events. | `-c 100` | N
69-
`--anonymous` | `-a` | If the event is anonymous. Only applies to `gift` and `cheer` events. | `-a` | N
70-
`--status` | `-S` | Status of the event object, currently applies to channel points redemptions. | `-S fulfilled` | N
71-
`--item-id` | `-i` | Manually set the ID of the event payload item (for example the reward ID in redemption events or game in stream events). | `-i 032e4a6c-4aef-11eb-a9f5-1f703d1f0b92` | N
72-
`--item-name` | `-n` | Manually set the name of the event payload item (for example the reward ID in redemption events or game name in stream events). | `-n "Science & Technology"` | N
73-
`--cost` | `-C` | Amount of bits or channel points redeemed/used in the event. | `-C 250` | N
74-
`--description` | `-d` | Title the stream should be updated/started with. | `-d Awesome new title!` | N
75-
`--game-id` | `-G` | Game ID for Drop or other relevant events. | `-G 1234` | N
60+
| Flag | Shorthand | Description | Example | Required? (Y/N) |
61+
|---------------------|-----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------|-----------------|
62+
| `--forward-address` | `-F` | Web server address for where to send mock events. | `-F https://localhost:8080` | N |
63+
| `--transport` | `-T` | The method used to send events. Default is `eventsub`. | `-T eventsub` | N |
64+
| `--to-user` | `-t` | Denotes the receiver's TUID of the event, usually the broadcaster. | `-t 44635596` | N |
65+
| `--from-user` | `-f` | Denotes the sender's TUID of the event, for example the user that follows another user or the subscriber to a broadcaster. | `-f 44635596` | N |
66+
| `--gift-user` | `-g` | Used only for subcription-based events, denotes the gifting user ID | `-g 44635596` | N |
67+
| `--secret` | `-s` | Webhook secret. If defined, signs all forwarded events with the SHA256 HMAC and must be 10-100 characters in length. | `-s testsecret` | N |
68+
| `--count` | `-c` | Count of events to fire. This can be used to simulate an influx of events. | `-c 100` | N |
69+
| `--anonymous` | `-a` | If the event is anonymous. Only applies to `gift` and `cheer` events. | `-a` | N |
70+
| `--status` | `-S` | Status of the event object, currently applies to channel points redemptions. | `-S fulfilled` | N |
71+
| `--item-id` | `-i` | Manually set the ID of the event payload item (for example the reward ID in redemption events or game in stream events). | `-i 032e4a6c-4aef-11eb-a9f5-1f703d1f0b92` | N |
72+
| `--item-name` | `-n` | Manually set the name of the event payload item (for example the reward ID in redemption events or game name in stream events). | `-n "Science & Technology"` | N |
73+
| `--cost` | `-C` | Amount of bits or channel points redeemed/used in the event. | `-C 250` | N |
74+
| `--description` | `-d` | Title the stream should be updated/started with. | `-d Awesome new title!` | N |
75+
| `--game-id` | `-G` | Game ID for Drop or other relevant events. | `-G 1234` | N |
7676

7777

78-
79-
**Examples**
80-
8178
```sh
8279
twitch event trigger subscribe -F https://localhost:8080/ // triggers a randomly generated subscribe event and forwards to the localhost:8080 server
8380
twitch event trigger cheer -f 1234 -t 4567 // generates JSON for a cheer event from user 1234 to user 4567
@@ -106,11 +103,11 @@ None
106103

107104
**Flags**
108105

109-
| Flag | Shorthand | Description | Example | Required? (Y/N) |
110-
| ------------------- | --------- | ---------------------------------------------------------------------------- | --------------------------- | --------------- |
111-
| `--forward-address` | `-F` | Web server address for where to send mock events. | `-F https://localhost:8080` | N |
112-
| `--id` | `-i` | The ID of the event to refire. | `-i <id>` | Y |
113-
| `--secret` | `-s` | Webhook secret. If defined, signs all forwarded events with the SHA256 HMAC. | `-s testsecret` | N |
106+
| Flag | Shorthand | Description | Example | Required? (Y/N) |
107+
|---------------------|-----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|-----------------|
108+
| `--forward-address` | `-F` | Web server address for where to send mock events. | `-F https://localhost:8080` | N |
109+
| `--id` | `-i` | The ID of the event to refire. | `-i <id>` | Y |
110+
| `--secret` | `-s` | Webhook secret. If defined, signs all forwarded events with the SHA256 HMAC and must be 10-100 characters in length. | `-s testsecret` | N |
114111

115112
**Examples**
116113

@@ -163,11 +160,13 @@ Allows you to test if your webserver responds to subscription requests properly.
163160

164161
**Flags**
165162

166-
| Flag | Shorthand | Description | Example | Required? (Y/N) |
167-
|---------------------|-----------|------------------------------------------------------------------------------|-----------------------------|-----------------|
168-
| `--forward-address` | `-F` | Web server address for where to send mock subscription. | `-F https://localhost:8080` | Y |
169-
| `--secret` | `-s` | Webhook secret. If defined, signs all forwarded events with the SHA256 HMAC. | `-s testsecret` | N |
170-
| `--transport` | `-T` | The method used to send events. Default is `eventsub`. | `-T eventsub` | N |
163+
| Flag | Shorthand | Description | Example | Required? (Y/N) |
164+
|---------------------|-----------|----------------------------------------------------------------------------------------------------------------------|-----------------------------|-----------------|
165+
| `--forward-address` | `-F` | Web server address for where to send mock subscription. | `-F https://localhost:8080` | Y |
166+
| `--secret` | `-s` | Webhook secret. If defined, signs all forwarded events with the SHA256 HMAC and must be 10-100 characters in length. | `-s testsecret` | N |
167+
| `--transport` | `-T` | The method used to send events. Default is `eventsub`. | `-T eventsub` | N |
168+
169+
171170

172171
**Examples**
173172

0 commit comments

Comments
 (0)