Hello ory-team, when we use the SelfService*Settin...
# talk-kratos
i
Hello ory-team, when we use the SelfService*SettingsFlow* or SelfService*LoginFlow* in our app we’re getting ts errors when trying to pass in a
SubmitSelfServiceSettingsFlowWithLookupMethodBody
to
submitSelfServiceSettingsFlow
and similarly for
submitSelfServiceLoginFlow
. It looks like
SubmitSelfServiceSettingsFlowWithLookupMethodBody
is missing from the types
SubmitSelfServiceSettingsFlowBody
and
SubmitSelfServiceLoginFlowBody
. Can I do a PR for this and fix it by updating
internal/httpclient/api/openapi.yaml
?
b
I circumvented this for now by adding a custom union type that extends the existing one with the missing fields/overriding fields. I think this is also true for any custom identity traits you gonna add eventually...
i
Thanks! Would you mind sharing your solution as an example please? Were you able to override the signature on the functions to use your custom type?
b
Sure 🙂 I only did it for the custom trait
name
but it should be applicable to the other types as well...
Copy code
export type CustomSubmitSelfServiceRegistrationFlowBody =
  SubmitSelfServiceRegistrationFlowBody & {
    traits: {
      email: string
      name: string
    }
  }
This will also give you type safety on the input fields
i
Thanks! But doesn't the
submitSelfServiceSettingsFlow
still expect the
SubmitSelfServiceRegistrationFlowBody
as an argument and not the custom type? We're calling
kratos.submitSelfServiceSettingsFlow(this.flowId, undefined, {
 
csrf_token: _this_.csrfToken,
 
method: 'lookup',
 
lookup_secret_disable: true,
})
b
I guess so. 😅 You could always do a typecasting
as expectedType
or even
as unknown as expectedType
. Where do you type the values that you get from the form? (I do it in the
onSubmit = (values: myType)
i
Yes the typecasting might help us here for now. In this situation we have a button where you can disable the 2FA using recovery codes so
submitSelfServiceSettingsFlow
is called when you click that button.