Skip to content

Commit a3add10

Browse files
author
stlc-bot
committed
Add HMAC signing for outbound webhooks (#21145)
Stainless-Generated-From: d6f22be8336a869c5e2479fd0b86dfec027b4036
1 parent 28b65a9 commit a3add10

48 files changed

Lines changed: 839 additions & 20 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎llama-cloud-core/src/main/kotlin/com/llamacloud_prod/api/models/beta/batch/BatchCreateParams.kt‎

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9335,6 +9335,7 @@ private constructor(
93359335
private val webhookEvents: JsonField<List<WebhookEvent>>,
93369336
private val webhookHeaders: JsonField<WebhookHeaders>,
93379337
private val webhookOutputFormat: JsonField<String>,
9338+
private val webhookSigningSecret: JsonField<String>,
93389339
private val webhookUrl: JsonField<String>,
93399340
private val additionalProperties: MutableMap<String, JsonValue>,
93409341
) {
@@ -9350,13 +9351,17 @@ private constructor(
93509351
@JsonProperty("webhook_output_format")
93519352
@ExcludeMissing
93529353
webhookOutputFormat: JsonField<String> = JsonMissing.of(),
9354+
@JsonProperty("webhook_signing_secret")
9355+
@ExcludeMissing
9356+
webhookSigningSecret: JsonField<String> = JsonMissing.of(),
93539357
@JsonProperty("webhook_url")
93549358
@ExcludeMissing
93559359
webhookUrl: JsonField<String> = JsonMissing.of(),
93569360
) : this(
93579361
webhookEvents,
93589362
webhookHeaders,
93599363
webhookOutputFormat,
9364+
webhookSigningSecret,
93609365
webhookUrl,
93619366
mutableMapOf(),
93629367
)
@@ -9389,6 +9394,18 @@ private constructor(
93899394
fun webhookOutputFormat(): Optional<String> =
93909395
webhookOutputFormat.getOptional("webhook_output_format")
93919396

9397+
/**
9398+
* Shared signing secret used to sign webhook deliveries. When set, each request
9399+
* includes an HMAC-SHA256 signature of the request body in the 'LC-Signature'
9400+
* header (value 'sha256=<hex>'). Recompute the HMAC over the raw request body
9401+
* with this secret to verify the delivery is authentic.
9402+
*
9403+
* @throws LlamaCloudInvalidDataException if the JSON field has an unexpected
9404+
* type (e.g. if the server responded with an unexpected value).
9405+
*/
9406+
fun webhookSigningSecret(): Optional<String> =
9407+
webhookSigningSecret.getOptional("webhook_signing_secret")
9408+
93929409
/**
93939410
* URL to receive webhook POST notifications
93949411
*
@@ -9427,6 +9444,16 @@ private constructor(
94279444
@ExcludeMissing
94289445
fun _webhookOutputFormat(): JsonField<String> = webhookOutputFormat
94299446

9447+
/**
9448+
* Returns the raw JSON value of [webhookSigningSecret].
9449+
*
9450+
* Unlike [webhookSigningSecret], this method doesn't throw if the JSON field
9451+
* has an unexpected type.
9452+
*/
9453+
@JsonProperty("webhook_signing_secret")
9454+
@ExcludeMissing
9455+
fun _webhookSigningSecret(): JsonField<String> = webhookSigningSecret
9456+
94309457
/**
94319458
* Returns the raw JSON value of [webhookUrl].
94329459
*
@@ -9464,6 +9491,7 @@ private constructor(
94649491
private var webhookEvents: JsonField<MutableList<WebhookEvent>>? = null
94659492
private var webhookHeaders: JsonField<WebhookHeaders> = JsonMissing.of()
94669493
private var webhookOutputFormat: JsonField<String> = JsonMissing.of()
9494+
private var webhookSigningSecret: JsonField<String> = JsonMissing.of()
94679495
private var webhookUrl: JsonField<String> = JsonMissing.of()
94689496
private var additionalProperties: MutableMap<String, JsonValue> =
94699497
mutableMapOf()
@@ -9474,6 +9502,7 @@ private constructor(
94749502
webhookConfiguration.webhookEvents.map { it.toMutableList() }
94759503
webhookHeaders = webhookConfiguration.webhookHeaders
94769504
webhookOutputFormat = webhookConfiguration.webhookOutputFormat
9505+
webhookSigningSecret = webhookConfiguration.webhookSigningSecret
94779506
webhookUrl = webhookConfiguration.webhookUrl
94789507
additionalProperties =
94799508
webhookConfiguration.additionalProperties.toMutableMap()
@@ -9561,6 +9590,33 @@ private constructor(
95619590
this.webhookOutputFormat = webhookOutputFormat
95629591
}
95639592

9593+
/**
9594+
* Shared signing secret used to sign webhook deliveries. When set, each
9595+
* request includes an HMAC-SHA256 signature of the request body in the
9596+
* 'LC-Signature' header (value 'sha256=<hex>'). Recompute the HMAC over the
9597+
* raw request body with this secret to verify the delivery is authentic.
9598+
*/
9599+
fun webhookSigningSecret(webhookSigningSecret: String?) =
9600+
webhookSigningSecret(JsonField.ofNullable(webhookSigningSecret))
9601+
9602+
/**
9603+
* Alias for calling [Builder.webhookSigningSecret] with
9604+
* `webhookSigningSecret.orElse(null)`.
9605+
*/
9606+
fun webhookSigningSecret(webhookSigningSecret: Optional<String>) =
9607+
webhookSigningSecret(webhookSigningSecret.getOrNull())
9608+
9609+
/**
9610+
* Sets [Builder.webhookSigningSecret] to an arbitrary JSON value.
9611+
*
9612+
* You should usually call [Builder.webhookSigningSecret] with a well-typed
9613+
* [String] value instead. This method is primarily for setting the field to
9614+
* an undocumented or not yet supported value.
9615+
*/
9616+
fun webhookSigningSecret(webhookSigningSecret: JsonField<String>) = apply {
9617+
this.webhookSigningSecret = webhookSigningSecret
9618+
}
9619+
95649620
/** URL to receive webhook POST notifications */
95659621
fun webhookUrl(webhookUrl: String?) =
95669622
webhookUrl(JsonField.ofNullable(webhookUrl))
@@ -9614,6 +9670,7 @@ private constructor(
96149670
(webhookEvents ?: JsonMissing.of()).map { it.toImmutable() },
96159671
webhookHeaders,
96169672
webhookOutputFormat,
9673+
webhookSigningSecret,
96179674
webhookUrl,
96189675
additionalProperties.toMutableMap(),
96199676
)
@@ -9639,6 +9696,7 @@ private constructor(
96399696
webhookEvents().ifPresent { it.forEach { it.validate() } }
96409697
webhookHeaders().ifPresent { it.validate() }
96419698
webhookOutputFormat()
9699+
webhookSigningSecret()
96429700
webhookUrl()
96439701
validated = true
96449702
}
@@ -9663,6 +9721,7 @@ private constructor(
96639721
?: 0) +
96649722
(webhookHeaders.asKnown().getOrNull()?.validity() ?: 0) +
96659723
(if (webhookOutputFormat.asKnown().isPresent) 1 else 0) +
9724+
(if (webhookSigningSecret.asKnown().isPresent) 1 else 0) +
96669725
(if (webhookUrl.asKnown().isPresent) 1 else 0)
96679726

96689727
class WebhookEvent
@@ -10103,6 +10162,7 @@ private constructor(
1010310162
webhookEvents == other.webhookEvents &&
1010410163
webhookHeaders == other.webhookHeaders &&
1010510164
webhookOutputFormat == other.webhookOutputFormat &&
10165+
webhookSigningSecret == other.webhookSigningSecret &&
1010610166
webhookUrl == other.webhookUrl &&
1010710167
additionalProperties == other.additionalProperties
1010810168
}
@@ -10112,6 +10172,7 @@ private constructor(
1011210172
webhookEvents,
1011310173
webhookHeaders,
1011410174
webhookOutputFormat,
10175+
webhookSigningSecret,
1011510176
webhookUrl,
1011610177
additionalProperties,
1011710178
)
@@ -10120,7 +10181,7 @@ private constructor(
1012010181
override fun hashCode(): Int = hashCode
1012110182

1012210183
override fun toString() =
10123-
"WebhookConfiguration{webhookEvents=$webhookEvents, webhookHeaders=$webhookHeaders, webhookOutputFormat=$webhookOutputFormat, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}"
10184+
"WebhookConfiguration{webhookEvents=$webhookEvents, webhookHeaders=$webhookHeaders, webhookOutputFormat=$webhookOutputFormat, webhookSigningSecret=$webhookSigningSecret, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}"
1012410185
}
1012510186

1012610187
override fun equals(other: Any?): Boolean {

‎llama-cloud-core/src/main/kotlin/com/llamacloud_prod/api/models/beta/batch/jobitems/JobItemGetProcessingResultsResponse.kt‎

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9430,6 +9430,7 @@ private constructor(
94309430
private val webhookEvents: JsonField<List<WebhookEvent>>,
94319431
private val webhookHeaders: JsonField<WebhookHeaders>,
94329432
private val webhookOutputFormat: JsonField<String>,
9433+
private val webhookSigningSecret: JsonField<String>,
94339434
private val webhookUrl: JsonField<String>,
94349435
private val additionalProperties: MutableMap<String, JsonValue>,
94359436
) {
@@ -9445,13 +9446,17 @@ private constructor(
94459446
@JsonProperty("webhook_output_format")
94469447
@ExcludeMissing
94479448
webhookOutputFormat: JsonField<String> = JsonMissing.of(),
9449+
@JsonProperty("webhook_signing_secret")
9450+
@ExcludeMissing
9451+
webhookSigningSecret: JsonField<String> = JsonMissing.of(),
94489452
@JsonProperty("webhook_url")
94499453
@ExcludeMissing
94509454
webhookUrl: JsonField<String> = JsonMissing.of(),
94519455
) : this(
94529456
webhookEvents,
94539457
webhookHeaders,
94549458
webhookOutputFormat,
9459+
webhookSigningSecret,
94559460
webhookUrl,
94569461
mutableMapOf(),
94579462
)
@@ -9487,6 +9492,19 @@ private constructor(
94879492
fun webhookOutputFormat(): Optional<String> =
94889493
webhookOutputFormat.getOptional("webhook_output_format")
94899494

9495+
/**
9496+
* Shared signing secret used to sign webhook deliveries. When set, each
9497+
* request includes an HMAC-SHA256 signature of the request body in the
9498+
* 'LC-Signature' header (value 'sha256=<hex>'). Recompute the HMAC over the
9499+
* raw request body with this secret to verify the delivery is authentic.
9500+
*
9501+
* @throws LlamaCloudInvalidDataException if the JSON field has an
9502+
* unexpected type (e.g. if the server responded with an unexpected
9503+
* value).
9504+
*/
9505+
fun webhookSigningSecret(): Optional<String> =
9506+
webhookSigningSecret.getOptional("webhook_signing_secret")
9507+
94909508
/**
94919509
* URL to receive webhook POST notifications
94929510
*
@@ -9526,6 +9544,16 @@ private constructor(
95269544
@ExcludeMissing
95279545
fun _webhookOutputFormat(): JsonField<String> = webhookOutputFormat
95289546

9547+
/**
9548+
* Returns the raw JSON value of [webhookSigningSecret].
9549+
*
9550+
* Unlike [webhookSigningSecret], this method doesn't throw if the JSON
9551+
* field has an unexpected type.
9552+
*/
9553+
@JsonProperty("webhook_signing_secret")
9554+
@ExcludeMissing
9555+
fun _webhookSigningSecret(): JsonField<String> = webhookSigningSecret
9556+
95299557
/**
95309558
* Returns the raw JSON value of [webhookUrl].
95319559
*
@@ -9563,6 +9591,7 @@ private constructor(
95639591
private var webhookEvents: JsonField<MutableList<WebhookEvent>>? = null
95649592
private var webhookHeaders: JsonField<WebhookHeaders> = JsonMissing.of()
95659593
private var webhookOutputFormat: JsonField<String> = JsonMissing.of()
9594+
private var webhookSigningSecret: JsonField<String> = JsonMissing.of()
95669595
private var webhookUrl: JsonField<String> = JsonMissing.of()
95679596
private var additionalProperties: MutableMap<String, JsonValue> =
95689597
mutableMapOf()
@@ -9573,6 +9602,7 @@ private constructor(
95739602
webhookConfiguration.webhookEvents.map { it.toMutableList() }
95749603
webhookHeaders = webhookConfiguration.webhookHeaders
95759604
webhookOutputFormat = webhookConfiguration.webhookOutputFormat
9605+
webhookSigningSecret = webhookConfiguration.webhookSigningSecret
95769606
webhookUrl = webhookConfiguration.webhookUrl
95779607
additionalProperties =
95789608
webhookConfiguration.additionalProperties.toMutableMap()
@@ -9664,6 +9694,35 @@ private constructor(
96649694
this.webhookOutputFormat = webhookOutputFormat
96659695
}
96669696

9697+
/**
9698+
* Shared signing secret used to sign webhook deliveries. When set, each
9699+
* request includes an HMAC-SHA256 signature of the request body in the
9700+
* 'LC-Signature' header (value 'sha256=<hex>'). Recompute the HMAC over
9701+
* the raw request body with this secret to verify the delivery is
9702+
* authentic.
9703+
*/
9704+
fun webhookSigningSecret(webhookSigningSecret: String?) =
9705+
webhookSigningSecret(JsonField.ofNullable(webhookSigningSecret))
9706+
9707+
/**
9708+
* Alias for calling [Builder.webhookSigningSecret] with
9709+
* `webhookSigningSecret.orElse(null)`.
9710+
*/
9711+
fun webhookSigningSecret(webhookSigningSecret: Optional<String>) =
9712+
webhookSigningSecret(webhookSigningSecret.getOrNull())
9713+
9714+
/**
9715+
* Sets [Builder.webhookSigningSecret] to an arbitrary JSON value.
9716+
*
9717+
* You should usually call [Builder.webhookSigningSecret] with a
9718+
* well-typed [String] value instead. This method is primarily for
9719+
* setting the field to an undocumented or not yet supported value.
9720+
*/
9721+
fun webhookSigningSecret(webhookSigningSecret: JsonField<String>) =
9722+
apply {
9723+
this.webhookSigningSecret = webhookSigningSecret
9724+
}
9725+
96679726
/** URL to receive webhook POST notifications */
96689727
fun webhookUrl(webhookUrl: String?) =
96699728
webhookUrl(JsonField.ofNullable(webhookUrl))
@@ -9719,6 +9778,7 @@ private constructor(
97199778
(webhookEvents ?: JsonMissing.of()).map { it.toImmutable() },
97209779
webhookHeaders,
97219780
webhookOutputFormat,
9781+
webhookSigningSecret,
97229782
webhookUrl,
97239783
additionalProperties.toMutableMap(),
97249784
)
@@ -9744,6 +9804,7 @@ private constructor(
97449804
webhookEvents().ifPresent { it.forEach { it.validate() } }
97459805
webhookHeaders().ifPresent { it.validate() }
97469806
webhookOutputFormat()
9807+
webhookSigningSecret()
97479808
webhookUrl()
97489809
validated = true
97499810
}
@@ -9768,6 +9829,7 @@ private constructor(
97689829
?: 0) +
97699830
(webhookHeaders.asKnown().getOrNull()?.validity() ?: 0) +
97709831
(if (webhookOutputFormat.asKnown().isPresent) 1 else 0) +
9832+
(if (webhookSigningSecret.asKnown().isPresent) 1 else 0) +
97719833
(if (webhookUrl.asKnown().isPresent) 1 else 0)
97729834

97739835
class WebhookEvent
@@ -10213,6 +10275,7 @@ private constructor(
1021310275
webhookEvents == other.webhookEvents &&
1021410276
webhookHeaders == other.webhookHeaders &&
1021510277
webhookOutputFormat == other.webhookOutputFormat &&
10278+
webhookSigningSecret == other.webhookSigningSecret &&
1021610279
webhookUrl == other.webhookUrl &&
1021710280
additionalProperties == other.additionalProperties
1021810281
}
@@ -10222,6 +10285,7 @@ private constructor(
1022210285
webhookEvents,
1022310286
webhookHeaders,
1022410287
webhookOutputFormat,
10288+
webhookSigningSecret,
1022510289
webhookUrl,
1022610290
additionalProperties,
1022710291
)
@@ -10230,7 +10294,7 @@ private constructor(
1023010294
override fun hashCode(): Int = hashCode
1023110295

1023210296
override fun toString() =
10233-
"WebhookConfiguration{webhookEvents=$webhookEvents, webhookHeaders=$webhookHeaders, webhookOutputFormat=$webhookOutputFormat, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}"
10297+
"WebhookConfiguration{webhookEvents=$webhookEvents, webhookHeaders=$webhookHeaders, webhookOutputFormat=$webhookOutputFormat, webhookSigningSecret=$webhookSigningSecret, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}"
1023410298
}
1023510299

1023610300
override fun equals(other: Any?): Boolean {

0 commit comments

Comments
 (0)