user.tsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. ip?: string;
  16. // Compatibility shim with EventUser serializer
  17. ipAddress?: string;
  18. lastSeen?: string;
  19. options?: {
  20. avatarType: Avatar['avatarType'];
  21. };
  22. };
  23. /**
  24. * This is an authenticator that a user is enrolled in
  25. */
  26. type UserEnrolledAuthenticator = {
  27. dateCreated: EnrolledAuthenticator['createdAt'];
  28. dateUsed: EnrolledAuthenticator['lastUsedAt'];
  29. id: EnrolledAuthenticator['authId'];
  30. name: EnrolledAuthenticator['name'];
  31. type: Authenticator['id'];
  32. };
  33. export interface User extends Omit<AvatarUser, 'options'> {
  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. defaultIssueEvent: 'recommended' | 'latest' | 'oldest';
  57. language: string;
  58. stacktraceOrder: number;
  59. theme: 'system' | 'light' | 'dark';
  60. timezone: string;
  61. };
  62. permissions: Set<string>;
  63. authenticators?: UserEnrolledAuthenticator[];
  64. }
  65. // XXX(epurkhiser): we should understand how this is diff from User['emails]
  66. // above
  67. export type UserEmail = {
  68. email: string;
  69. isPrimary: boolean;
  70. isVerified: boolean;
  71. };
  72. /**
  73. * API tokens and Api Applications.
  74. */
  75. // See src/sentry/api/serializers/models/apitoken.py for the differences based on application
  76. interface BaseApiToken {
  77. dateCreated: string;
  78. expiresAt: string;
  79. id: string;
  80. scopes: Scope[];
  81. state: string;
  82. }
  83. // We include the token for API tokens used for internal apps
  84. export interface InternalAppApiToken extends BaseApiToken {
  85. application: null;
  86. refreshToken: string;
  87. token: string;
  88. }
  89. export type ApiApplication = {
  90. allowedOrigins: string[];
  91. clientID: string;
  92. clientSecret: string | null;
  93. homepageUrl: string | null;
  94. id: string;
  95. name: string;
  96. privacyUrl: string | null;
  97. redirectUris: string[];
  98. termsUrl: string | null;
  99. };
  100. export type OrgAuthToken = {
  101. dateCreated: Date;
  102. id: string;
  103. name: string;
  104. scopes: string[];
  105. dateLastUsed?: Date;
  106. projectLastUsedId?: string;
  107. tokenLastCharacters?: string;
  108. };
  109. // Used in user session history.
  110. export type InternetProtocol = {
  111. countryCode: string | null;
  112. firstSeen: string;
  113. id: string;
  114. ipAddress: string;
  115. lastSeen: string;
  116. regionCode: string | null;
  117. };
  118. export type SubscriptionDetails = {disabled?: boolean; reason?: string};