@staxpayments/staxpayments-js 2.30.18
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/.babelrc +8 -0
- package/LICENSE +21 -0
- package/README.md +1192 -0
- package/dist/blockchyp-js-all.js +48535 -0
- package/dist/blockchyp-js-all.min.js +34 -0
- package/dist/client.js +972 -0
- package/dist/cryptoutils.js +111 -0
- package/dist/global.js +13 -0
- package/dist/mappers.js +75 -0
- package/dist/payments.js +94 -0
- package/dist/staxpaymentsclient.js +74 -0
- package/dist/terminals.js +308 -0
- package/eslint.config.mjs +34 -0
- package/index.js +4 -0
- package/package.json +69 -0
- package/spec/CryptoSpec.js +46 -0
- package/spec/SanitySpec.js +27 -0
- package/spec/support/jasmine.json +11 -0
- package/src/client.js +707 -0
- package/src/cryptoutils.js +95 -0
- package/src/global.js +6 -0
- package/src/mappers.js +72 -0
- package/src/payments.js +41 -0
- package/src/staxpaymentsclient.js +54 -0
- package/src/terminals.js +104 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export default [
|
|
2
|
+
{
|
|
3
|
+
languageOptions: {
|
|
4
|
+
ecmaVersion: 2020,
|
|
5
|
+
sourceType: "module",
|
|
6
|
+
globals: {
|
|
7
|
+
// Node.js globals
|
|
8
|
+
process: "readonly",
|
|
9
|
+
Buffer: "readonly",
|
|
10
|
+
__dirname: "readonly",
|
|
11
|
+
__filename: "readonly",
|
|
12
|
+
module: "readonly",
|
|
13
|
+
require: "readonly",
|
|
14
|
+
exports: "readonly",
|
|
15
|
+
console: "readonly",
|
|
16
|
+
// Browser globals
|
|
17
|
+
window: "readonly",
|
|
18
|
+
document: "readonly",
|
|
19
|
+
navigator: "readonly",
|
|
20
|
+
location: "readonly",
|
|
21
|
+
fetch: "readonly",
|
|
22
|
+
XMLHttpRequest: "readonly",
|
|
23
|
+
setTimeout: "readonly",
|
|
24
|
+
setInterval: "readonly",
|
|
25
|
+
clearTimeout: "readonly",
|
|
26
|
+
clearInterval: "readonly"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
rules: {
|
|
30
|
+
"new-cap": 0,
|
|
31
|
+
"comma-dangle": ["error", "only-multiline"]
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
];
|
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@staxpayments/staxpayments-js",
|
|
3
|
+
"version": "2.30.18",
|
|
4
|
+
"description": "Stax Payments JavaScript Client",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"es6",
|
|
7
|
+
"payments",
|
|
8
|
+
"blockchain"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://github.com/blockchyp/staxpayments-js#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/blockchyp/staxpayments-js/issues"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/blockchyp/staxpayments-js.git"
|
|
17
|
+
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"author": "jeffreydpayne",
|
|
20
|
+
"type": "commonjs",
|
|
21
|
+
"main": "index.js",
|
|
22
|
+
"files": [
|
|
23
|
+
"src/",
|
|
24
|
+
"spec/",
|
|
25
|
+
"itest/",
|
|
26
|
+
"dist/",
|
|
27
|
+
".babelrc",
|
|
28
|
+
"eslint.config.mjs"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "eslint src/* && babel src -d dist",
|
|
32
|
+
"prod": "npm run build && browserify dist/global.js -o dist/blockchyp-js-all.js && npx terser dist/blockchyp-js-all.js -o dist/blockchyp-js-all.min.js",
|
|
33
|
+
"test": "babel src -d dist && jasmine",
|
|
34
|
+
"prepare": "npm run prod"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@babel/runtime": "^7.27.0",
|
|
38
|
+
"@noble/curves": "^1.6.0",
|
|
39
|
+
"@noble/hashes": "^1.5.0",
|
|
40
|
+
"aes-js": "^3.1.1",
|
|
41
|
+
"axios": "^1.15.0",
|
|
42
|
+
"base-64": "^0.1.0",
|
|
43
|
+
"base32": "0.0.7",
|
|
44
|
+
"BigInt": "^5.5.3",
|
|
45
|
+
"bn.js": "^4.12.2",
|
|
46
|
+
"cached-path-relative": "^1.1.0",
|
|
47
|
+
"glob": "^13.0.0",
|
|
48
|
+
"https-browserify": "^1.0.0",
|
|
49
|
+
"moment": "^2.30.1"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@babel/cli": "^7.27.0",
|
|
53
|
+
"@babel/core": "^7.27.0",
|
|
54
|
+
"@babel/plugin-transform-runtime": "^7.27.0",
|
|
55
|
+
"@babel/preset-env": "^7.27.0",
|
|
56
|
+
"babelify": "^10.0.0",
|
|
57
|
+
"browserify": "^17.0.0",
|
|
58
|
+
"eslint": "^9.36.0",
|
|
59
|
+
"fs": "0.0.1-security",
|
|
60
|
+
"is-windows": "^1.0.2",
|
|
61
|
+
"jasmine": "^3.1.0",
|
|
62
|
+
"jasmine-promises": "^0.4.1",
|
|
63
|
+
"terser": "^5.36.0",
|
|
64
|
+
"uuid": "^3.3.3"
|
|
65
|
+
},
|
|
66
|
+
"overrides": {
|
|
67
|
+
"follow-redirects": "^1.16.0"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
describe("Crypto", function() {
|
|
2
|
+
var Crypto = require('../dist/cryptoutils.js').default;
|
|
3
|
+
|
|
4
|
+
console.log(Crypto)
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
it("Should Exist", function() {
|
|
8
|
+
expect(Crypto).toBeDefined();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("Should Generate Valid Headers", function() {
|
|
12
|
+
let creds = {
|
|
13
|
+
apiKey: "SGLATIFZD7PIMLAQJ2744MOEGI",
|
|
14
|
+
bearerToken: "FI2SWNNJHJVO6DBZEF26YEHHMY",
|
|
15
|
+
signingKey: "c3a8214c318dd470b0107d6c111f086b60ad695aaeb598bf7d1032eee95339a0"
|
|
16
|
+
}
|
|
17
|
+
headers = Crypto.generateGatewayHeaders(creds)
|
|
18
|
+
console.log(JSON.stringify(headers))
|
|
19
|
+
expect(headers).toBeDefined();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("Should Decrypt Go Encoded AES", function () {
|
|
23
|
+
let goCipher = '14b4e146a46ca9581d0900590b5d4bb9b945e7d3574834d239e9a695bc4ad5a7a7d05bc0e677f34cb8f125844b82a58c40ce2d1b07d44efe5a87a2dfc9cdd6d4'
|
|
24
|
+
let key = '7ef938ebbd24808f800bb368a4b97ba7'
|
|
25
|
+
|
|
26
|
+
let expectedPlainText = 'The quick brown fox jumped over the lazy dog.'
|
|
27
|
+
|
|
28
|
+
let plainText = Crypto.decrypt(key, goCipher)
|
|
29
|
+
|
|
30
|
+
expect(plainText).toBe(expectedPlainText)
|
|
31
|
+
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
it("Should Compute SHA 256 Hashes", function () {
|
|
36
|
+
let msg = 'f181167e704a9d06d66a2299b67882da7133d120c789e57d44041fa2a84ccad805a9f64788a905ac8734b990552c19070e18c09363b832680594b9aaa1dfc987179225d3cea9c8086aeaa04b3f72eb9fcf674dc6efd7ce158628b274677f0164beaf9eb0f54283b3fb7e592118db27069e231d1e4a3a500784ed123931db8240b7bbb99618b78348491bebe370b7850c459fb5390fb126b58c2212729d1e35c99880ca68e066949f03e6e56e261d15892828eddf250120e336a3580b5158ab32f5415bfce9ebeec70ef1e7bc8f50eec349d2175b9ec7dc4b6dfdc2201f4a55edf8becb860419871732c994e829caf7793ed695ca094a9154cb343659269addcf'
|
|
37
|
+
|
|
38
|
+
let expectedHash = 'f04e71b08dd61a4b9b88e695f09e4688b1d54dd0930450b52444bcd961b6ec6d'
|
|
39
|
+
|
|
40
|
+
let hash = Crypto.sha256Hash(msg)
|
|
41
|
+
|
|
42
|
+
expect(hash).toBe(expectedHash)
|
|
43
|
+
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
describe("SanityTest", function() {
|
|
2
|
+
var StaxPayments = require('../index.js');
|
|
3
|
+
var sdk = new StaxPayments.StaxPaymentsClient(new StaxPayments.StaxApiCredentials('<your-stax-bearer-token>'));
|
|
4
|
+
|
|
5
|
+
it("Should Exist", function() {
|
|
6
|
+
expect(sdk).toBeDefined();
|
|
7
|
+
expect(sdk.payments).toBeDefined();
|
|
8
|
+
expect(sdk.terminals).toBeDefined();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("Should Fetch Heatbeat", function(done) {
|
|
12
|
+
sdk.setGatewayHost('https://api.blockchyp.com/');
|
|
13
|
+
sdk.heartbeat()
|
|
14
|
+
.then(function (response) {
|
|
15
|
+
let hb = response.data
|
|
16
|
+
expect(hb.success).toBe(true);
|
|
17
|
+
expect(hb.timestamp).toBeDefined();
|
|
18
|
+
expect(hb.latestTick).toBeDefined();
|
|
19
|
+
done()
|
|
20
|
+
})
|
|
21
|
+
.catch(function (error) {
|
|
22
|
+
console.log("Error:", error)
|
|
23
|
+
done()
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
});
|