import BaseAPI from "./BaseAPI" ; import Client from "../Client" ; export type GetAuthTicket = { authTicket : string ; } ; export type GetAuthMetaData = { cookieLawNoticeTimeout : number ; } ; export type LoginOptions = { ctype : "Email" | "Username" | string ; cvalue : string ; password : string ; captchaToken : string ; captchaProvider : "PROVIDER_ARKOSELABS" | string ; } ; export type Login = { user : { id : number ; name : string ; displayName : string ; } ; twoStepVerificationData ? : { mediaType : "Email" | string ; ticket : string ; } ; } ; export type Logout = unknown ; export type GetCredentialsVerificationStatusOptions = { credentialType : "Email" | "Username" | "PhoneNumber" ; credentialValue : string ; password : string ; } ; export type GetCredentialsVerificationStatus = { canSend : boolean ; } ; export type SendCredentialsVerificationMessageOptions = { credentialType : "Email" | "Username" | "PhoneNumber" ; credentialValue : string ; password : string ; } ; export type SendCredentialsVerificationMessage = unknown ; export type GetMetaData = { isUpdateUsernameEnabled : boolean ; ftuxAvatarAssetMap : string ; } ; export type GetCurrentPasswordStatus = { valid : boolean ; } ; export type GetPasswordResetMetaDataOptions = { targetType : "Email" | "PhoneNumber" ; ticket : string ; } ; export type GetPasswordResetMetaData = { users : { userId : number ; username : string ; displayName : string ; } [ ] ; } ; export type ResetPasswordOptions = { targetType : "Email" | "PhoneNumber" ; ticket : string ; userId : number ; password : string ; passwordRepeated : string ; } ; export type ResetPassword = Login ; export type ValidatePasswordOptions = { username : string ; password : string ; } ; export type ValidatePassword = { code : string ; message : string ; } ; export type SendPasswordResetOptions = { targetType : ResetPasswordOptions [ "targetType" ] ; target : string ; captchaToken : string ; captchaProvider : "PROVIDER_ARKOSELABS" | string ; } ; export type SendPasswordReset = { nonce : string ; transmissionType : string ; } ; export type VerifyPasswordResetOptions = { targetType : ResetPasswordOptions [ "targetType" ] ; nonce : string ; code : string ; } ; export type VerifyPasswordReset = { userTickets : { user : { userId : number ; username : string ; displayName : string ; } ; ticket : string ; } [ ] ; } ; export type ChangeUserPasswordOptions = { currentPassword : string ; newPassword : string ; } ; export type ChangeUserPassword = unknown ; export type GetRecoveryMetaData = { isOnPhone : boolean ; codeLength : number ; isPhoneFeatureEnabledForUsername : boolean ; isPhoneFeatureEnabledForPassword : boolean ; isBedev2CaptchaEnabledForPasswordReset : boolean ; } ; export type RevertAccountInfoOptions = { ticket : string ; } ; export type RevertAccountInfo = { isTwoStepVerificationEnabled : boolean ; isEmailVerified : boolean ; isEmailChanged : boolean ; userId : number ; username : string ; ticket : string ; } ; export type RevertAccountOptions = { userId : number ; newPassword : string ; ticket : string ; } ; export type RevertAccount = Login ; export type GetSAMLMetaData = unknown ; export type SAMLRequest = unknown ; export type GetTwoStepVerificationMetaData = { codeLength : number ; loadingImageUrl : string ; supportUrl : string ; } ; export type ResendTwoStepVerificationOptions = { username : string ; ticket : string ; actionType : string ; } ; export type ResendTwoStepVerification = RequestTwoStepVerification ; export type RequestTwoStepVerification = { mediaType : "Email" | "PhoneNumber" | string ; ticket : string ; } ; export type VerifyTwoStepVerificationOptions = { username : string ; ticket : string ; code : string ; rememberDevice : boolean ; actionType : string ; } ; export type VerifyTwoStepVerification = unknown ; export type GetExistingUsernamesOptions = { username : string ; } ; export type GetExistingUsernames = { usernames : string [ ] ; } ; export type ValidateUsernameOptions = { username : string ; birthday : string ; context : "Unknown" | "Signup" | "UsernameChange" | string ; } ; export type ValidateUsername = { code : string ; message : string ; } ; export type RecoverUsernamesOptions = { targetType : "Email" | string ; target : string ; } ; export type RecoverUsernames = { transmissionType : string ; } ; export type SignUpOptions = { username : string ; password : string ; gender : "Unknown" | string ; birthday : string ; isTosAgreementBoxChecked : boolean ; email : string ; locale : string ; assetIds : number [ ] ; bodyColorId : number ; bodyTypeScale : number ; headScale : number ; heightScale : number ; widthScale : number ; proportionScale : number ; captchaToken : string ; captchaProvider : string ; } ; export type SignUp = { userId : number ; starterPlaceId : number ; } ; export type ChangeUsernameOptions = { username : string ; password : string ; } ; export type ChangeUsername = unknown ; export default class AuthAPI extends BaseAPI { constructor ( client ) { super ( { client , baseUrl : "https://auth.roblox.com/" } ) ; } getAuthTicket ( ) { return this . request ( { json : true , requiresAuth : true , request : { path : "v1/authentication-ticket" , method : "POST" , headers : { referer : "https://www.roblox.com/" , origin : "roblox.com" } } } ) . then ( response => ( { authTicket : response . headers [ "rbx-authentication-ticket" ] } ) ) ; } getAuthMetaData ( ) { return this . request ( { json : true , requiresAuth : false , request : { path : "v2/auth/metadata" } } ) . then ( response => response . body as GetAuthMetaData ) ; } login ( options ) { return this . request ( { json : true , requiresAuth : false , request : { path : "v2/login" , method : "POST" , json : options } } ) . then ( response => response . body as Login ) ; } logout ( ) { return this . request ( { json : true , requiresAuth : false , request : { path : "v2/logout" , method : "POST" } } ) . then ( response => response . body as Logout ) ; } getCredentialsVerificationStatus ( options ) { return this . request ( { json : true , requiresAuth : false , request : { path : "v2/credentials/verification" , qs : { "request.credentialType" : options . credentialType , "request.credentialValue" : options . credentialValue , "request.password" : options . password } } } ) . then ( response => response . body as GetCredentialsVerificationStatus ) ; } sendCredentialsVerificationMessage ( options ) { return this . request ( { json : true , requiresAuth : false , request : { path : "v2/credentials/verification/send" , method : "POST" , json : options } } ) . then ( response => response . body as SendCredentialsVerificationMessage ) ; } getMetaData ( ) { return this . request ( { json : true , requiresAuth : false , request : { path : "v2/metadata" } } ) . then ( response => response . body as GetMetaData ) ; } getCurrentUserPasswordStatus ( ) { return this . request ( { json : true , requiresAuth : true , request : { path : "v2/passwords/current-status" } } ) . then ( response => response . body as GetCurrentPasswordStatus ) ; } getPasswordResetMetaData ( options ) { return this . request ( { json : true , requiresAuth : false , request : { path : "v2/passwords/reset" , qs : { "request.targetType" : options . targetType , "request.ticket" : options . ticket } } } ) . then ( response => response . body as GetPasswordResetMetaData ) ; } resetPassword ( options ) { return this . request ( { json : true , requiresAuth : false , request : { path : "v2/auth/metadata" , method : "POST" , json : options } } ) . then ( response => response . body as ResetPassword ) ; } validatePassword ( options ) { return this . request ( { json : true , requiresAuth : false , request : { path : "v2/passwords/validate" , qs : { "request.username" : options . username , "request.password" : options . password } } } ) . then ( response => response . body as ValidatePassword ) ; } sendPasswordReset ( options ) { return this . request ( { json : true , requiresAuth : false , request : { path : "v2/passwords/reset/send" , method : "POST" , json : options } } ) . then ( response => response . body as SendPasswordReset ) ; } verifyPasswordReset ( options ) { return this . request ( { json : true , requiresAuth : false , request : { path : "v2/passwords/reset/verify" , method : "POST" , json : options } } ) . then ( response => response . body as VerifyPasswordReset ) ; } changeUserPassword ( options ) { return this . request ( { json : true , requiresAuth : true , request : { path : "v2/user/passwords/change" , method : "POST" , json : options } } ) . then ( response => response . body as ChangeUserPassword ) ; } getRecoveryMetaData ( ) { return this . request ( { json : true , requiresAuth : false , request : { path : "v2/recovery/metadata" } } ) . then ( response => response . body as GetRecoveryMetaData ) ; } getRevertAccountInfo ( options ) { return this . request ( { json : true , requiresAuth : false , request : { path : "v2/revert/account" , qs : { ticket : options . ticket } } } ) . then ( response => response . body as RevertAccountInfo ) ; } revertAccount ( options ) { return this . request ( { json : true , requiresAuth : false , request : { path : "v2/revert/account" , method : "POST" , json : options } } ) . then ( response => response . body as RevertAccount ) ; } getSAMLMetaData ( ) { return this . request ( { json : true , requiresAuth : false , request : { path : "v2/saml/metadata" } } ) . then ( response => response . body as GetSAMLMetaData ) ; } samlAuthenticate ( ) { return this . request ( { json : true , requiresAuth : false , request : { path : "v2/saml/login" , method : "POST" } } ) . then ( response => response . body as SAMLRequest ) ; } getTwoStepVerificationMetaData ( ) { return this . request ( { json : true , requiresAuth : false , request : { path : "v2/twostepverification/metadata" } } ) . then ( response => response . body as GetTwoStepVerificationMetaData ) ; } resendTwoStepVerificationCode ( options ) { return this . request ( { json : true , requiresAuth : false , request : { path : "v2/twostepverification/resend" , method : "POST" , json : options } } ) . then ( response => response . body as ResendTwoStepVerification ) ; } verifyTwoStepCode ( options ) { return this . request ( { json : true , requiresAuth : false , request : { path : "v2/twostepverification/verify" , method : "POST" , json : options } } ) . then ( response => response . body as VerifyTwoStepVerification ) ; } getExistingUsernames ( options ) { return this . request ( { json : true , requiresAuth : false , request : { path : "v2/usernames" , qs : { username : options . username } } } ) . then ( response => response . body as GetExistingUsernames ) ; } validateUsername ( options ) { return this . request ( { json : true , requiresAuth : false , request : { path : "v2/usernames/validate" , qs : { "request.username" : options . username , "request.birthday" : options . birthday , "request.context" : options . context } } } ) . then ( response => response . body as ValidateUsername ) ; } recoverUsernames ( options ) { return this . request ( { json : true , requiresAuth : false , request : { path : "v2/twostepverification/metadata" , json : options } } ) . then ( response => response . body as RecoverUsernames ) ; } signUp ( options ) { return this . request ( { json : true , requiresAuth : false , request : { path : "v2/twostepverification/metadata" , method : "POST" , json : options } } ) . then ( response => response . body as SignUp ) ; } changeUserUsername ( options ) { return this . request ( { json : true , requiresAuth : true , request : { path : "v2/username" , method : "POST" , json : options } } ) . then ( response => response . body as ChangeUsername ) ; } }