@rkfl/transact-server 1.0.7 → 1.0.8

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.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import t from"crypto-js";import*as e 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 r{#t;#e;#s;#r;#n=null;#a=null;constructor({clientId:t,clientSecret:e,merchantId:r,environment:n}){this.#t=t,this.#e=e,this.#s=r,this.#r=s[n||"production"]}#i(){const e=JSON.stringify({merchantId:this.#s,totop:""});return t.AES.encrypt(e,this.#e).toString()}#o(){const t={"Content-Type":"application/json"};return this.#n&&(t.Authorization=`Bearer ${this.#n}`),t}async#c(){const t={clientId:this.#t,encryptedPayload:this.#i()},e=await fetch(`${this.#r}/auth/generate-auth-token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!e.ok)throw new Error(`Auth failed: ${e.status}`);const s=await e.json(),r=s?.result;if(!r?.access)throw new Error("Token missing in response");this.#n=r.access,this.#a=r.refresh}async#h(t,e,s=!0){const r=await fetch(t,e);if(403===r.status&&s){console.warn(`Received 403, refreshing token and retrying: ${t}`),await this.#c();const s={...e,headers:this.#o()};return this.#h(t,s,!1)}if(!r.ok){const t=new Error(r.statusText);throw t.status=r.status,t}return r.json()}async createOrder(t){this.#n||await this.#c();const e=await this.#h(`${this.#r}/hosted-page`,{method:"POST",headers:this.#o(),body:JSON.stringify(t)});return{uuid:e?.result?.uuid}}async transactionLookup(t,e="ORDERID"){this.#n||await this.#c();const s=await this.#h(`${this.#r}/purchase/transactionLookup`,{method:"POST",headers:this.#o(),body:JSON.stringify({txId:t,type:e})});return s?.result}async verifyAgeVerification(t){this.#n||await this.#c();const e=await this.#h(`${this.#r}/merchant/audit/${t}`,{method:"GET",headers:this.#o()});return e?.result}verifyWebhookSignature(t){try{const{data:{data:s},signature:r}=t,n=e.createVerify("RSA-SHA256");return n.update(s),n.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-----",r,"base64")}catch(t){return console.error("Signature verification failed:",t),!1}}}export{r as Rocketfuel};
1
+ import t from"crypto-js";import*as e 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 r{#t;#e;#s;#r;#a=null;#n=null;constructor({clientId:t,clientSecret:e,merchantId:r,environment:a}){this.#t=t,this.#e=e,this.#s=r,this.#r=s[a||"production"]}#i(){const e=JSON.stringify({merchantId:this.#s,totop:""});return t.AES.encrypt(e,this.#e).toString()}#o(){const t={"Content-Type":"application/json"};return this.#a&&(t.Authorization=`Bearer ${this.#a}`),t}async#c(){const t={clientId:this.#t,encryptedPayload:this.#i()},e=await fetch(`${this.#r}/auth/generate-auth-token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!e.ok)throw new Error(`Auth failed: ${e.status}`);const s=await e.json(),r=s?.result;if(!r?.access)throw new Error("Token missing in response");this.#a=r.access,this.#n=r.refresh}async#h(t,e,s=!0){const r=await fetch(t,e);if((401===r.status||403===r.status)&&s){await this.#c();const s={...e,headers:this.#o()};return this.#h(t,s,!1)}if(!r.ok){const t=new Error(r.statusText);throw t.status=r.status,t}return r.json()}async createOrder(t){this.#a||await this.#c();const e=await this.#h(`${this.#r}/hosted-page`,{method:"POST",headers:this.#o(),body:JSON.stringify(t)});return{uuid:e?.result?.uuid}}async transactionLookup(t,e="ORDERID"){this.#a||await this.#c();const s=await this.#h(`${this.#r}/purchase/transactionLookup`,{method:"POST",headers:this.#o(),body:JSON.stringify({txId:t,type:e})});return s?.result}async verifyAgeVerification(t){this.#a||await this.#c();const e=await this.#h(`${this.#r}/merchant/audit/${t}`,{method:"GET",headers:this.#o()});return e?.result}verifyWebhookSignature(t){try{const{data:{data:s},signature:r}=t,a=e.createVerify("RSA-SHA256");return a.update(s),a.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-----",r,"base64")}catch(t){return console.error("Signature verification failed:",t),!1}}}export{r as Rocketfuel};
2
2
  //# sourceMappingURL=index.js.map
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": "1.0.7",
5
+ "version": "1.0.8",
6
6
  "scripts": {
7
7
  "build": "rollup -c",
8
8
  "npm:login": "npm login",