@@ -33,7 +33,8 @@ import {
3333 SetSignatureError ,
3434 SignatureGeneratingError ,
3535 SignatureNotFoundError ,
36- ErrorDuringVerificationError
36+ ErrorDuringVerificationError ,
37+ CallbackUrlRequiredError
3738} from './utils/errors'
3839import { validateContext , validateFunctionParams , validateParameters , validateSignature , validateURL , validateModalOptions , validateFunctionParamsWithFn , validateRedirectionMethod , validateRedirectionBody } from './utils/validationUtils'
3940import { fetchStatusUrl , initSession , updateSession } from './utils/sessionUtils'
@@ -975,6 +976,23 @@ export class ReclaimProofRequest {
975976 if ( ! this . signature ) {
976977 throw new SignatureNotFoundError ( 'Signature is not set.' )
977978 }
979+
980+ // When using a non-default regional portal, a custom callback URL is required
981+ const defaultHosts = [ 'share.reclaimprotocol.org' , 'portal.reclaimprotocol.org' ] ;
982+ if ( this . customSharePageUrl ) {
983+ try {
984+ const sharePageHost = new URL ( this . customSharePageUrl ) . hostname ;
985+ if ( ! defaultHosts . includes ( sharePageHost ) && ! this . appCallbackUrl ) {
986+ throw new CallbackUrlRequiredError (
987+ 'A custom callback URL is required when using a customSharePage url'
988+ ) ;
989+ }
990+ } catch ( e ) {
991+ if ( e instanceof CallbackUrlRequiredError ) throw e ;
992+ // If URL parsing fails, skip this check — URL validation elsewhere will catch it
993+ }
994+ }
995+
978996 validateSignature ( this . providerId , this . signature , this . applicationId , this . timeStamp )
979997 const templateData : TemplateData = {
980998 sessionId : this . sessionId ,
0 commit comments