@@ -165,6 +165,14 @@ const checkExpiredSession = async (
165165 }
166166} ;
167167
168+ const activateAddress = async ( { rowId, active, recipientId } ) => {
169+ const client = await createClient ( { recipientId } ) ;
170+ const res = await client . activateAddress ( rowId , active ) ;
171+ return res . status === 200
172+ ? res
173+ : await checkExpiredSession ( res , activateAddress , { rowId, active } ) ;
174+ } ;
175+
168176const acknowledgeEvents = async params => {
169177 const { eventIds, recipientId } = params ;
170178 const client = await createClient ( { recipientId } ) ;
@@ -209,6 +217,14 @@ const checkAvailableUsername = async username => {
209217 return await client . checkAvailableUsername ( username ) ;
210218} ;
211219
220+ const deleteAddress = async ( { addressId, recipientId } ) => {
221+ const client = await createClient ( { recipientId } ) ;
222+ const res = await client . deleteAddress ( addressId ) ;
223+ return res . status === 200
224+ ? res
225+ : await checkExpiredSession ( res , deleteAddress , addressId ) ;
226+ } ;
227+
212228const deleteDeviceToken = async params => {
213229 const recipientId = getRecipientId ( params ) ;
214230 const client = await createClient ( {
@@ -221,6 +237,14 @@ const deleteDeviceToken = async params => {
221237 : await checkExpiredSession ( res , deleteDeviceToken , params ) ;
222238} ;
223239
240+ const deleteDomain = async ( { domain, recipientId } ) => {
241+ const client = await createClient ( { recipientId } ) ;
242+ const res = await client . deleteDomain ( domain ) ;
243+ return res . status === 200
244+ ? res
245+ : await checkExpiredSession ( res , deleteDomain , domain ) ;
246+ } ;
247+
224248const deleteMyAccount = async params => {
225249 const { recipientId, password } = params ;
226250 const client = await createClient ( { recipientId } ) ;
@@ -265,6 +289,14 @@ const getDataReady = async recipientId => {
265289 : await checkExpiredSession ( res , getDataReady , recipientId ) ;
266290} ;
267291
292+ const getDomainMX = async ( { domain, recipientId } ) => {
293+ const client = await createClient ( { recipientId } ) ;
294+ const res = await client . getDomainMX ( domain ) ;
295+ return res . status === 200
296+ ? res
297+ : await checkExpiredSession ( res , getDomainMX , domain ) ;
298+ } ;
299+
268300const getKeyBundle = async params => {
269301 const { deviceId, recipientId } = params ;
270302 const client = await createClient ( { recipientId } ) ;
@@ -274,6 +306,13 @@ const getKeyBundle = async params => {
274306 : await checkExpiredSession ( res , getKeyBundle , params ) ;
275307} ;
276308
309+ const getMaxDevices = async params => {
310+ const { token, recipientId } = params ;
311+ const client = await createClient ( { recipientId } ) ;
312+ const res = await client . getMaxDevices ( token ) ;
313+ return res ;
314+ } ;
315+
277316const getUserSettings = async recipientId => {
278317 const client = await createClient ( { recipientId } ) ;
279318 const res = await client . getUserSettings ( ) ;
@@ -282,9 +321,16 @@ const getUserSettings = async recipientId => {
282321 : await checkExpiredSession ( res , getUserSettings , recipientId ) ;
283322} ;
284323
324+ const isDomainAvailable = async ( { domain, recipientId } ) => {
325+ const request = { domain : { name : domain } } ;
326+ const client = await createClient ( { recipientId } ) ;
327+ return await client . isDomainAvailable ( request ) ;
328+ } ;
329+
285330const parseUserSettings = settings => {
286- const { devices, general } = settings ;
331+ const { devices, general, addresses } = settings ;
287332 const {
333+ customerType,
288334 recoveryEmail,
289335 recoveryEmailConfirmed,
290336 replyTo,
@@ -293,6 +339,8 @@ const parseUserSettings = settings => {
293339 } = general ;
294340 return {
295341 devices,
342+ addresses,
343+ customerType,
296344 twoFactorAuth : ! ! twoFactorAuth ,
297345 recoveryEmail,
298346 recoveryEmailConfirmed : ! ! recoveryEmailConfirmed ,
@@ -463,6 +511,14 @@ const postUser = async params => {
463511 return await client . postUser ( params ) ;
464512} ;
465513
514+ const registerDomain = async ( { domain, recipientId } ) => {
515+ const client = await createClient ( { recipientId } ) ;
516+ const res = await client . registerDomain ( domain ) ;
517+ return res . status === 200
518+ ? res
519+ : await checkExpiredSession ( res , registerDomain , domain ) ;
520+ } ;
521+
466522const removeAvatar = async recipientId => {
467523 const client = await createClient ( { recipientId } ) ;
468524 return await client . deleteAvatar ( ) ;
@@ -505,6 +561,14 @@ const resetPassword = async params => {
505561 : await checkExpiredSession ( res , resetPassword , params ) ;
506562} ;
507563
564+ const setAddress = async params => {
565+ const client = await createClient ( { recipientId : params . recipientId } ) ;
566+ const res = await client . setAddress ( params . username , params . domain ) ;
567+ return res . status === 200
568+ ? res
569+ : await checkExpiredSession ( res , setAddress , params ) ;
570+ } ;
571+
508572const sendRecoveryCode = async ( { newDeviceData, jwt } ) => {
509573 const recipientId = getRecipientId ( newDeviceData ) ;
510574 const client = await createClient ( { recipientId, optionalToken : jwt } ) ;
@@ -659,6 +723,14 @@ const unsendEmail = async params => {
659723 : await checkExpiredSession ( res , unsendEmail , params ) ;
660724} ;
661725
726+ const validateDomainMX = async ( { domain, recipientId } ) => {
727+ const client = await createClient ( { recipientId } ) ;
728+ const res = await client . validateDomainMX ( domain ) ;
729+ return res . status === 200
730+ ? res
731+ : await checkExpiredSession ( res , validateDomainMX , domain ) ;
732+ } ;
733+
662734const validateRecoveryCode = async ( { newDeviceData, jwt } ) => {
663735 const recipientId = getRecipientId ( newDeviceData ) ;
664736 const client = await createClient ( { recipientId, optionalToken : jwt } ) ;
@@ -667,22 +739,28 @@ const validateRecoveryCode = async ({ newDeviceData, jwt }) => {
667739} ;
668740
669741module . exports = {
742+ activateAddress,
670743 acknowledgeEvents,
671744 canLogin,
672745 changePassword,
673746 changeRecoveryEmail,
674747 checkAvailableUsername,
675748 checkExpiredSession,
749+ deleteAddress,
676750 deleteDeviceToken,
751+ deleteDomain,
677752 deleteMyAccount,
678753 findDevices,
679754 findKeyBundles,
680755 generateEvent,
681756 getDataReady,
757+ getDomainMX,
682758 getKeyBundle,
759+ getMaxDevices,
683760 getUserSettings,
684761 insertPreKeys,
685762 isCriptextDomain,
763+ isDomainAvailable,
686764 linkAccept,
687765 linkAuth,
688766 linkBegin,
@@ -698,11 +776,13 @@ module.exports = {
698776 postPeerEvent,
699777 pushPeerEvents,
700778 postUser,
779+ registerDomain,
701780 removeAvatar,
702781 removeDevice,
703782 reportPhishing,
704783 resendConfirmationEmail,
705784 resetPassword,
785+ setAddress,
706786 sendRecoveryCode,
707787 setReadTracking,
708788 setReplyTo,
@@ -718,5 +798,6 @@ module.exports = {
718798 updatePushToken,
719799 uploadAvatar,
720800 unsendEmail,
801+ validateDomainMX,
721802 validateRecoveryCode
722803} ;
0 commit comments