2020-06-19 06:57:57 +03:00
import "isomorphic-fetch" ;
2021-07-07 23:50:57 +03:00
import microlink from "@microlink/mql" ;
2020-02-19 09:30:47 +03:00
2021-07-13 07:27:23 +03:00
import * as Logging from "~/common/logging" ;
2021-07-07 23:50:57 +03:00
import * as Events from "~/common/custom-events" ;
2021-01-11 06:57:40 +03:00
import * as Websockets from "~/common/browser-websockets" ;
2020-06-19 06:57:57 +03:00
import * as Strings from "~/common/strings" ;
2021-07-07 23:50:57 +03:00
import * as Credentials from "~/common/credentials" ;
2020-02-19 09:30:47 +03:00
2021-01-14 09:30:26 +03:00
//NOTE(martina): call Websockets.checkWebsocket() before any api call that uses websockets to return updates
// to make sure that websockets are properly connected (and to reconnect them if they are not)
// otherwise updates may not occur properly
2021-07-07 23:50:57 +03:00
//NOTE(martina): if the server is the slate backend, you should set credentials: "include". If it is cross origin (aka a call to shovel or lens), you will not be able to use credentials
// Instead, if a cross origin server requires authorization, pass an API key with Authorization: getCookie(Credentials.session.key)
const getCookie = ( name ) => {
var match = document . cookie . match ( new RegExp ( "(^| )" + name + "=([^;]+)" ) ) ;
if ( match ) return match [ 2 ] ;
} ;
2020-02-19 09:30:47 +03:00
const REQUEST _HEADERS = {
2020-06-19 06:57:57 +03:00
Accept : "application/json" ,
"Content-Type" : "application/json" ,
2020-02-19 09:30:47 +03:00
} ;
2021-07-07 23:50:57 +03:00
//NOTE(martina): used for calls to the server
2020-08-07 05:17:49 +03:00
const DEFAULT _OPTIONS = {
method : "POST" ,
headers : REQUEST _HEADERS ,
credentials : "include" ,
} ;
2021-07-07 23:50:57 +03:00
//NOTE(martina): used for calls to other servers (where sending credentials isn't allowed b/c it's cross origin) which also don't require API keys
2020-10-31 02:12:20 +03:00
const CORS _OPTIONS = {
method : "POST" ,
headers : REQUEST _HEADERS ,
credentials : "omit" ,
} ;
2020-08-07 05:17:49 +03:00
const returnJSON = async ( route , options ) => {
2021-07-07 23:50:57 +03:00
try {
const response = await fetch ( route , options ) ;
const json = await response . json ( ) ;
2020-08-07 05:17:49 +03:00
2021-07-07 23:50:57 +03:00
return json ;
} catch ( e ) {
2021-07-13 07:27:23 +03:00
Logging . error ( e ) ;
2021-07-07 23:50:57 +03:00
}
2020-08-07 05:17:49 +03:00
} ;
2021-03-05 10:32:08 +03:00
export const createZipToken = async ( { files , resourceURI } ) => {
return await returnJSON ( ` ${ resourceURI } /api/download/create-zip-token ` , {
2021-03-05 11:56:42 +03:00
... CORS _OPTIONS ,
2021-03-02 16:33:10 +03:00
body : JSON . stringify ( { files } ) ,
} ) ;
2021-03-05 10:32:08 +03:00
} ;
2021-03-02 16:33:10 +03:00
2021-03-05 10:32:08 +03:00
export const downloadZip = ( { token , name , resourceURI } ) =>
` ${ resourceURI } /api/download/download-by-token?downloadId= ${ token } &name= ${ name } ` ;
2021-03-02 16:33:10 +03:00
2020-08-19 21:17:12 +03:00
export const health = async ( data = { } ) => {
2021-01-11 06:57:40 +03:00
await Websockets . checkWebsocket ( ) ;
2020-08-12 11:22:28 +03:00
return await returnJSON ( ` /api/_ ` , {
... DEFAULT _OPTIONS ,
2020-08-19 21:17:12 +03:00
body : JSON . stringify ( { data : { buckets : data . buckets } } ) ,
2020-08-12 11:22:28 +03:00
} ) ;
} ;
2020-07-22 09:04:54 +03:00
export const sendFilecoin = async ( data ) => {
2020-04-09 00:29:13 +03:00
if ( Strings . isEmpty ( data . source ) ) {
return null ;
}
if ( Strings . isEmpty ( data . target ) ) {
return null ;
2020-02-19 09:30:47 +03:00
}
2020-04-09 00:29:13 +03:00
if ( ! data . amount ) {
return null ;
2020-02-19 09:30:47 +03:00
}
2021-01-11 06:57:40 +03:00
await Websockets . checkWebsocket ( ) ;
2020-08-07 05:17:49 +03:00
return await returnJSON ( ` /api/addresses/send ` , {
... DEFAULT _OPTIONS ,
2020-08-27 07:24:49 +03:00
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
2021-07-07 23:50:57 +03:00
// export const mql = async (url) => {
// try {
// const res = await microlink(url, { screenshot: true });
// return res;
// } catch (e) {
// console.log(e);
// if (e.description) {
// Events.dispatchMessage({ message: e.description });
// }
// }
// };
2020-09-02 11:33:39 +03:00
export const checkUsername = async ( data ) => {
2021-03-07 23:53:54 +03:00
return await returnJSON ( ` /api/users/check-username ` , {
2020-09-02 11:33:39 +03:00
... DEFAULT _OPTIONS ,
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
2021-06-09 01:53:30 +03:00
export const checkEmail = async ( data ) => {
return await returnJSON ( ` /api/users/check-email ` , {
... DEFAULT _OPTIONS ,
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
//NOTE(toast): this functionality comes with the upgraded sg plan
// export const validateEmail = async (data) => {
// return await returnJSON("/api/emails/validate", {
// ...DEFAULT_OPTIONS,
// body: JSON.stringify({ data }),
// });
// };
export const sendEmail = async ( data ) => {
return await returnJSON ( "/api/emails/send-email" , {
... DEFAULT _OPTIONS ,
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
export const sendTemplateEmail = async ( data ) => {
return await returnJSON ( "/api/emails/send-template" , {
... DEFAULT _OPTIONS ,
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
2020-09-23 14:17:56 +03:00
export const archive = async ( data ) => {
2021-01-11 06:57:40 +03:00
await Websockets . checkWebsocket ( ) ;
2020-08-28 09:57:04 +03:00
return await returnJSON ( ` /api/data/archive ` , {
... DEFAULT _OPTIONS ,
2020-09-23 14:17:56 +03:00
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
export const removeFromBucket = async ( data ) => {
2021-01-11 06:57:40 +03:00
await Websockets . checkWebsocket ( ) ;
2020-09-23 14:17:56 +03:00
return await returnJSON ( ` /api/data/bucket-remove ` , {
... DEFAULT _OPTIONS ,
body : JSON . stringify ( { data } ) ,
2020-08-28 09:57:04 +03:00
} ) ;
} ;
2020-09-03 09:00:02 +03:00
export const getSlateById = async ( data ) => {
2021-01-11 06:57:40 +03:00
await Websockets . checkWebsocket ( ) ;
2020-09-03 09:00:02 +03:00
return await returnJSON ( ` /api/slates/get ` , {
... DEFAULT _OPTIONS ,
2020-07-22 09:04:54 +03:00
body : JSON . stringify ( { data } ) ,
2020-08-07 05:17:49 +03:00
} ) ;
2020-02-19 09:30:47 +03:00
} ;
2020-07-17 13:24:20 +03:00
2020-11-17 10:12:35 +03:00
export const getSlatesByIds = async ( data ) => {
2021-01-24 09:20:57 +03:00
return await returnJSON ( ` /api/slates/get ` , {
2021-01-24 04:18:04 +03:00
... DEFAULT _OPTIONS ,
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
export const getSocial = async ( data ) => {
2021-01-24 09:20:57 +03:00
return await returnJSON ( ` /api/users/get-social ` , {
2020-11-17 10:12:35 +03:00
... DEFAULT _OPTIONS ,
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
2020-12-14 19:51:14 +03:00
export const deleteTrustRelationship = async ( data ) => {
2021-01-11 06:57:40 +03:00
await Websockets . checkWebsocket ( ) ;
2020-12-14 19:51:14 +03:00
return await returnJSON ( ` /api/users/trust-delete ` , {
... DEFAULT _OPTIONS ,
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
export const updateTrustRelationship = async ( data ) => {
2021-01-11 06:57:40 +03:00
await Websockets . checkWebsocket ( ) ;
2020-12-14 19:51:14 +03:00
return await returnJSON ( ` /api/users/trust-update ` , {
... DEFAULT _OPTIONS ,
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
export const createTrustRelationship = async ( data ) => {
2021-01-11 06:57:40 +03:00
await Websockets . checkWebsocket ( ) ;
2020-12-14 19:51:14 +03:00
return await returnJSON ( ` /api/users/trust ` , {
... DEFAULT _OPTIONS ,
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
2020-08-26 06:13:06 +03:00
export const createSubscription = async ( data ) => {
2021-01-11 06:57:40 +03:00
await Websockets . checkWebsocket ( ) ;
2020-08-26 06:13:06 +03:00
return await returnJSON ( ` /api/subscribe ` , {
... DEFAULT _OPTIONS ,
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
2020-08-26 04:27:05 +03:00
export const search = async ( data ) => {
2021-01-11 06:57:40 +03:00
await Websockets . checkWebsocket ( ) ;
2020-11-12 00:08:59 +03:00
if ( Strings . isEmpty ( data . query ) ) {
2020-08-26 06:13:06 +03:00
return { decorator : "NO_SERVER_TRIP" , data : { results : [ ] } } ;
2020-08-26 04:27:05 +03:00
}
2020-11-16 11:18:02 +03:00
2020-11-12 00:08:59 +03:00
if ( Strings . isEmpty ( data . resourceURI ) ) {
return { decorator : "NO_RESOURCE_URI" , data : { results : [ ] } } ;
}
2020-11-11 05:38:22 +03:00
return await returnJSON ( ` ${ data . resourceURI } /search ` , {
2020-10-31 02:12:20 +03:00
... CORS _OPTIONS ,
2020-11-10 00:20:38 +03:00
body : JSON . stringify ( { data } ) ,
2020-08-26 04:27:05 +03:00
} ) ;
} ;
2021-03-07 23:53:54 +03:00
export const createFile = async ( data ) => {
2021-01-11 06:57:40 +03:00
await Websockets . checkWebsocket ( ) ;
2021-03-07 23:53:54 +03:00
return await returnJSON ( ` /api/data/create ` , {
2020-10-05 00:30:28 +03:00
... DEFAULT _OPTIONS ,
2020-11-28 04:30:40 +03:00
body : JSON . stringify ( { data } ) ,
2020-10-05 00:30:28 +03:00
} ) ;
} ;
2021-07-07 23:50:57 +03:00
export const createLink = async ( data ) => {
await Websockets . checkWebsocket ( ) ;
return await returnJSON ( ` /api/data/create-link ` , {
... DEFAULT _OPTIONS ,
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
2020-09-23 23:52:00 +03:00
export const addFileToSlate = async ( data ) => {
2021-01-11 06:57:40 +03:00
await Websockets . checkWebsocket ( ) ;
2021-03-07 23:53:54 +03:00
return await returnJSON ( ` /api/slates/add-file ` , {
2020-09-23 23:52:00 +03:00
... DEFAULT _OPTIONS ,
2020-11-28 04:30:40 +03:00
body : JSON . stringify ( { data } ) ,
2020-09-23 23:52:00 +03:00
} ) ;
} ;
2021-06-09 01:53:30 +03:00
export const requestTwitterToken = async ( ) => {
return await returnJSON ( ` /api/twitter/request-token ` , {
... DEFAULT _OPTIONS ,
} ) ;
} ;
export const authenticateViaTwitter = async ( data ) => {
return await returnJSON ( ` /api/twitter/authenticate ` , {
... DEFAULT _OPTIONS ,
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
export const createUserViaTwitter = async ( data ) => {
return await returnJSON ( ` /api/twitter/signup ` , {
... DEFAULT _OPTIONS ,
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
export const createUserViaTwitterWithVerification = async ( data ) => {
return await returnJSON ( ` /api/twitter/signup-with-verification ` , {
... DEFAULT _OPTIONS ,
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
2020-07-22 07:11:13 +03:00
export const updateViewer = async ( data ) => {
2021-01-11 06:57:40 +03:00
await Websockets . checkWebsocket ( ) ;
2020-08-07 05:17:49 +03:00
return await returnJSON ( ` /api/users/update ` , {
... DEFAULT _OPTIONS ,
2020-11-28 04:30:40 +03:00
body : JSON . stringify ( { data } ) ,
2020-08-07 05:17:49 +03:00
} ) ;
2020-07-22 07:11:13 +03:00
} ;
2020-07-21 14:36:50 +03:00
export const signIn = async ( data ) => {
2020-08-07 05:17:49 +03:00
return await returnJSON ( ` /api/sign-in ` , {
... DEFAULT _OPTIONS ,
2020-07-21 14:36:50 +03:00
body : JSON . stringify ( { data } ) ,
2020-08-07 05:17:49 +03:00
} ) ;
2020-07-21 14:36:50 +03:00
} ;
2020-07-22 08:53:29 +03:00
export const hydrateAuthenticatedUser = async ( ) => {
2021-01-11 06:57:40 +03:00
await Websockets . checkWebsocket ( ) ;
2020-08-07 05:17:49 +03:00
return await returnJSON ( ` /api/hydrate ` , {
... DEFAULT _OPTIONS ,
} ) ;
2020-07-17 13:24:20 +03:00
} ;
2020-07-22 08:53:29 +03:00
export const deleteViewer = async ( ) => {
2020-08-07 05:17:49 +03:00
return await returnJSON ( ` /api/users/delete ` , {
... DEFAULT _OPTIONS ,
} ) ;
2020-07-17 13:24:20 +03:00
} ;
export const createUser = async ( data ) => {
2020-08-07 05:17:49 +03:00
return await returnJSON ( ` /api/users/create ` , {
... DEFAULT _OPTIONS ,
2020-10-26 00:11:27 +03:00
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
2020-12-09 07:22:17 +03:00
export const updateStatus = async ( data ) => {
2021-01-11 06:57:40 +03:00
await Websockets . checkWebsocket ( ) ;
2020-12-09 07:22:17 +03:00
return await returnJSON ( ` /api/users/status-update ` , {
2020-10-26 00:11:27 +03:00
... DEFAULT _OPTIONS ,
2020-11-10 00:20:38 +03:00
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
export const updateSearch = async ( data ) => {
return await returnJSON ( ` /api/search/update ` , {
... DEFAULT _OPTIONS ,
2020-07-17 13:24:20 +03:00
body : JSON . stringify ( { data } ) ,
2020-08-07 05:17:49 +03:00
} ) ;
2020-07-17 13:24:20 +03:00
} ;
2021-03-07 23:53:54 +03:00
// export const checkCIDStatus = async (data) => {
// return await returnJSON(`/api/data/cid-status`, {
// ...DEFAULT_OPTIONS,
// body: JSON.stringify({ data }),
// });
// };
2020-07-24 10:45:21 +03:00
2020-07-25 03:19:12 +03:00
export const createSlate = async ( data ) => {
2021-01-11 06:57:40 +03:00
await Websockets . checkWebsocket ( ) ;
2020-08-07 05:17:49 +03:00
return await returnJSON ( ` /api/slates/create ` , {
... DEFAULT _OPTIONS ,
2020-07-25 03:19:12 +03:00
body : JSON . stringify ( { data } ) ,
2020-08-07 05:17:49 +03:00
} ) ;
2020-07-25 03:19:12 +03:00
} ;
export const updateSlate = async ( data ) => {
2021-01-11 06:57:40 +03:00
await Websockets . checkWebsocket ( ) ;
2020-08-07 05:17:49 +03:00
return await returnJSON ( ` /api/slates/update ` , {
... DEFAULT _OPTIONS ,
2020-07-25 03:19:12 +03:00
body : JSON . stringify ( { data } ) ,
2020-08-07 05:17:49 +03:00
} ) ;
} ;
2020-07-25 03:19:12 +03:00
2021-03-07 23:53:54 +03:00
export const updateSlateLayout = async ( data ) => {
await Websockets . checkWebsocket ( ) ;
return await returnJSON ( ` /api/slates/update-layout ` , {
... DEFAULT _OPTIONS ,
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
2020-08-07 05:17:49 +03:00
export const deleteSlate = async ( data ) => {
2021-01-11 06:57:40 +03:00
await Websockets . checkWebsocket ( ) ;
2020-08-07 05:17:49 +03:00
return await returnJSON ( ` /api/slates/delete ` , {
... DEFAULT _OPTIONS ,
body : JSON . stringify ( { data } ) ,
} ) ;
2020-07-25 03:19:12 +03:00
} ;
2020-07-28 09:54:15 +03:00
2020-10-24 09:36:52 +03:00
export const removeFileFromSlate = async ( data ) => {
2021-01-11 06:57:40 +03:00
await Websockets . checkWebsocket ( ) ;
2021-03-07 23:53:54 +03:00
return await returnJSON ( ` /api/slates/remove-file ` , {
2020-08-07 05:17:49 +03:00
... DEFAULT _OPTIONS ,
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
2020-07-28 09:54:15 +03:00
2020-08-07 05:17:49 +03:00
export const generateAPIKey = async ( ) => {
2021-01-11 06:57:40 +03:00
await Websockets . checkWebsocket ( ) ;
2020-08-07 05:17:49 +03:00
return await returnJSON ( ` /api/keys/generate ` , {
... DEFAULT _OPTIONS ,
} ) ;
2020-07-28 09:54:15 +03:00
} ;
export const deleteAPIKey = async ( data ) => {
2021-01-11 06:57:40 +03:00
await Websockets . checkWebsocket ( ) ;
2020-08-07 05:17:49 +03:00
return await returnJSON ( ` /api/keys/delete ` , {
... DEFAULT _OPTIONS ,
2020-07-28 09:54:15 +03:00
body : JSON . stringify ( { data } ) ,
2020-08-07 05:17:49 +03:00
} ) ;
2020-07-28 09:54:15 +03:00
} ;
2020-08-12 11:22:28 +03:00
2021-03-07 23:53:54 +03:00
export const saveCopy = async ( data ) => {
2021-01-11 06:57:40 +03:00
await Websockets . checkWebsocket ( ) ;
2021-03-07 23:53:54 +03:00
return await returnJSON ( ` /api/data/save-copy ` , {
2020-10-05 00:30:28 +03:00
... DEFAULT _OPTIONS ,
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
2021-03-07 23:53:54 +03:00
export const updateFile = async ( data ) => {
2021-01-11 06:57:40 +03:00
await Websockets . checkWebsocket ( ) ;
2020-11-16 03:29:13 +03:00
return await returnJSON ( ` /api/data/update ` , {
... DEFAULT _OPTIONS ,
body : JSON . stringify ( { data } ) ,
2021-01-09 07:13:00 +03:00
} ) ;
} ;
2021-03-07 23:53:54 +03:00
export const deleteFiles = async ( data ) => {
2021-01-11 06:57:40 +03:00
await Websockets . checkWebsocket ( ) ;
2021-03-07 23:53:54 +03:00
return await returnJSON ( ` /api/data/delete ` , {
2020-09-18 06:40:10 +03:00
... DEFAULT _OPTIONS ,
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
2020-09-03 06:26:56 +03:00
export const getSerializedSlate = async ( data ) => {
return await returnJSON ( ` /api/slates/get-serialized ` , {
... DEFAULT _OPTIONS ,
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
export const getSerializedProfile = async ( data ) => {
return await returnJSON ( ` /api/users/get-serialized ` , {
... DEFAULT _OPTIONS ,
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
2020-09-17 02:26:15 +03:00
export const createSupportMessage = async ( data ) => {
return await returnJSON ( ` /api/support-message ` , {
... DEFAULT _OPTIONS ,
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
2020-12-04 02:34:19 +03:00
2021-05-19 05:58:14 +03:00
export const createDownloadActivity = async ( data ) => {
return await returnJSON ( ` /api/activity/create-download-activity ` , {
... DEFAULT _OPTIONS ,
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
2021-01-14 09:30:26 +03:00
export const getActivity = async ( data ) => {
2021-03-07 23:53:54 +03:00
return await returnJSON ( ` /api/activity/get-activity ` , {
... DEFAULT _OPTIONS ,
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
export const getExplore = async ( data ) => {
return await returnJSON ( ` /api/activity/get-explore ` , {
2020-12-04 02:34:19 +03:00
... DEFAULT _OPTIONS ,
2021-01-14 09:30:26 +03:00
body : JSON . stringify ( { data } ) ,
2020-12-04 02:34:19 +03:00
} ) ;
} ;
2020-12-25 02:44:47 +03:00
2020-12-25 02:52:34 +03:00
export const getZipFilePaths = async ( data ) => {
2021-03-04 09:31:11 +03:00
return await returnJSON ( ` /api/zip/get-paths ` , {
2020-12-25 02:44:47 +03:00
... DEFAULT _OPTIONS ,
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
2021-01-21 04:07:40 +03:00
export const cleanDatabase = async ( ) => {
2021-06-09 01:53:30 +03:00
return await returnJSON ( ` /api/clean-up/users ` , {
2021-01-21 04:07:40 +03:00
... DEFAULT _OPTIONS ,
} ) ;
} ;
2021-04-20 23:35:30 +03:00
2021-06-09 01:53:30 +03:00
export const createTwitterEmailVerification = async ( data ) => {
return await returnJSON ( ` /api/verifications/twitter/create ` , {
2021-06-30 00:09:09 +03:00
... DEFAULT _OPTIONS ,
2021-06-09 01:53:30 +03:00
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
export const verifyTwitterEmail = async ( data ) => {
return await returnJSON ( ` /api/verifications/twitter/verify ` , {
2021-06-30 00:09:09 +03:00
... DEFAULT _OPTIONS ,
2021-06-09 01:53:30 +03:00
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
export const createPasswordResetVerification = async ( data ) => {
return await returnJSON ( ` /api/verifications/password-reset/create ` , {
2021-06-30 00:09:09 +03:00
... DEFAULT _OPTIONS ,
2021-06-09 01:53:30 +03:00
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
export const verifyPasswordResetEmail = async ( data ) => {
return await returnJSON ( ` /api/verifications/password-reset/verify ` , {
2021-06-30 00:09:09 +03:00
... DEFAULT _OPTIONS ,
2021-06-09 01:53:30 +03:00
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
export const resetPassword = async ( data ) => {
return await returnJSON ( ` /api/users/reset-password ` , {
2021-06-30 00:09:09 +03:00
... DEFAULT _OPTIONS ,
2021-06-09 01:53:30 +03:00
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
export const createLegacyVerification = async ( data ) => {
return await returnJSON ( ` /api/verifications/legacy/create ` , {
2021-06-30 00:09:09 +03:00
... DEFAULT _OPTIONS ,
2021-06-09 01:53:30 +03:00
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
export const migrateUser = async ( data ) => {
return await returnJSON ( ` /api/users/migrate ` , {
2021-06-30 00:09:09 +03:00
... DEFAULT _OPTIONS ,
2021-06-09 01:53:30 +03:00
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
export const createVerification = async ( data ) => {
return await returnJSON ( ` /api/verifications/create ` , {
2021-06-30 00:09:09 +03:00
... DEFAULT _OPTIONS ,
2021-06-09 01:53:30 +03:00
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
export const verifyEmail = async ( data ) => {
return await returnJSON ( ` /api/verifications/verify ` , {
2021-06-30 00:09:09 +03:00
... DEFAULT _OPTIONS ,
2021-06-09 01:53:30 +03:00
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
export const resendVerification = async ( data ) => {
return await returnJSON ( ` /api/verifications/resend ` , {
2021-06-30 00:09:09 +03:00
... DEFAULT _OPTIONS ,
2021-06-09 01:53:30 +03:00
body : JSON . stringify ( { data } ) ,
} ) ;
} ;
export const getUserVersion = async ( data ) => {
return await returnJSON ( ` /api/users/get-version ` , {
2021-06-30 00:09:09 +03:00
... DEFAULT _OPTIONS ,
2021-04-20 23:35:30 +03:00
body : JSON . stringify ( { data } ) ,
} ) ;
} ;