user.tsx 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. language: string;
  48. stacktraceOrder: number;
  49. theme: 'system' | 'light' | 'dark';
  50. timezone: string;
  51. };
  52. permissions: Set<string>;
  53. authenticators?: UserEnrolledAuthenticator[];
  54. }
  55. // XXX(epurkhiser): we should understand how this is diff from User['emails]
  56. // above
  57. export type UserEmail = {
  58. email: string;
  59. isPrimary: boolean;
  60. isVerified: boolean;
  61. };
  62. /**
  63. * API tokens and Api Applications.
  64. */
  65. // See src/sentry/api/serializers/models/apitoken.py for the differences based on application
  66. interface BaseApiToken {
  67. dateCreated: string;
  68. expiresAt: string;
  69. id: string;
  70. scopes: Scope[];
  71. state: string;
  72. }
  73. // We include the token for API tokens used for internal apps
  74. export interface InternalAppApiToken extends BaseApiToken {
  75. application: null;
  76. refreshToken: string;
  77. token: string;
  78. tokenLastCharacters?: string;
  79. }
  80. export type ApiApplication = {
  81. allowedOrigins: string[];
  82. clientID: string;
  83. clientSecret: string | null;
  84. homepageUrl: string | null;
  85. id: string;
  86. name: string;
  87. privacyUrl: string | null;
  88. redirectUris: string[];
  89. termsUrl: string | null;
  90. };
  91. export type OrgAuthToken = {
  92. dateCreated: Date;
  93. id: string;
  94. name: string;
  95. scopes: string[];
  96. dateLastUsed?: Date;
  97. projectLastUsedId?: string;
  98. tokenLastCharacters?: string;
  99. };
  100. // Used in user session history.
  101. export type InternetProtocol = {
  102. countryCode: string | null;
  103. firstSeen: string;
  104. id: string;
  105. ipAddress: string;
  106. lastSeen: string;
  107. regionCode: string | null;
  108. };
  109. export type SubscriptionDetails = {disabled?: boolean; reason?: string};