user.tsx 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 type User = Omit<AvatarUser, 'options'> & {
  34. authenticators: UserEnrolledAuthenticator[];
  35. canReset2fa: boolean;
  36. dateJoined: string;
  37. emails: {
  38. email: string;
  39. id: string;
  40. is_verified: boolean;
  41. }[];
  42. experiments: Partial<UserExperiments>;
  43. flags: {newsletter_consent_prompt: boolean};
  44. has2fa: boolean;
  45. hasPasswordAuth: boolean;
  46. identities: any[];
  47. isActive: boolean;
  48. isAuthenticated: boolean;
  49. isManaged: boolean;
  50. isStaff: boolean;
  51. isSuperuser: boolean;
  52. lastActive: string;
  53. lastLogin: string;
  54. options: {
  55. avatarType: Avatar['avatarType'];
  56. clock24Hours: boolean;
  57. language: string;
  58. stacktraceOrder: number;
  59. theme: 'system' | 'light' | 'dark';
  60. timezone: string;
  61. };
  62. permissions: Set<string>;
  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. // Used in user session history.
  100. export type InternetProtocol = {
  101. countryCode: string | null;
  102. firstSeen: string;
  103. id: string;
  104. ipAddress: string;
  105. lastSeen: string;
  106. regionCode: string | null;
  107. };
  108. export type SubscriptionDetails = {disabled?: boolean; reason?: string};