Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 0 additions & 70 deletions lib/api/contacts.js

This file was deleted.

118 changes: 118 additions & 0 deletions lib/api/contacts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
export const queryContacts = ({
Page = 0,
PageSize = 1000,
LabelID
}: {
Page?: number;
PageSize?: number;
LabelID?: string;
} = {}) => ({
url: 'contacts',
method: 'get',
params: { Page, PageSize, LabelID }
});

export const queryContactExport = ({
Page = 0,
PageSize = 50,
LabelID
}: {
Page?: number;
PageSize?: number;
LabelID?: string;
} = {}) => ({
url: 'contacts/export',
method: 'get',
params: { Page, PageSize, LabelID }
});

export const getContact = (contactID: string) => ({
url: `contacts/${contactID}`,
method: 'get'
});

interface Card {
Type: number;
Data: string;
Signature: string | null;
}

export const addContacts = ({
Contacts,
Overwrite,
Labels,
timeout
}: {
Contacts: {
Cards: Card[];
}[];
Overwrite: 0 | 1;
Labels?: number;
timeout?: number;
}) => ({
url: 'contacts',
method: 'post',
data: { Contacts, Overwrite, Labels },
timeout
});

export const updateContact = (contactID: string, { Cards }: { Cards: Card[] }) => ({
url: `contacts/${contactID}`,
method: 'put',
data: { Cards }
});

export const labelContacts = ({ LabelID, ContactIDs }: { LabelID: string; ContactIDs: string[] }) => ({
url: 'contacts/label',
method: 'put',
data: { LabelID, ContactIDs }
});

export const unLabelContacts = ({ LabelID, ContactIDs }: { LabelID: string; ContactIDs: string[] }) => ({
url: 'contacts/unlabel',
method: 'put',
data: { LabelID, ContactIDs }
});

export const deleteContacts = (IDs: string[]) => ({
url: 'contacts/delete',
method: 'put',
data: { IDs }
});

export const clearContacts = () => ({
url: 'contacts',
method: 'delete'
});

export const queryContactEmails = ({
Page,
PageSize,
Email,
LabelID
}: {
Page?: number;
PageSize?: number;
} & ({
Email?: string;
LabelID?: never;
} | {
Email?: never;
LabelID?: string;
}) = {}) => ({
url: 'contacts/emails',
method: 'get',
params: { Page, PageSize, Email, LabelID }
});

export const labelContactEmails = ({ LabelID, ContactEmailIDs }: { LabelID: string; ContactEmailIDs: string[] }) => ({
url: 'contacts/emails/label',
method: 'put',
data: { LabelID, ContactEmailIDs }
});

export const unLabelContactEmails = ({ LabelID, ContactEmailIDs }: { LabelID: string; ContactEmailIDs: string[] }) => ({
url: 'contacts/emails/unlabel',
method: 'put',
data: { LabelID, ContactEmailIDs }
});
68 changes: 0 additions & 68 deletions lib/api/user.js

This file was deleted.

97 changes: 97 additions & 0 deletions lib/api/user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
export const getUser = () => ({
url: 'users',
method: 'get'
});

export const queryCreateUser = (data: {
Username: string;
Email: string;
Token: string;
TokenType: 'captcha' | 'email' | 'sms' | 'invite' | 'payment';
Type: 1 | 2; // 1 = mail, 2 = VPN
Auth: {
Version: number;
ModulusID: string;
Salt: string;
Verifier: string;
};
Referrer?: string;
Payload?: {
[key: string]: string;
};
Salt?: string;
}) => ({
url: 'users',
method: 'post',
data
});

export const queryUnlock = () => ({
url: 'users/unlock',
method: 'put'
});

export const deleteUser = (data: {
ClientEphemeral: string;
ClientProof: string;
SRPSession: string;
TwoFactorCode: number;
}) => ({
url: 'users/delete',
method: 'put',
data
});

export const unlockPasswordChanges = () => ({
url: 'users/password',
method: 'put'
});

export const lockSensitiveSettings = () => ({
url: 'users/lock',
method: 'put'
});

export const getHumanVerificationMethods = () => ({
url: 'users/human',
method: 'get'
});

export const queryVerificationCode = (
Type: 'email' | 'sms',
Destination: {
Address: string;
Phone?: never;
} | {
Address?: never;
Phone: string;
}
) => ({
url: 'users/code',
method: 'post',
data: { Type, Destination }
});

export const queryCheckUsernameAvailability = (Name: string) => ({
url: 'users/available',
method: 'get',
params: { Name }
});

export const queryDirectSignupStatus = (
Type: 1 | 2 // 1 = mail, 2 = VPN
) => ({
url: 'users/direct',
method: 'get',
params: { Type }
});

export const queryCheckVerificationCode = (
Token: string,
TokenType: 'email' | 'sms' | 'invite' | 'coupon' | 'payment',
Type: 1 | 2 // 1 = mail, 2 = VPN
) => ({
url: 'users/check',
method: 'put',
data: { Token, TokenType, Type }
});