user.tsx 2.9 KB

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