user.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. prefersIssueDetailsStreamlinedUI: boolean;
  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. name: string;
  72. scopes: Scope[];
  73. state: string;
  74. }
  75. // API Tokens should not be using and storing the token values in the application, as the tokens are secrets.
  76. export interface InternalAppApiToken extends BaseApiToken {
  77. application: null;
  78. refreshToken: string;
  79. tokenLastCharacters: string;
  80. }
  81. // We include the token for new API tokens
  82. export interface NewInternalAppApiToken extends InternalAppApiToken {
  83. token: string;
  84. }
  85. export type ApiApplication = {
  86. allowedOrigins: string[];
  87. clientID: string;
  88. clientSecret: string | null;
  89. homepageUrl: string | null;
  90. id: string;
  91. name: string;
  92. privacyUrl: string | null;
  93. redirectUris: string[];
  94. termsUrl: string | null;
  95. };
  96. export type OrgAuthToken = {
  97. dateCreated: Date;
  98. id: string;
  99. name: string;
  100. scopes: string[];
  101. dateLastUsed?: Date;
  102. projectLastUsedId?: string;
  103. tokenLastCharacters?: string;
  104. };
  105. // Used in user session history.
  106. export type InternetProtocol = {
  107. countryCode: string | null;
  108. firstSeen: string;
  109. id: string;
  110. ipAddress: string;
  111. lastSeen: string;
  112. regionCode: string | null;
  113. };
  114. export type SubscriptionDetails = {disabled?: boolean; reason?: string};