import { Uuid, Base64String, TokenData, RFC3339Date, Url } from './' import { AllRoleType } from './practice' export type AuthRefreshFunc = (refreshToken?: string) => Promise export interface Tokens { accessToken?: string refreshToken?: string } export interface AuthTokenRequest { practiceUuid: string email: string password: Base64String otp?: string } export interface AuthTokenResponse { accessToken: string tokenType: string refreshToken?: string expiresIn: number } /** * This interface is used to request a M2M token as a service */ export interface M2MTokenRequest { clientId: string clientSecret: string requestedScopes: string[] practiceUuid?: string } export interface AuthRecoverRequest { practiceUuid: string email: string } export type IdentityResendConfirmEmailRequest = AuthRecoverRequest export interface WhoAmIResponse { aud: string exp: number jti: string iat: number iss: string nbf: number sub: string scope: string // Whitespace separated list of practice AllTypeRole email: string practice: string } export interface IdentityCreateRequest { practiceUuid: Uuid email: string emailConfirmed?: boolean //In any env that aren't production, you can skip the email verification. Useful to write tests for instance. password: Base64String publicKey: Base64String recoveryPassword: Base64String tosAndCpAcceptance: TosAndCpAcceptanceRequest tokenData?: TokenData subscriptionAcceptance?: SubscriptionAcceptanceRequest } export interface TosAndCpAcceptanceRequest { tosVersion: string cpVersion: string } export interface IdentityResponse { id: Uuid practiceUuid?: Uuid email?: string emailConfirmed: boolean tokenData?: TokenData mfaEnabled?: boolean mfaSecret?: Base64String publicKey: Base64String recoveryLogin?: Uuid recoveryPassword: Base64String recoveryMasterKey?: Base64String recoverySecurityQuestions?: SecretShard[] legal?: LegalData createdAt?: string updatedAt?: string refreshToken?: string } export interface IdentityUpdateRequest { emailConfirmed?: boolean password?: PasswordUpdateRequest mfaEnable?: MFAEnableRequest recoveryPassword?: Base64String recoveryMasterKey?: Base64String recoverySecurityQuestions?: SecretShard[] tokenData?: TokenData epAcceptance?: EpAcceptanceRequest rpAcceptance?: RpAcceptanceRequest subscriptionAcceptance?: SubscriptionAcceptanceRequest } export interface EpAcceptanceRequest { epVersion: string } export interface RpAcceptanceRequest { rpVersion: string } export interface SubscriptionAcceptanceRequest { email: string } export interface PasswordUpdateRequest { oldPassword?: Base64String newPassword: Base64String } export interface QRCodeRequest { password: Base64String } export interface QRCodeResponse { url: string qrContentType: string qrBytes: Base64String } export interface MFAEnableRequest { password: Base64String otp: string } export interface SecretShard { securityQuestion: string securityAnswer?: string nonce: Base64String encryptedShare: Base64String } export interface LegalData { tosAcceptedAtTime?: RFC3339Date tosAcceptedVersion: Url tosAcceptedAtIP?: string cpAcceptedAtTime?: RFC3339Date cpAcceptedVersion: Url cpAcceptedAtIP?: string epAcceptedAtTime?: RFC3339Date epAcceptedVersion: Url epAcceptedAtIP?: string rpAcceptedAtTime?: RFC3339Date rpAcceptedVersion: Url rpAcceptedAtIP?: string subscribedAtTime?: RFC3339Date subscribedAtIP?: string subscribedEmail?: string subscribedAudience?: string } export type RoleBasedScopes = AllRoleType export type PermissionBasedScopes = | 'consult.consults.get' | 'consult.consults.post' | 'consult.consults.put' | 'practice.assignments.post' | 'practice.emails.get' | 'practice.configs.get' | 'practice.practitioners.get' | 'practice.invoices.get' | 'practice.payments.get' | 'practice.secrets.get' | 'teller.emails.post' export type AllScopes = RoleBasedScopes | PermissionBasedScopes