1 import type { ProductParam } from '../apps/product';
2 import { getProductHeaders } from '../apps/product';
3 import type { CLIENT_TYPES } from '../constants';
4 import type { FetchConfig } from '../fetch/interface';
5 import type { HumanVerificationMethodType } from '../interfaces';
7 export const getUser = () => ({
12 export const queryCreateUser = (
18 Type: CLIENT_TYPES; // 1 = mail, 2 = VPN
20 ReferralIdentifier?: string;
21 ReferralID?: string; // Invite
22 TokenPayment?: string;
24 [key: string]: string;
33 headers: getProductHeaders(product, {
34 endpoint: 'core/v4/users',
39 export const getRecoveryMethods = (Username: string): FetchConfig => ({
40 url: 'core/v4/users/reset',
45 export const queryCreateUserExternal = (
49 TokenType?: HumanVerificationMethodType;
50 Type: CLIENT_TYPES; // 1 = mail, 2 = VPN
52 TokenPayment?: string;
53 TokenPreVerifiedAddress?: string;
55 [key: string]: string;
61 url: 'core/v4/users/external',
64 headers: getProductHeaders(product, {
65 endpoint: 'core/v4/users/external',
70 export const queryUnlock = (): FetchConfig => ({
71 url: 'core/v4/users/unlock',
75 export const canDelete = (): FetchConfig => ({
76 url: 'core/v4/users/delete',
80 export const deleteUser = (data: { Reason?: string; Feedback?: string; Email?: string }): FetchConfig => ({
81 url: 'core/v4/users/delete',
86 export const unlockPasswordChanges = (): FetchConfig => ({
87 url: 'core/v4/users/password',
91 export const lockSensitiveSettings = (): FetchConfig => ({
92 url: 'core/v4/users/lock',
96 export const getHumanVerificationMethods = (): FetchConfig => ({
97 url: 'core/v4/users/human',
101 export const queryVerificationCode = (
102 Type: 'email' | 'sms',
113 url: 'core/v4/users/code',
115 data: { Type, Destination },
118 export const queryCheckUsernameAvailability = (Name: string, ParseDomain?: boolean) => ({
119 url: 'core/v4/users/available',
121 params: { Name, ParseDomain: ParseDomain ? 1 : 0 },
124 export const queryCheckEmailAvailability = (Name: string) => ({
125 url: 'core/v4/users/availableExternal',
130 export const queryDirectSignupStatus = (
131 Type: CLIENT_TYPES // 1 = mail, 2 = VPN
133 url: 'core/v4/users/direct',
138 export const queryCheckVerificationCode = (
140 TokenType: 'email' | 'sms' | 'invite' | 'coupon' | 'payment',
141 Type: CLIENT_TYPES // 1 = mail, 2 = VPN
143 url: 'core/v4/users/check',
145 data: { Token, TokenType, Type },
148 export const getInvitations = (): FetchConfig => ({
149 url: 'core/v4/users/invitations',
153 export const acceptInvitation = (invitationID: string): FetchConfig => ({
154 url: `core/v4/users/invitations/${invitationID}/accept`,
158 export const rejectInvitation = (invitationID: string): FetchConfig => ({
159 url: `core/v4/users/invitations/${invitationID}/reject`,
163 export const disableUser = (data: { JWT: string }): FetchConfig => ({
164 url: `core/v4/users/disable/${data.JWT}`,