@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockchyp/blockchyp-ts",
3
- "version": "2.26.1",
3
+ "version": "2.28.0",
4
4
  "description": "BlockChyp Typescript Client",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -39,7 +39,6 @@
39
39
  "devDependencies": {
40
40
  "@types/aes-js": "^3.1.4",
41
41
  "@types/create-hmac": "^1.1.3",
42
- "@types/elliptic": "^6.4.18",
43
42
  "@types/is-windows": "^1.0.2",
44
43
  "@types/jasmine": "^5.1.4",
45
44
  "@types/node": "^20.12.12",
@@ -69,15 +68,11 @@
69
68
  "bn.js": "^4.12.2",
70
69
  "buffer": "^6.0.3",
71
70
  "cached-path-relative": "^1.0.2",
72
- "create-hmac": "^1.1.7",
73
- "crypto-browserify": "^3.12.1",
74
- "elliptic": "^6.6.1",
71
+ "@noble/curves": "^1.6.0",
72
+ "@noble/hashes": "^1.5.0",
75
73
  "glob": "^13.0.0",
76
74
  "moment": "^2.22.2",
77
75
  "npm": "^11.6.3",
78
- "randombytes": "^2.0.6",
79
- "pbkdf2": "^3.1.5",
80
- "sha.js": "^2.4.12",
81
76
  "stream-browserify": "^3.0.0",
82
77
  "uuidv4": "^6.2.13"
83
78
  }
package/src/client.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2019-2025 BlockChyp, Inc. All rights reserved. Use of this code is governed
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
@@ -1,22 +1,22 @@
1
- import createHmac from 'create-hmac'
2
- import randomBytes from 'randombytes'
1
+ import { hmac } from '@noble/hashes/hmac'
2
+ import { sha256 } from '@noble/hashes/sha256'
3
+ import { randomBytes, bytesToHex, utf8ToBytes } from '@noble/hashes/utils'
3
4
  import moment from 'moment'
4
5
  const base32 = require('base32')
5
- import shajs from 'sha.js'
6
- import * as EC from 'elliptic'
6
+ import { p256 } from '@noble/curves/nist'
7
7
  import * as aesjs from 'aes-js'
8
8
  import { Buffer } from 'buffer';
9
9
  import { BlockChypCredentials } from './client'
10
10
 
11
+
11
12
  export class BlockChypCrypto {
12
13
  generateGatewayHeaders (creds: BlockChypCredentials) {
13
14
  const nonce = this.generateNonce()
14
15
  const ts = this.generateIsoTimestamp()
15
16
  const toSign = creds.apiKey + creds.bearerToken + ts + nonce
16
17
  const key = Buffer.from(creds.signingKey, 'hex')
17
- const hmac = createHmac('sha256', key)
18
- hmac.update(toSign)
19
- const sig = hmac.digest('hex')
18
+ const mac = hmac(sha256, key, utf8ToBytes(toSign))
19
+ const sig = bytesToHex(mac)
20
20
 
21
21
  const results = {
22
22
  'Nonce': nonce,
@@ -38,18 +38,32 @@ export class BlockChypCrypto {
38
38
  const plainBytes = aesjs.padding.pkcs7.pad(aesjs.utils.utf8.toBytes(plainText))
39
39
  const encryptedBytes = aesCbc.encrypt(plainBytes)
40
40
 
41
- return iv.toString('hex') + aesjs.utils.hex.fromBytes(encryptedBytes)
41
+ return bytesToHex(iv) + aesjs.utils.hex.fromBytes(encryptedBytes)
42
42
  }
43
43
 
44
44
  sha256Hash (msg: string) {
45
- return shajs('sha256').update(msg, 'hex').digest('hex')
45
+ const msgBytes = Buffer.from(msg, 'hex')
46
+ return bytesToHex(sha256(msgBytes))
46
47
  }
47
48
 
48
49
  validateSignature (publicKey: any, msg: string, sig: any) {
49
- const ec = new EC.ec('p256')
50
- const key = ec.keyFromPublic({x: publicKey.x, y: publicKey.y})
51
50
  const msgHash = this.sha256Hash(msg)
52
- return key.verify(msgHash, {r: sig.r, s: sig.s})
51
+ const msgHashBytes = Buffer.from(msgHash, 'hex')
52
+
53
+ const pubKeyPoint = p256.ProjectivePoint.fromAffine({
54
+ x: BigInt('0x' + publicKey.x),
55
+ y: BigInt('0x' + publicKey.y)
56
+ })
57
+ const pubKeyBytes = pubKeyPoint.toRawBytes(false)
58
+
59
+ const signature = new p256.Signature(
60
+ BigInt('0x' + sig.r),
61
+ BigInt('0x' + sig.s)
62
+ )
63
+ const sigBytes = signature.toCompactRawBytes()
64
+
65
+ // Verify signature (prehash: true means we already hashed the message)
66
+ return p256.verify(sigBytes, msgHashBytes, pubKeyBytes, { prehash: true })
53
67
  }
54
68
 
55
69
  decrypt (hexKey: string, cipherText: string) {
package/src/models.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright 2019-2025 BlockChyp, Inc. All rights reserved. Use of this code is governed
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
@@ -9617,6 +9617,16 @@ export class BatchDetailsResponse {
9617
9617
  */
9618
9618
  volumeByTerminal: TerminalVolume[] | null = null;
9619
9619
 
9620
+ /**
9621
+ * The net volume for this batch, usually expected volume less daily fees volume.
9622
+ */
9623
+ netDeposit: string | null = null;
9624
+
9625
+ /**
9626
+ * The daily fees for this batch
9627
+ */
9628
+ dailyFees: string | null = null;
9629
+
9620
9630
  // Constructor with default values for optional fields
9621
9631
  constructor(
9622
9632
  success: boolean | null = null,
@@ -9637,6 +9647,8 @@ export class BatchDetailsResponse {
9637
9647
  openDate: Date | null = null,
9638
9648
  closeDate: Date | null = null,
9639
9649
  volumeByTerminal: TerminalVolume[] | null = null,
9650
+ netDeposit: string | null = null,
9651
+ dailyFees: string | null = null,
9640
9652
  ) {
9641
9653
  this.success = success;
9642
9654
  this.error = error;
@@ -9656,6 +9668,8 @@ export class BatchDetailsResponse {
9656
9668
  this.openDate = openDate;
9657
9669
  this.closeDate = closeDate;
9658
9670
  this.volumeByTerminal = volumeByTerminal;
9671
+ this.netDeposit = netDeposit;
9672
+ this.dailyFees = dailyFees;
9659
9673
  }
9660
9674
  }
9661
9675