@rkfl/transact-server 1.0.5 → 1.0.7
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/README.md +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/package.json +9 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ A secure and minimal Node.js SDK to interact with Rocketfuel payment APIs. (This
|
|
|
8
8
|
npm i @rkfl/transact-server
|
|
9
9
|
```
|
|
10
10
|
## Documentation
|
|
11
|
-
Click here for more detailed [Documentation](https://rocketfuel
|
|
11
|
+
Click here for more detailed [Documentation](https://docs.rocketfuel.inc/plug-ins-and-sdks/javascript-js/rocketfuel-sdk-nodejs)
|
|
12
12
|
## Usage
|
|
13
13
|
|
|
14
14
|
### Create order
|
package/dist/index.d.ts
CHANGED
|
@@ -9,5 +9,6 @@ export declare class Rocketfuel {
|
|
|
9
9
|
});
|
|
10
10
|
createOrder(payload: CartData): Promise<any>;
|
|
11
11
|
transactionLookup(txId: string, type?: 'ORDERID' | 'TXID'): Promise<any>;
|
|
12
|
+
verifyAgeVerification(auditId: string): Promise<any>;
|
|
12
13
|
verifyWebhookSignature(body: any): boolean;
|
|
13
14
|
}
|
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"]}#
|
|
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};
|
|
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.
|
|
5
|
+
"version": "1.0.7",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "rollup -c",
|
|
8
8
|
"npm:login": "npm login",
|
|
@@ -13,6 +13,14 @@
|
|
|
13
13
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
14
14
|
},
|
|
15
15
|
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"import": "./dist/index.js",
|
|
19
|
+
"require": "./dist/index.js",
|
|
20
|
+
"default": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.ts"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
16
24
|
"files": [
|
|
17
25
|
"dist"
|
|
18
26
|
],
|