user.tsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. import type {UserEnrolledAuthenticator} 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. ip?: string;
  16. // Compatibility shim with EventUser serializer
  17. ipAddress?: string;
  18. lastSeen?: string;
  19. options?: {
  20. avatarType: Avatar['avatarType'];
  21. };
  22. };
  23. // This object tracks the status of the quick start display for each organization.
  24. // The key is the organization ID, and the value represents the display status:
  25. // Null = Hidden on the first visit
  26. // 1 = Shown once (on the second visit)
  27. // 2 = Hidden automatically after the second visit
  28. type QuickStartDisplay = Record<string, number>;
  29. export interface User extends Omit<AvatarUser, 'options'> {
  30. canReset2fa: boolean;
  31. dateJoined: string;
  32. emails: Array<{
  33. email: string;
  34. id: string;
  35. is_verified: boolean;
  36. }>;
  37. experiments: Partial<UserExperiments>;
  38. flags: {newsletter_consent_prompt: boolean};
  39. has2fa: boolean;
  40. hasPasswordAuth: boolean;
  41. identities: any[];
  42. isActive: boolean;
  43. isAuthenticated: boolean;
  44. isManaged: boolean;
  45. isStaff: boolean;
  46. isSuperuser: boolean;
  47. lastActive: string;
  48. lastLogin: string;
  49. options: {
  50. avatarType: Avatar['avatarType'];
  51. clock24Hours: boolean;
  52. defaultIssueEvent: 'recommended' | 'latest' | 'oldest';
  53. language: string;
  54. prefersIssueDetailsStreamlinedUI: boolean;
  55. prefersStackedNavigation: boolean;
  56. quickStartDisplay: QuickStartDisplay;
  57. stacktraceOrder: number;
  58. theme: 'system' | 'light' | 'dark';
  59. timezone: string;
  60. };
  61. permissions: Set<string>;
  62. authenticators?: UserEnrolledAuthenticator[];
  63. }
  64. // XXX(epurkhiser): we should understand how this is diff from User['emails]
  65. // above
  66. export type UserEmail = {
  67. email: string;
  68. isPrimary: boolean;
  69. isVerified: boolean;
  70. };
  71. /**
  72. * API tokens and Api Applications.
  73. */
  74. // See src/sentry/api/serializers/models/apitoken.py for the differences based on application
  75. interface BaseApiToken {
  76. dateCreated: string;
  77. expiresAt: string;
  78. id: string;
  79. name: string;
  80. scopes: Scope[];
  81. state: string;
  82. }
  83. // API Tokens should not be using and storing the token values in the application, as the tokens are secrets.
  84. export interface InternalAppApiToken extends BaseApiToken {
  85. application: null;
  86. refreshToken: string;
  87. tokenLastCharacters: string;
  88. }
  89. // We include the token for new API tokens
  90. export interface NewInternalAppApiToken extends InternalAppApiToken {
  91. token: string;
  92. }
  93. export type ApiApplication = {
  94. allowedOrigins: string[];
  95. clientID: string;
  96. clientSecret: string | null;
  97. homepageUrl: string | null;
  98. id: string;
  99. name: string;
  100. privacyUrl: string | null;
  101. redirectUris: string[];
  102. termsUrl: string | null;
  103. };
  104. export type OrgAuthToken = {
  105. dateCreated: Date;
  106. id: string;
  107. name: string;
  108. scopes: string[];
  109. dateLastUsed?: Date;
  110. projectLastUsedId?: string;
  111. tokenLastCharacters?: string;
  112. };
  113. // Used in user session history.
  114. export type InternetProtocol = {
  115. countryCode: string | null;
  116. firstSeen: string;
  117. id: string;
  118. ipAddress: string;
  119. lastSeen: string;
  120. regionCode: string | null;
  121. };
  122. export type SubscriptionDetails = {disabled?: boolean; reason?: string};