@yosle/tropipayjs 0.2.2 → 0.2.3
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/SECURITY.md +43 -0
- package/index.d.ts +2 -1
- package/index.js +6 -13
- package/package.json +10 -11
- package/rollup.config.js +3 -4
- package/tsconfig.json +2 -2
package/SECURITY.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Supply Chain Security Plan
|
|
2
|
+
|
|
3
|
+
## 1. Lockfile Integrity
|
|
4
|
+
- Always commit `package-lock.json` — it pins exact sub-dependency versions
|
|
5
|
+
- Verify integrity: `npm audit signatures` after install (requires npm 9+)
|
|
6
|
+
|
|
7
|
+
## 2. Automated Scanning
|
|
8
|
+
```yaml
|
|
9
|
+
# CI steps
|
|
10
|
+
- run: npm audit --audit-level=high # fail on high/critical known CVEs
|
|
11
|
+
- run: npx socket-cli scan # detect protestware, typo-squatting, obfuscation
|
|
12
|
+
```
|
|
13
|
+
- [Socket.dev](https://socket.dev) — free tier detects behavioral risks (not just CVEs)
|
|
14
|
+
- [Snyk](https://snyk.io) — broader CVE coverage, integrates with GitHub
|
|
15
|
+
|
|
16
|
+
## 3. Dependency Updates
|
|
17
|
+
- Enable **Dependabot** or **Renovate** — auto-create PRs for security patches
|
|
18
|
+
- Review every new dependency before adding: check downloads, maintenance, publisher
|
|
19
|
+
|
|
20
|
+
## 4. Overrides for Transitive Dependencies
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"overrides": {
|
|
24
|
+
"axios": "1.18.1",
|
|
25
|
+
"semver": "^7.6.0"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
Use `overrides` to force-patch transitive deps when upstream is slow to release.
|
|
30
|
+
|
|
31
|
+
## 5. Minimal Surface Area
|
|
32
|
+
- Fewer dependencies = fewer attack vectors
|
|
33
|
+
- Regularly audit with `npm ls --depth=0` and remove unused packages
|
|
34
|
+
|
|
35
|
+
## 6. SBOM Generation
|
|
36
|
+
```bash
|
|
37
|
+
npm sbom --sbom-format cyclonedx > sbom.json
|
|
38
|
+
```
|
|
39
|
+
Generate a Software Bill of Materials for compliance and tracking.
|
|
40
|
+
|
|
41
|
+
## 7. Package Provenance
|
|
42
|
+
- Prefer packages with [provenance attestations](https://docs.npmjs.com/generating-provenance-statements) (npm publish --provenance)
|
|
43
|
+
- Check publisher reputation and maintainer count before adding
|
package/index.d.ts
CHANGED
|
@@ -494,4 +494,5 @@ declare class ServerSideUtils {
|
|
|
494
494
|
|
|
495
495
|
declare const SERVER_MODE: ServerMode$1;
|
|
496
496
|
|
|
497
|
-
export {
|
|
497
|
+
export { ClientSideUtils, MAX_IMAGE_SIZE_MB, SERVER_MODE, ServerSideUtils, Tropipay };
|
|
498
|
+
export type { AccountBalance, AccountDeposits, Country, Deposit, HookEventType, HookTargetType, LoginError, LoginResponse, MediationPaymentCardConfig, PaymentLink, PaymentLinkPayload, RefundResponse, ServerMode$1 as ServerMode, TropipayConfig, TropipayCredentials, UserHook, UserHookSubscribed };
|
package/index.js
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var axios = require('axios');
|
|
6
4
|
var crypto = require('crypto');
|
|
7
5
|
var fs = require('fs/promises');
|
|
8
6
|
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
function _interopNamespace(e) {
|
|
12
|
-
if (e && e.__esModule) return e;
|
|
7
|
+
function _interopNamespaceDefault(e) {
|
|
13
8
|
var n = Object.create(null);
|
|
14
9
|
if (e) {
|
|
15
10
|
Object.keys(e).forEach(function (k) {
|
|
@@ -22,13 +17,11 @@ function _interopNamespace(e) {
|
|
|
22
17
|
}
|
|
23
18
|
});
|
|
24
19
|
}
|
|
25
|
-
n
|
|
20
|
+
n.default = e;
|
|
26
21
|
return Object.freeze(n);
|
|
27
22
|
}
|
|
28
23
|
|
|
29
|
-
var
|
|
30
|
-
var crypto__namespace = /*#__PURE__*/_interopNamespace(crypto);
|
|
31
|
-
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
24
|
+
var crypto__namespace = /*#__PURE__*/_interopNamespaceDefault(crypto);
|
|
32
25
|
|
|
33
26
|
function handleExceptions(error) {
|
|
34
27
|
if (error instanceof axios.AxiosError) {
|
|
@@ -520,7 +513,7 @@ class Tropipay {
|
|
|
520
513
|
const tpp_env = this.serverMode === "Production"
|
|
521
514
|
? "https://www.tropipay.com"
|
|
522
515
|
: "https://tropipay-dev.herokuapp.com";
|
|
523
|
-
this.request =
|
|
516
|
+
this.request = axios.create({
|
|
524
517
|
baseURL: config.customTropipayUrl || tpp_env,
|
|
525
518
|
headers: {
|
|
526
519
|
"Content-Type": "application/json",
|
|
@@ -885,7 +878,7 @@ class ServerSideUtils {
|
|
|
885
878
|
* @return {Promise<string>} a Promise that resolves to the base64 representation of the file content
|
|
886
879
|
*/
|
|
887
880
|
static async fileToBase64(filepath) {
|
|
888
|
-
const contents = await
|
|
881
|
+
const contents = await fs.readFile(filepath);
|
|
889
882
|
let base64content = contents.toString("base64");
|
|
890
883
|
const ext = filepath.split(".").pop();
|
|
891
884
|
return `data:image/${ext};base64,` + base64content;
|
|
@@ -897,7 +890,7 @@ class ServerSideUtils {
|
|
|
897
890
|
* @return {Promise<string>} the base64 representation of the file
|
|
898
891
|
*/
|
|
899
892
|
static async getBase64FromFileUrl(url) {
|
|
900
|
-
const response = await
|
|
893
|
+
const response = await axios.get(url, {
|
|
901
894
|
responseType: "arraybuffer",
|
|
902
895
|
maxRedirects: 5,
|
|
903
896
|
});
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yosle/tropipayjs",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Javascript / Typescript SDK for the Tropipay API",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "jest --passWithNoTests --updateSnapshot --coverage",
|
|
8
|
-
"_clear": "rimraf src/dist
|
|
8
|
+
"_clear": "rimraf src/dist",
|
|
9
9
|
"_tsc": "tsc",
|
|
10
10
|
"_make-bundle": "rollup --config",
|
|
11
11
|
"build": "npm run _clear && npm run _tsc && npm run _make-bundle"
|
|
@@ -28,22 +28,21 @@
|
|
|
28
28
|
"author": "Yosleivy Baez Acosta <yosle007@gmail.com>",
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"axios": "^1.
|
|
32
|
-
"tslib": "^2.
|
|
31
|
+
"axios": "^1.18.1",
|
|
32
|
+
"tslib": "^2.8.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@rollup/plugin-typescript": "^
|
|
35
|
+
"@rollup/plugin-typescript": "^12.3.0",
|
|
36
36
|
"@types/jest": "^29.5.12",
|
|
37
37
|
"@types/node": "^20.12.7",
|
|
38
38
|
"@types/tough-cookie": "^4.0.5",
|
|
39
39
|
"babel-jest": "^29.7.0",
|
|
40
40
|
"jest": "^29.7.0",
|
|
41
|
-
"rimraf": "^
|
|
42
|
-
"rollup": "^
|
|
43
|
-
"rollup-plugin-dts": "^4.
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"typescript": "^5.4.5"
|
|
41
|
+
"rimraf": "^6.1.3",
|
|
42
|
+
"rollup": "^4.62.2",
|
|
43
|
+
"rollup-plugin-dts": "^6.4.1",
|
|
44
|
+
"ts-jest": "^29.4.11",
|
|
45
|
+
"typescript": "^6.0.3"
|
|
47
46
|
},
|
|
48
47
|
"funding": {
|
|
49
48
|
"type": "individual",
|
package/rollup.config.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import dts from "rollup-plugin-dts";
|
|
1
|
+
import { dts } from "rollup-plugin-dts";
|
|
2
|
+
|
|
4
3
|
const config = [
|
|
5
4
|
{
|
|
6
5
|
input: "dist/index.js",
|
|
@@ -10,7 +9,6 @@ const config = [
|
|
|
10
9
|
sourcemap: true,
|
|
11
10
|
},
|
|
12
11
|
external: ["axios", "crypto", "fs/promises"],
|
|
13
|
-
plugins: [typescript()],
|
|
14
12
|
},
|
|
15
13
|
{
|
|
16
14
|
input: "dist/index.d.ts",
|
|
@@ -21,4 +19,5 @@ const config = [
|
|
|
21
19
|
plugins: [dts()],
|
|
22
20
|
},
|
|
23
21
|
];
|
|
22
|
+
|
|
24
23
|
export default config;
|
package/tsconfig.json
CHANGED
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
/* Modules */
|
|
25
25
|
"module": "esnext" /* Specify what module code is generated. */,
|
|
26
26
|
"rootDir": "./src" /* Specify the root folder within your source files. */,
|
|
27
|
-
"moduleResolution": "
|
|
27
|
+
"moduleResolution": "bundler" /* Specify how TypeScript looks up a file from a given module specifier. */,
|
|
28
28
|
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
29
29
|
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
30
30
|
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
31
31
|
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
|
32
|
-
|
|
32
|
+
"types": ["node", "jest"], /* Specify type package names to be included without being referenced in a source file. */
|
|
33
33
|
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
34
34
|
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
|
35
35
|
// "resolveJsonModule": true, /* Enable importing .json files. */
|