okta/okta-sdk-nodejs

Support custom attributes in UserProfile type

JuanCaicedo opened this issue Β· 8 comments

Hi there! I'm looking to switch over to use your new typescript definitions (thank you! πŸ˜€) and am running into an issue.

My organization currently defines some custom attributes as part of the user profile. However, it looks to me like the UserProfile type has not way of accounting for these other attributes, which is causing my code that tries to access them to not compile.

I wanted to flag this and see if this is a known issue or if there's something I'm overlooking πŸ˜„

If this does need to be addressed, I'm not sure what would be a good strategy. Perhaps leveraging somehow generics on the User/UserProfile type to represent the custom properties?

Thank you!

Thanks for posting!

@shuowu-okta can you help with this?

@JuanCaicedo how are you retrieving the custom properties on the user profile? The getUser api does not seem to return custom properties even outside of typing constraints...

@theseyi When I call getUser it comes back with a profile including those custom properties πŸ˜…

@theseyi When I call getUser it comes back with a profile including those custom properties πŸ˜…

I see, I guess someone already updated the schΓ©ma in your Okta org to apply those custom fields to the user type... πŸ€”

We're using custom properties as well, any updates on this?

We ended building our own profile type by

type OktaUser = Awaited<ReturnType<Client['createUser']>>
type OktaUserProfile = OktaUser['profile']
interface CustomUserProfile extends OktaUserProfile {
  customProperty?: string
}

export interface CustomOktaUser extends OktaUser {
  profile: CustomUserProfile
}

I'm having a similar issue but with Group profiles. Whenever I try to access any of the custom attributes I get 'property' does not exists on type 'GroupProfile'. Any guidance from Okta would be appreciated.

@mgrubb index signature was added for extensible types in 6.6.0 - can you please check if it works for you?