@@ -5,7 +5,7 @@ import config from '../../config.ts';
55import { GroupRepository , PartyRepository , ProfileRepository } from '../../db.ts' ;
66import { Group , Party , ProfileTable } from '../../entities.ts' ;
77import type { PreselectedPartyOperationType } from '../types/mutation.ts' ;
8- import type { NotificationSettingsInputData } from '../types/profile.ts' ;
8+ import type { NotificationSettingsInputData , VerifyAddressInputData } from '../types/profile.ts' ;
99
1010const { platformBaseURL } = config ;
1111
@@ -454,6 +454,56 @@ export const updateProfileSettingPreference = async (context: Context, shouldSho
454454 }
455455} ;
456456
457+ export const verifyAddress = async ( data : VerifyAddressInputData , context : Context ) => {
458+ const newToken = await exchangeToken ( context ) ;
459+ try {
460+ await axios . post (
461+ `${ platformProfileAPI_url } users/current/verification/verify` ,
462+ { value : data . value , type : data . type , verificationCode : data . verificationCode } ,
463+ {
464+ timeout : 30000 ,
465+ headers : {
466+ Authorization : `Bearer ${ newToken } ` ,
467+ 'Content-Type' : 'application/json' ,
468+ Accept : 'application/json' ,
469+ } ,
470+ } ,
471+ ) ;
472+ return { success : true } ;
473+ } catch ( error ) {
474+ if ( typeof error === 'object' && error !== null && 'response' in error ) {
475+ const axiosError = error as { response ?: { status ?: number } } ;
476+ if ( axiosError . response ?. status === 422 ) {
477+ return { success : false , message : 'invalid_code' } ;
478+ }
479+ }
480+ logger . error ( error , 'Error verifying address:' ) ;
481+ throw error ;
482+ }
483+ } ;
484+
485+ export const getVerifiedAddresses = async ( context : Context ) => {
486+ const newToken = await exchangeToken ( context ) ;
487+ if ( ! newToken ) {
488+ logger . error ( 'No new token received' ) ;
489+ throw new Error ( 'Unable to exchange token' ) ;
490+ }
491+ try {
492+ const response = await axios . get ( `${ platformProfileAPI_url } users/current/verification/verified-addresses` , {
493+ timeout : 30000 ,
494+ headers : {
495+ Authorization : `Bearer ${ newToken } ` ,
496+ 'Content-Type' : 'application/json' ,
497+ Accept : 'application/json' ,
498+ } ,
499+ } ) ;
500+ return response . data ?? [ ] ;
501+ } catch ( error ) {
502+ logger . error ( error , 'Error fetching verified addresses for user:' ) ;
503+ return [ ] ;
504+ }
505+ } ;
506+
457507export const updateLanguage = async ( pid : string , language : string ) => {
458508 const currentProfile = await ProfileRepository ! . findOne ( {
459509 where : { pid } ,
0 commit comments