user.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. language: string;
  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. scopes: Scope[];
  80. state: string;
  81. }
  82. // We include the token for API tokens used for internal apps
  83. export interface InternalAppApiToken extends BaseApiToken {
  84. application: null;
  85. refreshToken: string;
  86. token: string;
  87. }
  88. export type ApiApplication = {
  89. allowedOrigins: string[];
  90. clientID: string;
  91. clientSecret: string | null;
  92. homepageUrl: string | null;
  93. id: string;
  94. name: string;
  95. privacyUrl: string | null;
  96. redirectUris: string[];
  97. termsUrl: string | null;
  98. };
  99. export type OrgAuthToken = {
  100. dateCreated: Date;
  101. id: string;
  102. name: string;
  103. scopes: string[];
  104. dateLastUsed?: Date;
  105. projectLastUsedId?: string;
  106. tokenLastCharacters?: string;
  107. };
  108. // Used in user session history.
  109. export type InternetProtocol = {
  110. countryCode: string | null;
  111. firstSeen: string;
  112. id: string;
  113. ipAddress: string;
  114. lastSeen: string;
  115. regionCode: string | null;
  116. };
  117. export type SubscriptionDetails = {disabled?: boolean; reason?: string};