user.tsx 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import type {Authenticator, EnrolledAuthenticator} from './auth';
  2. import type {Avatar, Scope} from './core';
  3. import type {UserExperiments} from './experiments';
  4. /**
  5. * Avatars are a more primitive version of User.
  6. */
  7. export type AvatarUser = {
  8. email: string;
  9. id: string;
  10. ip_address: string;
  11. name: string;
  12. username: string;
  13. avatar?: Avatar;
  14. avatarUrl?: string;
  15. // Compatibility shim with EventUser serializer
  16. ipAddress?: string;
  17. lastSeen?: string;
  18. options?: {
  19. avatarType: Avatar['avatarType'];
  20. };
  21. };
  22. /**
  23. * This is an authenticator that a user is enrolled in
  24. */
  25. type UserEnrolledAuthenticator = {
  26. dateCreated: EnrolledAuthenticator['createdAt'];
  27. dateUsed: EnrolledAuthenticator['lastUsedAt'];
  28. id: EnrolledAuthenticator['authId'];
  29. name: EnrolledAuthenticator['name'];
  30. type: Authenticator['id'];
  31. };
  32. export type User = Omit<AvatarUser, 'options'> & {
  33. authenticators: UserEnrolledAuthenticator[];
  34. canReset2fa: boolean;
  35. dateJoined: string;
  36. emails: {
  37. email: string;
  38. id: string;
  39. is_verified: boolean;
  40. }[];
  41. experiments: Partial<UserExperiments>;
  42. flags: {newsletter_consent_prompt: boolean};
  43. has2fa: boolean;
  44. hasPasswordAuth: boolean;
  45. identities: any[];
  46. isActive: boolean;
  47. isAuthenticated: boolean;
  48. isManaged: boolean;
  49. isStaff: boolean;
  50. isSuperuser: boolean;
  51. lastActive: string;
  52. lastLogin: string;
  53. options: {
  54. avatarType: Avatar['avatarType'];
  55. clock24Hours: boolean;
  56. language: string;
  57. stacktraceOrder: number;
  58. theme: 'system' | 'light' | 'dark';
  59. timezone: string;
  60. };
  61. permissions: Set<string>;
  62. };
  63. // XXX(epurkhiser): we should understand how this is diff from User['emails]
  64. // above
  65. export type UserEmail = {
  66. email: string;
  67. isPrimary: boolean;
  68. isVerified: boolean;
  69. };
  70. /**
  71. * API tokens and Api Applications.
  72. */
  73. // See src/sentry/api/serializers/models/apitoken.py for the differences based on application
  74. type BaseApiToken = {
  75. dateCreated: string;
  76. expiresAt: string;
  77. id: string;
  78. scopes: Scope[];
  79. state: string;
  80. };
  81. // We include the token for API tokens used for internal apps
  82. export type InternalAppApiToken = BaseApiToken & {
  83. application: null;
  84. refreshToken: string;
  85. token: string;
  86. };
  87. export type ApiApplication = {
  88. allowedOrigins: string[];
  89. clientID: string;
  90. clientSecret: string | null;
  91. homepageUrl: string | null;
  92. id: string;
  93. name: string;
  94. privacyUrl: string | null;
  95. redirectUris: string[];
  96. termsUrl: string | null;
  97. };
  98. // Used in user session history.
  99. export type InternetProtocol = {
  100. countryCode: string | null;
  101. firstSeen: string;
  102. id: string;
  103. ipAddress: string;
  104. lastSeen: string;
  105. regionCode: string | null;
  106. };
  107. export type SubscriptionDetails = {disabled?: boolean; reason?: string};