This attaches the characteristics key of the SDK configuration into the types of protect(). We leverage some type magic to ensure users specify all data needed when they are using user-defined characteristics.
I totally forgot about this when reviewing the initial PR, but we're lucky to have caught it before the release.
I also needed to fix the tests because the way they were originally written allowed the required request fields to be excluded. @e-moran It's worth noting that rules always need to be directly specified in the rules: [] array for TypeScript's inference to work properly—which avoids the need to annotate your variables. We are able to use as const on the characteristic arrays, but that isn't allowed on function calls like rateLimit().
This attaches the
characteristics
key of the SDK configuration into the types ofprotect()
. We leverage some type magic to ensure users specify all data needed when they are using user-defined characteristics.I totally forgot about this when reviewing the initial PR, but we're lucky to have caught it before the release.
I also needed to fix the tests because the way they were originally written allowed the required request fields to be excluded. @e-moran It's worth noting that rules always need to be directly specified in the
rules: []
array for TypeScript's inference to work properly—which avoids the need to annotate your variables. We are able to useas const
on the characteristic arrays, but that isn't allowed on function calls likerateLimit()
.Closes #1042