@rkfl/transact-server 2.2.0-alpha.0 → 2.3.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import e from"crypto-js";import*as t from"crypto";const s={production:"https://app.rocketfuel.inc/api",qa:"https://qa-app.rfdemo.co/api",preprod:"https://preprod-app.rocketdemo.net/api",sandbox:"https://app-sandbox.rocketfuel.inc/api"};class a{#e;#t;#s;#a;#r=null;#n=null;constructor({clientId:e,clientSecret:t,merchantId:a,environment:r}){this.#e=e,this.#t=t,this.#s=a,this.#a=s[r||"production"]}#i(){const t=JSON.stringify({merchantId:this.#s,totop:""});return e.AES.encrypt(t,this.#t).toString()}#o(){const e={"Content-Type":"application/json"};return this.#r&&(e.Authorization=`Bearer ${this.#r}`),e}async#c(){const e={clientId:this.#e,encryptedPayload:this.#i()},t=await fetch(`${this.#a}/auth/generate-auth-token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error(`Auth failed: ${t.status}`);const s=await t.json(),a=s?.result;if(!a?.access)throw new Error("Token missing in response");this.#r=a.access,this.#n=a.refresh}async#h(e,t,s=!0){const a=await fetch(e,t);if((401===a.status||403===a.status)&&s){await this.#c();const s={...t,headers:this.#o()};return this.#h(e,s,!1)}if(!a.ok){const e=new Error(a.statusText);throw e.status=a.status,e}return a.json()}async createOrder(e){this.#r||await this.#c();const t=await this.#h(`${this.#a}/hosted-page`,{method:"POST",headers:this.#o(),body:JSON.stringify(e)});return{uuid:t?.result?.uuid}}async transactionLookup(e,t="ORDERID"){this.#r||await this.#c();const s=await this.#h(`${this.#a}/purchase/transactionLookup`,{method:"POST",headers:this.#o(),body:JSON.stringify({txId:e,type:t})});return s?.result}async verifyAgeVerification(e){this.#r||await this.#c();const t=await this.#h(`${this.#a}/merchant/audit/${e}`,{method:"GET",headers:this.#o()});return t?.result}verifyWebhookSignature(e){try{const{data:{data:s},signature:a}=e,r=t.createVerify("RSA-SHA256");return r.update(s),r.verify("-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2e4stIYooUrKHVQmwztC\n/l0YktX6uz4bE1iDtA2qu4OaXx+IKkwBWa0hO2mzv6dAoawyzxa2jmN01vrpMkMj\nrB+Dxmoq7tRvRTx1hXzZWaKuv37BAYosOIKjom8S8axM1j6zPkX1zpMLE8ys3dUX\nFN5Dl/kBfeCTwGRV4PZjP4a+QwgFRzZVVfnpcRI/O6zhfkdlRah8MrAPWYSoGBpG\nCPiAjUeHO/4JA5zZ6IdfZuy/DKxbcOlt9H+z14iJwB7eVUByoeCE+Bkw+QE4msKs\naIn4xl9GBoyfDZKajTzL50W/oeoE1UcuvVfaULZ9DWnHOy6idCFH1WbYDxYYIWLi\nAQIDAQAB\n-----END PUBLIC KEY-----",a,"base64")}catch(e){return console.error("Signature verification failed:",e),!1}}}const r={production:"https://app.rocketfuel.inc/api",qa:"https://qa-app.rfdemo.co/api",preprod:"https://preprod-app.rocketdemo.net/api",sandbox:"https://app-sandbox.rocketfuel.inc/api"};class n{clientId;clientSecret;merchantId;domain;accessToken=null;refreshToken=null;constructor({clientId:e,clientSecret:t,merchantId:s,environment:a}){this.clientId=e,this.clientSecret=t,this.merchantId=s,this.domain=r[a||"production"]}getAuthPayload(){const t=JSON.stringify({merchantId:this.merchantId,totop:""});return e.AES.encrypt(t,this.clientSecret).toString()}getHeaders(){const e={"Content-Type":"application/json"};return this.accessToken&&(e.Authorization=`Bearer ${this.accessToken}`),e}async getAccessToken(){const e={clientId:this.clientId,encryptedPayload:this.getAuthPayload()},t=await fetch(`${this.domain}/auth/generate-auth-token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error(`Auth failed: ${t.status}`);const s=await t.json(),a=s?.result;if(!a?.access)throw new Error("Token missing in response");this.accessToken=a.access,this.refreshToken=a.refresh}async requestWithRetry(e,t,s=!0){const a=await fetch(e,t);if((401===a.status||403===a.status)&&s){await this.getAccessToken();const s={...t,headers:this.getHeaders()};return this.requestWithRetry(e,s,!1)}if(!a.ok){const e=new Error(a.statusText);throw e.status=a.status,e}return a.json()}}class i extends n{constructor(e){super(e)}async getBankConfiguration(e){this.accessToken||await this.getAccessToken();const t=new URLSearchParams({payeeId:e.payeeId,currency:e.currency,country:e.country}),s=`${this.domain}/payout/fiat/bank-configuration?${t.toString()}`,a=await this.requestWithRetry(s,{method:"GET",headers:this.getHeaders()}),r=new URLSearchParams({payeeId:e.payeeId}),n=`${this.domain}/payout/fiat/personal-field-values?${r.toString()}`,i=await this.requestWithRetry(n,{method:"GET",headers:this.getHeaders()}),o=a?.result??a,c=i?.result?.fields;if(c&&o){const e=Object.keys(c),t={};return Object.keys(o).forEach(s=>{t[s]=o[s].map(t=>(e.indexOf(t.name)>-1&&(t.acceptedValues=c[t.name]),t))}),console.debug("fetched personal field values and appended it"),t}return console.debug("no personal field values found"),o}async getStatus(e){this.accessToken||await this.getAccessToken();const t=new URLSearchParams({payeeId:e.payeeId,country:e.country,currency:e.currency}),s=`${this.domain}/payout/services?${t.toString()}`,a=await this.requestWithRetry(s,{method:"GET",headers:this.getHeaders()});return a?.result??a}async shouldShowExternalPayeeForm(e){this.accessToken||await this.getAccessToken();const t=new URLSearchParams({payeeId:e}),s=`${this.domain}/payout/user/create/external/check?${t.toString()}`,a=await this.requestWithRetry(s,{method:"GET",headers:this.getHeaders()});return a?.result??a}async createPayeeUserExternal(e){this.accessToken||await this.getAccessToken();const t=`${this.domain}/payout/user/create/external?payeeId=${e.payeeId}`,s=await this.requestWithRetry(t,{method:"POST",headers:this.getHeaders(),body:JSON.stringify({fName:e.fName,lName:e.lName,email:e.email,country:e.country})});return s?.result??s}async getPublicCountries(){const e=`${this.domain}/payout/countries`,t=await this.requestWithRetry(e,{method:"GET",headers:this.getHeaders()});return t?.result??t}async getCountries(e){this.accessToken||await this.getAccessToken();const t=new URLSearchParams;e.payeeId&&t.set("payeeId",e.payeeId),e.currency&&t.set("currency",e.currency);const s=`${this.domain}/payout/fiat/country${t.toString()?`?${t.toString()}`:""}`,a=await this.requestWithRetry(s,{method:"GET",headers:this.getHeaders()});return a?.result??a}async getCurrencies(e){this.accessToken||await this.getAccessToken();const t=new URLSearchParams({payeeId:e.payeeId});e.country&&t.set("country",e.country);const s=`${this.domain}/payout/fiat/currency?${t.toString()}`,a=await this.requestWithRetry(s,{method:"GET",headers:this.getHeaders()});return a?.result??a}async saveBankDetails(e,t){this.accessToken||await this.getAccessToken();const s=new URLSearchParams({payeeId:e,currency:t.currency,country:t.country}),a=`${this.domain}/payout/fiat/bank-configuration?${s.toString()}`,r=await this.requestWithRetry(a,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(t)});return r?.result??r}async deleteBankDetails(e){this.accessToken||await this.getAccessToken();const t=new URLSearchParams({payeeId:e.payeeId}),s=`${this.domain}/payout/fiat/bank/${encodeURIComponent(e.bankId)}?${t.toString()}`,a=await this.requestWithRetry(s,{method:"DELETE",headers:this.getHeaders()});return a?.result??a}async listBankDetails(e){this.accessToken||await this.getAccessToken();const t=new URLSearchParams({payeeId:e.payeeId}),s=`${this.domain}/payout/fiat/bank-detail?${t.toString()}`,a=await this.requestWithRetry(s,{method:"GET",headers:this.getHeaders()});return a?.result??a}async getTransferFee(e,t){this.accessToken||await this.getAccessToken();const s=new URLSearchParams({payeeId:e.payeeId,country:e.country,currency:e.currency}),a=`${this.domain}/payout/fiat/fees?${s.toString()}`,r=await this.requestWithRetry(a,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(t)});return r?.result??r}async transfer(e,t){this.accessToken||await this.getAccessToken();const s=new URLSearchParams({payeeId:e.payeeId,country:e.country,currency:e.currency}),a=`${this.domain}/payout/fiat/transfer?${s.toString()}`,r=await this.requestWithRetry(a,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(t)});return r?.result??r}async getTransferStatus(e,t){this.accessToken||await this.getAccessToken();const s=new URLSearchParams({payeeId:t}),a=`${this.domain}/payout/order/${encodeURIComponent(e)}?${s.toString()}`,r=await this.requestWithRetry(a,{method:"GET",headers:this.getHeaders()});return r?.result??r}async getPaymentMethods(e){this.accessToken||await this.getAccessToken();const t=new URLSearchParams({amount:e.amount});e.payeeId&&t.set("payeeId",e.payeeId),e.country&&t.set("country",e.country),e.currency&&t.set("currency",e.currency);const s=`${this.domain}/payout/fiat/payment-methods?${t.toString()}`,a=await this.requestWithRetry(s,{method:"GET",headers:this.getHeaders()});return a?.result??a}async getFileUploadUrl(e){this.accessToken||await this.getAccessToken();const t=new URLSearchParams({contentType:e.contentType});e.payeeId&&t.set("payeeId",e.payeeId);const s=`${this.domain}/payout/files/upload-url?${t.toString()}`,a=await this.requestWithRetry(s,{method:"GET",headers:this.getHeaders()});return a?.result??a}async getComplianceStatus(e){this.accessToken||await this.getAccessToken();const t=new URLSearchParams({country:e.country,service:e.service});e.destinationRecordId&&t.set("destinationRecordId",e.destinationRecordId),e.payeeId&&t.set("payeeId",e.payeeId);const s=`${this.domain}/payout/compliance-status?${t.toString()}`,a=await this.requestWithRetry(s,{method:"GET",headers:this.getHeaders()});return a?.result??a}}class o extends n{constructor(e){super(e)}async getCurrencies(e){this.accessToken||await this.getAccessToken();const t=`${this.domain}/payout/currencies?payeeId=${encodeURIComponent(e)}`,s=await this.requestWithRetry(t,{method:"GET",headers:this.getHeaders()});return s?.result}async checkAddress(e){this.accessToken||await this.getAccessToken();return await this.requestWithRetry(`${this.domain}/payout/know-your-address`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(e)})}async getTransferFee(e,t){this.accessToken||await this.getAccessToken();const s=`${this.domain}/payout/fee?payeeId=${encodeURIComponent(e)}`,a=await this.requestWithRetry(s,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(t)});return a?.result}async checkTransfer(e,t){this.accessToken||await this.getAccessToken();const s=`${this.domain}/payout/withdraw-check?payeeId=${encodeURIComponent(e)}`,a=await this.requestWithRetry(s,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(t)});return a?.result}async transfer(e,t){this.accessToken||await this.getAccessToken();const s=`${this.domain}/payout/withdraw?payeeId=${encodeURIComponent(e)}`,a=await this.requestWithRetry(s,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(t)});return a?.result}async getTransferStatus(e,t){this.accessToken||await this.getAccessToken();const s=new URLSearchParams({payeeId:t}),a=`${this.domain}/payout/order/${encodeURIComponent(e)}?${s.toString()}`,r=await this.requestWithRetry(a,{method:"GET",headers:this.getHeaders()});return r?.result??r}}class c extends n{constructor(e){super(e)}async invitePayee(e){this.accessToken||await this.getAccessToken();const t=await this.requestWithRetry(`${this.domain}/payout/external/payee`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(e)});return t?.result}async submitPayeeKyc(e){this.accessToken||await this.getAccessToken();const t=await this.requestWithRetry(`${this.domain}/compliance/kyc`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(e)});return t?.result}async getPayeeBalance(e){this.accessToken||await this.getAccessToken();const t=await this.requestWithRetry(`${this.domain}/payout-admin/payee/${encodeURIComponent(e)}/balance`,{method:"GET",headers:this.getHeaders()});return t?.result}async getBalance(){this.accessToken||await this.getAccessToken();return await this.requestWithRetry(`${this.domain}/payout-admin/balance`,{method:"GET",headers:this.getHeaders()})}async getRunningBalance(){this.accessToken||await this.getAccessToken();return await this.requestWithRetry(`${this.domain}/payout-admin/running-balance`,{method:"GET",headers:this.getHeaders()})}async createTransferAllocation(e){this.accessToken||await this.getAccessToken();const t=await this.requestWithRetry(`${this.domain}/payout-admin/transfer`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(e)});return t?.result??t}async allocateTransfer(e,t){this.accessToken||await this.getAccessToken();const s=`${this.domain}/payout-admin/transfer/${encodeURIComponent(e)}/allocate`,a=await this.requestWithRetry(s,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(t)});return a?.result??a}}class h{static verify(e){try{const{data:s,signature:a}=e||{};if(!s||!a)return!1;const r=t.createVerify("RSA-SHA256");return r.update(s),r.verify("-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2e4stIYooUrKHVQmwztC\n/l0YktX6uz4bE1iDtA2qu4OaXx+IKkwBWa0hO2mzv6dAoawyzxa2jmN01vrpMkMj\nrB+Dxmoq7tRvRTx1hXzZWaKuv37BAYosOIKjom8S8axM1j6zPkX1zpMLE8ys3dUX\nFN5Dl/kBfeCTwGRV4PZjP4a+QwgFRzZVVfnpcRI/O6zhfkdlRah8MrAPWYSoGBpG\nCPiAjUeHO/4JA5zZ6IdfZuy/DKxbcOlt9H+z14iJwB7eVUByoeCE+Bkw+QE4msKs\naIn4xl9GBoyfDZKajTzL50W/oeoE1UcuvVfaULZ9DWnHOy6idCFH1WbYDxYYIWLi\nAQIDAQAB\n-----END PUBLIC KEY-----",a,"base64")}catch(e){return console.error("Payout signature verification failed:",e),!1}}}const d="PAYOUT",u={PayeeAdded:"PayeeAdded",PayeeKycStarted:"PayeeKycStarted",PayeeKycStatusChange:"PayeeKycStatusChange",PayeeFundAllocated:"PayeeFundAllocated",PayoutStarted:"PayoutStarted",PayoutStatusChange:"PayoutStatusChange"};class y{fiat;crypto;admin;constructor(e){this.fiat=new i(e),this.crypto=new o(e),this.admin=new c(e)}}export{u as PAYOUT_WEBHOOK_EVENTS,d as PAYOUT_WEBHOOK_EVENT_TYPE,h as PayoutWebhookVerifier,a as Rocketfuel,y as RocketfuelPayouts};
1
+ import e from"crypto-js";import*as t from"crypto";const s={production:"https://app.rocketfuel.inc/api",qa:"https://qa-app.rfdemo.co/api",preprod:"https://preprod-app.rocketdemo.net/api",sandbox:"https://app-sandbox.rocketfuel.inc/api"};class a{#e;#t;#s;#a;#r=null;#n=null;constructor({clientId:e,clientSecret:t,merchantId:a,environment:r}){this.#e=e,this.#t=t,this.#s=a,this.#a=s[r||"production"]}#i(){const t=JSON.stringify({merchantId:this.#s,totop:""});return e.AES.encrypt(t,this.#t).toString()}#o(){const e={"Content-Type":"application/json"};return this.#r&&(e.Authorization=`Bearer ${this.#r}`),e}async#c(){const e={clientId:this.#e,encryptedPayload:this.#i()},t=await fetch(`${this.#a}/auth/generate-auth-token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error(`Auth failed: ${t.status}`);const s=await t.json(),a=s?.result;if(!a?.access)throw new Error("Token missing in response");this.#r=a.access,this.#n=a.refresh}async#h(e,t,s=!0){const a=await fetch(e,t);if((401===a.status||403===a.status)&&s){await this.#c();const s={...t,headers:this.#o()};return this.#h(e,s,!1)}if(!a.ok){const e=new Error(a.statusText);throw e.status=a.status,e}return a.json()}async createOrder(e){this.#r||await this.#c();const t=await this.#h(`${this.#a}/hosted-page`,{method:"POST",headers:this.#o(),body:JSON.stringify(e)});return{uuid:t?.result?.uuid}}async transactionLookup(e,t="ORDERID"){this.#r||await this.#c();const s=await this.#h(`${this.#a}/purchase/transactionLookup`,{method:"POST",headers:this.#o(),body:JSON.stringify({txId:e,type:t})});return s?.result}async verifyAgeVerification(e){this.#r||await this.#c();const t=await this.#h(`${this.#a}/merchant/audit/${e}`,{method:"GET",headers:this.#o()});return t?.result}verifyWebhookSignature(e){try{const{data:{data:s},signature:a}=e,r=t.createVerify("RSA-SHA256");return r.update(s),r.verify("-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2e4stIYooUrKHVQmwztC\n/l0YktX6uz4bE1iDtA2qu4OaXx+IKkwBWa0hO2mzv6dAoawyzxa2jmN01vrpMkMj\nrB+Dxmoq7tRvRTx1hXzZWaKuv37BAYosOIKjom8S8axM1j6zPkX1zpMLE8ys3dUX\nFN5Dl/kBfeCTwGRV4PZjP4a+QwgFRzZVVfnpcRI/O6zhfkdlRah8MrAPWYSoGBpG\nCPiAjUeHO/4JA5zZ6IdfZuy/DKxbcOlt9H+z14iJwB7eVUByoeCE+Bkw+QE4msKs\naIn4xl9GBoyfDZKajTzL50W/oeoE1UcuvVfaULZ9DWnHOy6idCFH1WbYDxYYIWLi\nAQIDAQAB\n-----END PUBLIC KEY-----",a,"base64")}catch(e){return console.error("Signature verification failed:",e),!1}}}const r={production:"https://app.rocketfuel.inc/api",qa:"https://qa-app.rfdemo.co/api",preprod:"https://preprod-app.rocketdemo.net/api",sandbox:"https://app-sandbox.rocketfuel.inc/api"};class n{clientId;clientSecret;merchantId;domain;accessToken=null;refreshToken=null;constructor({clientId:e,clientSecret:t,merchantId:s,environment:a}){this.clientId=e,this.clientSecret=t,this.merchantId=s,this.domain=r[a||"production"]}getAuthPayload(){const t=JSON.stringify({merchantId:this.merchantId,totop:""});return e.AES.encrypt(t,this.clientSecret).toString()}getHeaders(){const e={"Content-Type":"application/json"};return this.accessToken&&(e.Authorization=`Bearer ${this.accessToken}`),e}async getAccessToken(){const e={clientId:this.clientId,encryptedPayload:this.getAuthPayload()},t=await fetch(`${this.domain}/auth/generate-auth-token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error(`Auth failed: ${t.status}`);const s=await t.json(),a=s?.result;if(!a?.access)throw new Error("Token missing in response");this.accessToken=a.access,this.refreshToken=a.refresh}async requestWithRetry(e,t,s=!0){const a=await fetch(e,t);if((401===a.status||403===a.status)&&s){await this.getAccessToken();const s={...t,headers:this.getHeaders()};return this.requestWithRetry(e,s,!1)}if(!a.ok){const e=new Error(a.statusText);throw e.status=a.status,e}return a.json()}}class i extends n{constructor(e){super(e)}async getBankConfiguration(e){this.accessToken||await this.getAccessToken();const t=new URLSearchParams({payeeId:e.payeeId,currency:e.currency,country:e.country}),s=`${this.domain}/payout/fiat/bank-configuration?${t.toString()}`,a=await this.requestWithRetry(s,{method:"GET",headers:this.getHeaders()}),r=new URLSearchParams({payeeId:e.payeeId}),n=`${this.domain}/payout/fiat/personal-field-values?${r.toString()}`,i=await this.requestWithRetry(n,{method:"GET",headers:this.getHeaders()}),o=a?.result??a,c=i?.result?.fields;if(c&&o){const e=Object.keys(c),t={};return Object.keys(o).forEach(s=>{t[s]=o[s].map(t=>(e.indexOf(t.name)>-1&&(t.acceptedValues=c[t.name]),t))}),console.debug("fetched personal field values and appended it"),t}return console.debug("no personal field values found"),o}async getStatus(e){this.accessToken||await this.getAccessToken();const t=new URLSearchParams({payeeId:e.payeeId,country:e.country,currency:e.currency}),s=`${this.domain}/payout/services?${t.toString()}`,a=await this.requestWithRetry(s,{method:"GET",headers:this.getHeaders()});return a?.result??a}async shouldShowExternalPayeeForm(e){this.accessToken||await this.getAccessToken();const t=new URLSearchParams({payeeId:e}),s=`${this.domain}/payout/user/create/external/check?${t.toString()}`,a=await this.requestWithRetry(s,{method:"GET",headers:this.getHeaders()});return a?.result??a}async createPayeeUserExternal(e){this.accessToken||await this.getAccessToken();const t=`${this.domain}/payout/user/create/external?payeeId=${e.payeeId}`,s=await this.requestWithRetry(t,{method:"POST",headers:this.getHeaders(),body:JSON.stringify({fName:e.fName,lName:e.lName,email:e.email,country:e.country})});return s?.result??s}async getPublicCountries(e){const t=`${this.domain}/payout/countries?payeeId=${e}`,s=await this.requestWithRetry(t,{method:"GET",headers:this.getHeaders()});return s?.result??s}async getCountries(e){this.accessToken||await this.getAccessToken();const t=new URLSearchParams;e.payeeId&&t.set("payeeId",e.payeeId),e.currency&&t.set("currency",e.currency);const s=`${this.domain}/payout/fiat/country${t.toString()?`?${t.toString()}`:""}`,a=await this.requestWithRetry(s,{method:"GET",headers:this.getHeaders()});return a?.result??a}async getCurrencies(e){this.accessToken||await this.getAccessToken();const t=new URLSearchParams({payeeId:e.payeeId});e.country&&t.set("country",e.country);const s=`${this.domain}/payout/fiat/currency?${t.toString()}`,a=await this.requestWithRetry(s,{method:"GET",headers:this.getHeaders()});return a?.result??a}async saveBankDetails(e,t){this.accessToken||await this.getAccessToken();const s=new URLSearchParams({payeeId:e,currency:t.currency,country:t.country}),a=`${this.domain}/payout/fiat/bank-configuration?${s.toString()}`,r=await this.requestWithRetry(a,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(t)});return r?.result??r}async deleteBankDetails(e){this.accessToken||await this.getAccessToken();const t=new URLSearchParams({payeeId:e.payeeId}),s=`${this.domain}/payout/fiat/bank/${encodeURIComponent(e.bankId)}?${t.toString()}`,a=await this.requestWithRetry(s,{method:"DELETE",headers:this.getHeaders()});return a?.result??a}async listBankDetails(e){this.accessToken||await this.getAccessToken();const t=new URLSearchParams({payeeId:e.payeeId}),s=`${this.domain}/payout/fiat/bank-detail?${t.toString()}`,a=await this.requestWithRetry(s,{method:"GET",headers:this.getHeaders()});return a?.result??a}async getTransferFee(e,t){this.accessToken||await this.getAccessToken();const s=new URLSearchParams({payeeId:e.payeeId,country:e.country,currency:e.currency}),a=`${this.domain}/payout/fiat/fees?${s.toString()}`,r=await this.requestWithRetry(a,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(t)});return r?.result??r}async transfer(e,t){this.accessToken||await this.getAccessToken();const s=new URLSearchParams({payeeId:e.payeeId,country:e.country,currency:e.currency}),a=`${this.domain}/payout/fiat/transfer?${s.toString()}`,r=await this.requestWithRetry(a,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(t)});return r?.result??r}async getTransferStatus(e,t){this.accessToken||await this.getAccessToken();const s=new URLSearchParams({payeeId:t}),a=`${this.domain}/payout/order/${encodeURIComponent(e)}?${s.toString()}`,r=await this.requestWithRetry(a,{method:"GET",headers:this.getHeaders()});return r?.result??r}async getPaymentMethods(e){this.accessToken||await this.getAccessToken();const t=new URLSearchParams({amount:e.amount});e.payeeId&&t.set("payeeId",e.payeeId),e.country&&t.set("country",e.country),e.currency&&t.set("currency",e.currency);const s=`${this.domain}/payout/fiat/payment-methods?${t.toString()}`,a=await this.requestWithRetry(s,{method:"GET",headers:this.getHeaders()});return a?.result??a}async getFileUploadUrl(e){this.accessToken||await this.getAccessToken();const t=new URLSearchParams({contentType:e.contentType});e.payeeId&&t.set("payeeId",e.payeeId);const s=`${this.domain}/payout/files/upload-url?${t.toString()}`,a=await this.requestWithRetry(s,{method:"GET",headers:this.getHeaders()});return a?.result??a}async getComplianceStatus(e){this.accessToken||await this.getAccessToken();const t=new URLSearchParams({country:e.country,service:e.service});e.destinationRecordId&&t.set("destinationRecordId",e.destinationRecordId),e.payeeId&&t.set("payeeId",e.payeeId);const s=`${this.domain}/payout/compliance-status?${t.toString()}`,a=await this.requestWithRetry(s,{method:"GET",headers:this.getHeaders()});return a?.result??a}}class o extends n{constructor(e){super(e)}async getCurrencies(e){this.accessToken||await this.getAccessToken();const t=`${this.domain}/payout/currencies?payeeId=${encodeURIComponent(e)}`,s=await this.requestWithRetry(t,{method:"GET",headers:this.getHeaders()});return s?.result}async checkAddress(e){this.accessToken||await this.getAccessToken();return await this.requestWithRetry(`${this.domain}/payout/know-your-address`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(e)})}async getTransferFee(e,t){this.accessToken||await this.getAccessToken();const s=`${this.domain}/payout/fee?payeeId=${encodeURIComponent(e)}`,a=await this.requestWithRetry(s,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(t)});return a?.result}async checkTransfer(e,t){this.accessToken||await this.getAccessToken();const s=`${this.domain}/payout/withdraw-check?payeeId=${encodeURIComponent(e)}`,a=await this.requestWithRetry(s,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(t)});return a?.result}async transfer(e,t){this.accessToken||await this.getAccessToken();const s=`${this.domain}/payout/withdraw?payeeId=${encodeURIComponent(e)}`,a=await this.requestWithRetry(s,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(t)});return a?.result}async getTransferStatus(e,t){this.accessToken||await this.getAccessToken();const s=new URLSearchParams({payeeId:t}),a=`${this.domain}/payout/order/${encodeURIComponent(e)}?${s.toString()}`,r=await this.requestWithRetry(a,{method:"GET",headers:this.getHeaders()});return r?.result??r}}class c extends n{constructor(e){super(e)}async invitePayee(e){this.accessToken||await this.getAccessToken();const t=await this.requestWithRetry(`${this.domain}/payout/external/payee`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(e)});return t?.result}async submitPayeeKyc(e){this.accessToken||await this.getAccessToken();const t=await this.requestWithRetry(`${this.domain}/compliance/kyc`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(e)});return t?.result}async getPayeeBalance(e){this.accessToken||await this.getAccessToken();const t=await this.requestWithRetry(`${this.domain}/payout-admin/payee/${encodeURIComponent(e)}/balance`,{method:"GET",headers:this.getHeaders()});return t?.result}async getBalance(){this.accessToken||await this.getAccessToken();return await this.requestWithRetry(`${this.domain}/payout-admin/balance`,{method:"GET",headers:this.getHeaders()})}async getRunningBalance(){this.accessToken||await this.getAccessToken();return await this.requestWithRetry(`${this.domain}/payout-admin/running-balance`,{method:"GET",headers:this.getHeaders()})}async createTransferAllocation(e){this.accessToken||await this.getAccessToken();const t=await this.requestWithRetry(`${this.domain}/payout-admin/transfer`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(e)});return t?.result??t}async allocateTransfer(e,t){this.accessToken||await this.getAccessToken();const s=`${this.domain}/payout-admin/transfer/${encodeURIComponent(e)}/allocate`,a=await this.requestWithRetry(s,{method:"POST",headers:this.getHeaders(),body:JSON.stringify(t)});return a?.result??a}}class h{static verify(e){try{const{data:s,signature:a}=e||{};if(!s||!a)return!1;const r=t.createVerify("RSA-SHA256");return r.update(s),r.verify("-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2e4stIYooUrKHVQmwztC\n/l0YktX6uz4bE1iDtA2qu4OaXx+IKkwBWa0hO2mzv6dAoawyzxa2jmN01vrpMkMj\nrB+Dxmoq7tRvRTx1hXzZWaKuv37BAYosOIKjom8S8axM1j6zPkX1zpMLE8ys3dUX\nFN5Dl/kBfeCTwGRV4PZjP4a+QwgFRzZVVfnpcRI/O6zhfkdlRah8MrAPWYSoGBpG\nCPiAjUeHO/4JA5zZ6IdfZuy/DKxbcOlt9H+z14iJwB7eVUByoeCE+Bkw+QE4msKs\naIn4xl9GBoyfDZKajTzL50W/oeoE1UcuvVfaULZ9DWnHOy6idCFH1WbYDxYYIWLi\nAQIDAQAB\n-----END PUBLIC KEY-----",a,"base64")}catch(e){return console.error("Payout signature verification failed:",e),!1}}}const d="PAYOUT",u={PayeeAdded:"PayeeAdded",PayeeKycStarted:"PayeeKycStarted",PayeeKycStatusChange:"PayeeKycStatusChange",PayeeFundAllocated:"PayeeFundAllocated",PayoutStarted:"PayoutStarted",PayoutStatusChange:"PayoutStatusChange"};class y{fiat;crypto;admin;constructor(e){this.fiat=new i(e),this.crypto=new o(e),this.admin=new c(e)}}export{u as PAYOUT_WEBHOOK_EVENTS,d as PAYOUT_WEBHOOK_EVENT_TYPE,h as PayoutWebhookVerifier,a as Rocketfuel,y as RocketfuelPayouts};
2
2
  //# sourceMappingURL=index.js.map
@@ -36,7 +36,7 @@ export declare class FiatPayoutClient extends PayoutBase {
36
36
  * This is a public endpoint that does not require authentication.
37
37
  * Maps to: GET /api/payout/countries
38
38
  */
39
- getPublicCountries(): Promise<Country[]>;
39
+ getPublicCountries(payeeId: string): Promise<Country[]>;
40
40
  /**
41
41
  * Get list of supported payout countries.
42
42
  * Maps to: GET /api/payout/fiat/country?[payeeId={payeeId}][&currency={currency}]
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@rkfl/transact-server",
3
3
  "main": "./dist/index.js",
4
4
  "type": "module",
5
- "version": "2.2.0-alpha.0",
5
+ "version": "2.3.0-alpha.0",
6
6
  "scripts": {
7
7
  "build": "rollup -c",
8
8
  "npm:login": "npm login",