gamemoney 4.0.0 → 4.2.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/README.md +38 -0
- package/index.d.ts +4 -0
- package/index.js +8 -1
- package/package.json +15 -15
- package/utils.js +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
[GameMoney](https://gmpays.com/) API wrapper for Node.js
|
|
4
|
+
|
|
5
|
+
Full API documentation [here](https://cp.gmpays.com/apidoc)
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
```sh
|
|
9
|
+
$ npm install gamemoney
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
### Initialization
|
|
15
|
+
```typescript
|
|
16
|
+
import fs from 'fs'
|
|
17
|
+
import GameMoney from 'gamemoney'
|
|
18
|
+
|
|
19
|
+
const gm = new GameMoney({
|
|
20
|
+
project: 42,
|
|
21
|
+
hmacPrivateKey: 'test',
|
|
22
|
+
|
|
23
|
+
// Optional. But to make checkouts must be specified
|
|
24
|
+
rsaPrivateKey: {
|
|
25
|
+
key: fs.readFileSync('./private.pem').toString(),
|
|
26
|
+
passphrase: '123' // Optional
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
// OR:
|
|
30
|
+
// rsaPrivateKey: Buffer.from(
|
|
31
|
+
// process.env.GM_RSA_PRIVATE_KEY ?? '',
|
|
32
|
+
// 'base64',
|
|
33
|
+
// )
|
|
34
|
+
})
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Examples
|
|
38
|
+
See examples in [src/examples](https://github.com/gamemoney-ps/gamemoney-node-sdk/tree/master/src/examples) directory
|
package/index.d.ts
CHANGED
|
@@ -330,6 +330,7 @@ export interface CheckoutNotification {
|
|
|
330
330
|
currency_user: string;
|
|
331
331
|
time: string;
|
|
332
332
|
signature: string;
|
|
333
|
+
refunds?: Refund[];
|
|
333
334
|
}
|
|
334
335
|
export interface TransferNotification {
|
|
335
336
|
amount: number;
|
|
@@ -342,6 +343,9 @@ export interface TransferNotification {
|
|
|
342
343
|
signature: string;
|
|
343
344
|
}
|
|
344
345
|
declare type Payload = Record<string, unknown>;
|
|
346
|
+
export declare class GameMoneyError extends Error {
|
|
347
|
+
constructor(message: string);
|
|
348
|
+
}
|
|
345
349
|
export default class GameMoney {
|
|
346
350
|
private readonly config;
|
|
347
351
|
private readonly got;
|
package/index.js
CHANGED
|
@@ -5,6 +5,12 @@ export var SignType;
|
|
|
5
5
|
SignType["HMAC"] = "HMAC";
|
|
6
6
|
SignType["RSA"] = "RSA";
|
|
7
7
|
})(SignType || (SignType = {}));
|
|
8
|
+
export class GameMoneyError extends Error {
|
|
9
|
+
constructor(message) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = 'GameMoneyError';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
8
14
|
export default class GameMoney {
|
|
9
15
|
config;
|
|
10
16
|
got = got.extend({
|
|
@@ -13,6 +19,7 @@ export default class GameMoney {
|
|
|
13
19
|
});
|
|
14
20
|
constructor(config) {
|
|
15
21
|
this.config = config;
|
|
22
|
+
this.config = config;
|
|
16
23
|
}
|
|
17
24
|
async request(url, payload = {}, signType = SignType.HMAC) {
|
|
18
25
|
const form = {
|
|
@@ -41,7 +48,7 @@ export default class GameMoney {
|
|
|
41
48
|
throw new Error(`Wrong rand parameter: ${response.rand}`);
|
|
42
49
|
}
|
|
43
50
|
if (response.state === 'error') {
|
|
44
|
-
throw new
|
|
51
|
+
throw new GameMoneyError(response.error);
|
|
45
52
|
}
|
|
46
53
|
return response;
|
|
47
54
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gamemoney",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "GameMoney API wrapper for Node.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gamemoney",
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
"scripts": {
|
|
34
34
|
"prebuild": "rm -rf .build",
|
|
35
35
|
"build": "tsc",
|
|
36
|
-
"postbuild": "cp -r package*.json .npmignore ./src/certs .build",
|
|
36
|
+
"postbuild": "cp -r package*.json .npmignore ./src/certs README.md .build",
|
|
37
37
|
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
|
|
38
38
|
"lint": "xo",
|
|
39
39
|
"lint:fix": "xo --fix"
|
|
40
40
|
},
|
|
41
41
|
"lint-staged": {
|
|
42
|
-
"*.ts": "xo
|
|
42
|
+
"*.ts": "xo"
|
|
43
43
|
},
|
|
44
44
|
"jest": {
|
|
45
45
|
"testMatch": [
|
|
@@ -62,24 +62,24 @@
|
|
|
62
62
|
},
|
|
63
63
|
"prettier": "@onmoon/prettier-config",
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@onmoon/eslint-config": "^1.0.
|
|
65
|
+
"@onmoon/eslint-config": "^1.0.11",
|
|
66
66
|
"@onmoon/prettier-config": "^1.0.2",
|
|
67
|
-
"@onmoon/tsconfigs": "^
|
|
67
|
+
"@onmoon/tsconfigs": "^2.0.0",
|
|
68
68
|
"@types/body-parser": "^1.19.2",
|
|
69
69
|
"@types/express": "^4.17.13",
|
|
70
|
-
"@types/jest": "^27.
|
|
71
|
-
"@types/node": "^17.0.
|
|
70
|
+
"@types/jest": "^27.5.1",
|
|
71
|
+
"@types/node": "^17.0.35",
|
|
72
72
|
"@types/uuid": "^8.3.4",
|
|
73
|
-
"body-parser": "^1.
|
|
74
|
-
"express": "^4.
|
|
75
|
-
"husky": "^
|
|
76
|
-
"lint-staged": "^12.
|
|
77
|
-
"ts-jest": "^
|
|
78
|
-
"typescript": "^4.
|
|
73
|
+
"body-parser": "^1.20.0",
|
|
74
|
+
"express": "^4.18.1",
|
|
75
|
+
"husky": "^8.0.1",
|
|
76
|
+
"lint-staged": "^12.4.1",
|
|
77
|
+
"ts-jest": "^28.0.2",
|
|
78
|
+
"typescript": "^4.6.4",
|
|
79
79
|
"uuid": "^8.3.2",
|
|
80
|
-
"xo": "^0.
|
|
80
|
+
"xo": "^0.49.0"
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"got": "^12.0.
|
|
83
|
+
"got": "^12.0.4"
|
|
84
84
|
}
|
|
85
85
|
}
|
package/utils.js
CHANGED
|
@@ -2,7 +2,7 @@ import { URL } from 'node:url';
|
|
|
2
2
|
import crypto from 'node:crypto';
|
|
3
3
|
import fs from 'node:fs';
|
|
4
4
|
const publicCert = fs
|
|
5
|
-
.readFileSync(new URL('
|
|
5
|
+
.readFileSync(new URL('certs/gm.crt', import.meta.url))
|
|
6
6
|
.toString();
|
|
7
7
|
export function parametersToString(body) {
|
|
8
8
|
let parametersString = '';
|