@blockchyp/blockchyp-ts 2.26.1 → 2.28.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/_bundles/blockchyp.js +25785 -54682
- package/_bundles/blockchyp.js.map +1 -1
- package/_bundles/blockchyp.min.js +1 -1
- package/_bundles/blockchyp.min.js.LICENSE.txt +3 -1
- package/_bundles/blockchyp.min.js.map +1 -1
- package/lib/src/client.d.ts +1 -1
- package/lib/src/client.js +1 -1
- package/lib/src/cryptoutils.js +21 -14
- package/lib/src/cryptoutils.js.map +1 -1
- package/lib/src/models.d.ts +10 -2
- package/lib/src/models.js +12 -2
- package/lib/src/models.js.map +1 -1
- package/package.json +3 -8
- package/src/client.ts +1 -1
- package/src/cryptoutils.ts +26 -12
- package/src/models.ts +15 -1
package/lib/src/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2019-
|
|
2
|
+
* Copyright 2019-2026 BlockChyp, Inc. All rights reserved. Use of this code is governed
|
|
3
3
|
* by a license that can be found in the LICENSE file.
|
|
4
4
|
*
|
|
5
5
|
* This file was generated automatically by the BlockChyp SDK Generator. Changes to this
|
package/lib/src/client.js
CHANGED
|
@@ -37,7 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.newClient = exports.BlockChypCredentials = exports.BlockChypClient = exports.HealthcareType = exports.CVMType = exports.AVSResponse = exports.PromptType = exports.RoundingMode = exports.SignatureFormat = exports.CardType = void 0;
|
|
39
39
|
/**
|
|
40
|
-
* Copyright 2019-
|
|
40
|
+
* Copyright 2019-2026 BlockChyp, Inc. All rights reserved. Use of this code is governed
|
|
41
41
|
* by a license that can be found in the LICENSE file.
|
|
42
42
|
*
|
|
43
43
|
* This file was generated automatically by the BlockChyp SDK Generator. Changes to this
|
package/lib/src/cryptoutils.js
CHANGED
|
@@ -27,12 +27,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.BlockChypCrypto = void 0;
|
|
30
|
-
const
|
|
31
|
-
const
|
|
30
|
+
const hmac_1 = require("@noble/hashes/hmac");
|
|
31
|
+
const sha256_1 = require("@noble/hashes/sha256");
|
|
32
|
+
const utils_1 = require("@noble/hashes/utils");
|
|
32
33
|
const moment_1 = __importDefault(require("moment"));
|
|
33
34
|
const base32 = require('base32');
|
|
34
|
-
const
|
|
35
|
-
const EC = __importStar(require("elliptic"));
|
|
35
|
+
const nist_1 = require("@noble/curves/nist");
|
|
36
36
|
const aesjs = __importStar(require("aes-js"));
|
|
37
37
|
const buffer_1 = require("buffer");
|
|
38
38
|
class BlockChypCrypto {
|
|
@@ -41,9 +41,8 @@ class BlockChypCrypto {
|
|
|
41
41
|
const ts = this.generateIsoTimestamp();
|
|
42
42
|
const toSign = creds.apiKey + creds.bearerToken + ts + nonce;
|
|
43
43
|
const key = buffer_1.Buffer.from(creds.signingKey, 'hex');
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
const sig = hmac.digest('hex');
|
|
44
|
+
const mac = (0, hmac_1.hmac)(sha256_1.sha256, key, (0, utils_1.utf8ToBytes)(toSign));
|
|
45
|
+
const sig = (0, utils_1.bytesToHex)(mac);
|
|
47
46
|
const results = {
|
|
48
47
|
'Nonce': nonce,
|
|
49
48
|
'Timestamp': ts,
|
|
@@ -54,21 +53,29 @@ class BlockChypCrypto {
|
|
|
54
53
|
encrypt(hexKey, plainText) {
|
|
55
54
|
const key = buffer_1.Buffer.from(hexKey, 'hex').slice(0, 32);
|
|
56
55
|
const keyArr = [...key];
|
|
57
|
-
const iv = (0,
|
|
56
|
+
const iv = (0, utils_1.randomBytes)(16);
|
|
58
57
|
const ivArr = [...iv];
|
|
59
58
|
const aesCbc = new aesjs.ModeOfOperation.cbc(keyArr, ivArr);
|
|
60
59
|
const plainBytes = aesjs.padding.pkcs7.pad(aesjs.utils.utf8.toBytes(plainText));
|
|
61
60
|
const encryptedBytes = aesCbc.encrypt(plainBytes);
|
|
62
|
-
return
|
|
61
|
+
return (0, utils_1.bytesToHex)(iv) + aesjs.utils.hex.fromBytes(encryptedBytes);
|
|
63
62
|
}
|
|
64
63
|
sha256Hash(msg) {
|
|
65
|
-
|
|
64
|
+
const msgBytes = buffer_1.Buffer.from(msg, 'hex');
|
|
65
|
+
return (0, utils_1.bytesToHex)((0, sha256_1.sha256)(msgBytes));
|
|
66
66
|
}
|
|
67
67
|
validateSignature(publicKey, msg, sig) {
|
|
68
|
-
const ec = new EC.ec('p256');
|
|
69
|
-
const key = ec.keyFromPublic({ x: publicKey.x, y: publicKey.y });
|
|
70
68
|
const msgHash = this.sha256Hash(msg);
|
|
71
|
-
|
|
69
|
+
const msgHashBytes = buffer_1.Buffer.from(msgHash, 'hex');
|
|
70
|
+
const pubKeyPoint = nist_1.p256.ProjectivePoint.fromAffine({
|
|
71
|
+
x: BigInt('0x' + publicKey.x),
|
|
72
|
+
y: BigInt('0x' + publicKey.y)
|
|
73
|
+
});
|
|
74
|
+
const pubKeyBytes = pubKeyPoint.toRawBytes(false);
|
|
75
|
+
const signature = new nist_1.p256.Signature(BigInt('0x' + sig.r), BigInt('0x' + sig.s));
|
|
76
|
+
const sigBytes = signature.toCompactRawBytes();
|
|
77
|
+
// Verify signature (prehash: true means we already hashed the message)
|
|
78
|
+
return nist_1.p256.verify(sigBytes, msgHashBytes, pubKeyBytes, { prehash: true });
|
|
72
79
|
}
|
|
73
80
|
decrypt(hexKey, cipherText) {
|
|
74
81
|
const key = buffer_1.Buffer.from(hexKey, 'hex').slice(0, 32);
|
|
@@ -82,7 +89,7 @@ class BlockChypCrypto {
|
|
|
82
89
|
return aesjs.utils.utf8.fromBytes(decryptedBytes);
|
|
83
90
|
}
|
|
84
91
|
generateNonce() {
|
|
85
|
-
return base32.encode((0,
|
|
92
|
+
return base32.encode((0, utils_1.randomBytes)(32)).toUpperCase();
|
|
86
93
|
}
|
|
87
94
|
generateIsoTimestamp() {
|
|
88
95
|
return (0, moment_1.default)().utc().format('YYYY-MM-DDTHH:mm:ss.SSS') + 'Z';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cryptoutils.js","sourceRoot":"","sources":["../../src/cryptoutils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"cryptoutils.js","sourceRoot":"","sources":["../../src/cryptoutils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAyC;AACzC,iDAA6C;AAC7C,+CAA0E;AAC1E,oDAA4B;AAC5B,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;AAChC,6CAAyC;AACzC,8CAA+B;AAC/B,mCAAgC;AAIhC,MAAa,eAAe;IAC1B,sBAAsB,CAAE,KAA2B;QACjD,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,EAAE,CAAA;QAClC,MAAM,EAAE,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAA;QACtC,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,WAAW,GAAG,EAAE,GAAG,KAAK,CAAA;QAC5D,MAAM,GAAG,GAAG,eAAM,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;QAChD,MAAM,GAAG,GAAG,IAAA,WAAI,EAAC,eAAM,EAAE,GAAG,EAAE,IAAA,mBAAW,EAAC,MAAM,CAAC,CAAC,CAAA;QAClD,MAAM,GAAG,GAAG,IAAA,kBAAU,EAAC,GAAG,CAAC,CAAA;QAE3B,MAAM,OAAO,GAAG;YACd,OAAO,EAAE,KAAK;YACd,WAAW,EAAE,EAAE;YACf,eAAe,EAAE,OAAO,GAAG,KAAK,CAAC,WAAW,GAAG,GAAG,GAAG,KAA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G,CAAC,GAAG,MAAM,CAAC,CAAA;QAC7B,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAA;QAE3E,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAA;IACnD,CAAC;IAED,aAAa;QACX,OAAO,MAAM,CAAC,MAAM,CAAC,IAAA,mBAAW,EAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAA;IACrD,CAAC;IAED,oBAAoB;QAClB,OAAO,IAAA,gBAAM,GAAE,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,yBAAyB,CAAC,GAAG,GAAG,CAAA;IAC/D,CAAC;CACF;AAhFD,0CAgFC;AAED,MAAM,WAAW,GAAG,IAAI,eAAe,EAAE,CAAA;AACzC,kBAAe,WAAW,CAAA"}
|
package/lib/src/models.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright 2019-
|
|
2
|
+
* Copyright 2019-2026 BlockChyp, Inc. All rights reserved. Use of this code is governed
|
|
3
3
|
* by a license that can be found in the LICENSE file.
|
|
4
4
|
*
|
|
5
5
|
* This file was generated automatically by the BlockChyp SDK Generator. Changes to this
|
|
@@ -5641,7 +5641,15 @@ export declare class BatchDetailsResponse {
|
|
|
5641
5641
|
* Merchant's batch history in descending order.
|
|
5642
5642
|
*/
|
|
5643
5643
|
volumeByTerminal: TerminalVolume[] | null;
|
|
5644
|
-
|
|
5644
|
+
/**
|
|
5645
|
+
* The net volume for this batch, usually expected volume less daily fees volume.
|
|
5646
|
+
*/
|
|
5647
|
+
netDeposit: string | null;
|
|
5648
|
+
/**
|
|
5649
|
+
* The daily fees for this batch
|
|
5650
|
+
*/
|
|
5651
|
+
dailyFees: string | null;
|
|
5652
|
+
constructor(success?: boolean | null, error?: string | null, responseDescription?: string | null, test?: boolean | null, batchId?: string | null, entryMethod?: string | null, destinationAccountId?: string | null, capturedAmount?: string | null, openPreauths?: string | null, totalVolume?: string | null, transactionCount?: number | null, giftCardsSold?: string | null, giftCardVolume?: string | null, expectedDeposit?: string | null, open?: boolean | null, openDate?: Date | null, closeDate?: Date | null, volumeByTerminal?: TerminalVolume[] | null, netDeposit?: string | null, dailyFees?: string | null);
|
|
5645
5653
|
}
|
|
5646
5654
|
/**
|
|
5647
5655
|
* Models transaction volume for a single terminal.
|
package/lib/src/models.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Copyright 2019-
|
|
3
|
+
* Copyright 2019-2026 BlockChyp, Inc. All rights reserved. Use of this code is governed
|
|
4
4
|
* by a license that can be found in the LICENSE file.
|
|
5
5
|
*
|
|
6
6
|
* This file was generated automatically by the BlockChyp SDK Generator. Changes to this
|
|
@@ -4365,7 +4365,7 @@ exports.BatchDetailsRequest = BatchDetailsRequest;
|
|
|
4365
4365
|
*/
|
|
4366
4366
|
class BatchDetailsResponse {
|
|
4367
4367
|
// Constructor with default values for optional fields
|
|
4368
|
-
constructor(success = null, error = null, responseDescription = null, test = null, batchId = null, entryMethod = null, destinationAccountId = null, capturedAmount = null, openPreauths = null, totalVolume = null, transactionCount = null, giftCardsSold = null, giftCardVolume = null, expectedDeposit = null, open = null, openDate = null, closeDate = null, volumeByTerminal = null) {
|
|
4368
|
+
constructor(success = null, error = null, responseDescription = null, test = null, batchId = null, entryMethod = null, destinationAccountId = null, capturedAmount = null, openPreauths = null, totalVolume = null, transactionCount = null, giftCardsSold = null, giftCardVolume = null, expectedDeposit = null, open = null, openDate = null, closeDate = null, volumeByTerminal = null, netDeposit = null, dailyFees = null) {
|
|
4369
4369
|
/**
|
|
4370
4370
|
* Whether or not the request succeeded.
|
|
4371
4371
|
*/
|
|
@@ -4438,6 +4438,14 @@ class BatchDetailsResponse {
|
|
|
4438
4438
|
* Merchant's batch history in descending order.
|
|
4439
4439
|
*/
|
|
4440
4440
|
this.volumeByTerminal = null;
|
|
4441
|
+
/**
|
|
4442
|
+
* The net volume for this batch, usually expected volume less daily fees volume.
|
|
4443
|
+
*/
|
|
4444
|
+
this.netDeposit = null;
|
|
4445
|
+
/**
|
|
4446
|
+
* The daily fees for this batch
|
|
4447
|
+
*/
|
|
4448
|
+
this.dailyFees = null;
|
|
4441
4449
|
this.success = success;
|
|
4442
4450
|
this.error = error;
|
|
4443
4451
|
this.responseDescription = responseDescription;
|
|
@@ -4456,6 +4464,8 @@ class BatchDetailsResponse {
|
|
|
4456
4464
|
this.openDate = openDate;
|
|
4457
4465
|
this.closeDate = closeDate;
|
|
4458
4466
|
this.volumeByTerminal = volumeByTerminal;
|
|
4467
|
+
this.netDeposit = netDeposit;
|
|
4468
|
+
this.dailyFees = dailyFees;
|
|
4459
4469
|
}
|
|
4460
4470
|
}
|
|
4461
4471
|
exports.BatchDetailsResponse = BatchDetailsResponse;
|