Socket
Socket
Sign inDemoInstall

@vechain/sdk-core

Package Overview
Dependencies
Maintainers
8
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vechain/sdk-core - npm Package Compare versions

Comparing version 1.0.0-beta.26 to 1.0.0-beta.27

src/vcdm/index.ts

11

package.json
{
"name": "@vechain/sdk-core",
"version": "1.0.0-beta.26",
"version": "1.0.0-beta.27",
"description": "Includes modules for fundamental operations like hashing and cryptography",

@@ -20,4 +20,5 @@ "author": "vechain Foundation",

"private": false,
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"files": [

@@ -45,4 +46,4 @@ "dist",

"@types/elliptic": "^6.4.18",
"@vechain/sdk-errors": "1.0.0-beta.26",
"@vechain/sdk-logging": "1.0.0-beta.26",
"@vechain/sdk-errors": "1.0.0-beta.27",
"@vechain/sdk-logging": "1.0.0-beta.27",
"bignumber.js": "^9.1.2",

@@ -49,0 +50,0 @@ "blakejs": "^1.2.1",

@@ -5,6 +5,6 @@ import fastJsonStableStringify from 'fast-json-stable-stringify';

import { CertificateSignature } from '@vechain/sdk-errors';
import { Txt } from '../vcdm';
import { blake2b256 } from '../hash';
import { hexToBytes } from '@noble/curves/abstract/utils';
import { secp256k1 } from '../secp256k1';
import { txt } from '../utils/txt/txt';
import { type Certificate } from './types';

@@ -28,3 +28,2 @@

*
* @see {NORMALIZATION_FORM_CANONICAL_COMPOSITION}
* @see {https://www.npmjs.com/package/fast-json-stable-stringify fastJsonStableStringify}

@@ -35,3 +34,3 @@ * @see {sign}

function encode(cert: Certificate): Uint8Array {
return txt.encode(
return Txt.of(
// The following `fastJsonStableStringify` strips blank chars and serialize alphabetical sorted properties.

@@ -48,3 +47,3 @@ fastJsonStableStringify({

})
);
).bytes;
}

@@ -51,0 +50,0 @@

@@ -7,6 +7,8 @@ import { ethers } from 'ethers';

export * from './bloom';
export * from './bloom';
export * from './certificate';
export * from './encoding';
export * from './certificate';
export * from './clause';
export * from './contract';
export * from './encoding';
export * from './hash';

@@ -19,6 +21,5 @@ export * from './hdnode';

export * from './utils';
export * from './bloom';
export * from './certificate';
export * from './vcdm';
// Other libraries
export { ethers as vechain_sdk_core_ethers };
import { Hex, Hex0x } from '../utils';
import { Txt } from '../vcdm';
import { blake2b } from '@noble/hashes/blake2b';
import { hexToBytes } from '@noble/hashes/utils';
import { txt } from '../utils/txt/txt';
import { type ReturnType } from './types';

@@ -12,3 +12,2 @@ import { InvalidDataType } from '@vechain/sdk-errors';

* Computes the Blake2bB-256 hash of the given data.
* If `data` is a string this is normalized using the {@link NORMALIZATION_FORM_CANONICAL_COMPOSITION} encoding.
*

@@ -19,3 +18,3 @@ * @param {string | Uint8Array} data - The data to compute the hash for. It can be either a string or a Uint8Array.

*
* @throws {InvalidDataReturnTypeError} - If the specified return type is invalid.
* @throws {InvalidDataReturnType} - If the specified return type is invalid.
*

@@ -28,3 +27,2 @@ * @remark Use {@link blake2b256OfHex} to hash a string representing an array of bytes in hexadecimal form.

* Calculates the Blake2b-256 hash of the given data.
* If `data` is a string this is normalized using the {@link NORMALIZATION_FORM_CANONICAL_COMPOSITION} encoding.
*

@@ -47,3 +45,2 @@ * @param {string | Uint8Array} data - The input data to be hashed.

* Computes the blake2b-256 hash of the input data.
* If `data` is a string this is normalized using the {@link NORMALIZATION_FORM_CANONICAL_COMPOSITION} encoding.
*

@@ -65,3 +62,2 @@ * @param {string | Uint8Array} data - The input data to be hashed.

* Calculates the Blake2b-256 hash of the given input data.
* If `data` is a string this is normalized using the {@link NORMALIZATION_FORM_CANONICAL_COMPOSITION} encoding.
*

@@ -159,3 +155,2 @@ * Secure audit function.

* Calculates the BLAKE2b-256 hash of a given string.
* The string is normalized using the {@link NORMALIZATION_FORM_CANONICAL_COMPOSITION} encoding.
*

@@ -170,5 +165,5 @@ * Secure audit function.

function blake2b256OfString(text: string): Uint8Array {
return blake2b256OfArray(txt.encode(text));
return blake2b256OfArray(Txt.of(text).bytes);
}
export { blake2b256, blake2b256OfHex };
import { VeChainSDKLogger } from '@vechain/sdk-logging';
import { Txt } from '../vcdm';
import { keystoreEthers, keystoreExperimental } from './cryptography';
import { txt } from '../utils/txt/txt';
import { type Keystore, type KeystoreAccount } from './types';

@@ -41,3 +41,3 @@

return EXPERIMENTAL_CRYPTOGRAPHY
? keystoreExperimental.encrypt(privateKey, txt.encode(password))
? keystoreExperimental.encrypt(privateKey, Txt.of(password).bytes)
: await keystoreEthers.encrypt(privateKey, password);

@@ -68,3 +68,3 @@ }

return EXPERIMENTAL_CRYPTOGRAPHY
? keystoreExperimental.decrypt(keystore, txt.encode(password))
? keystoreExperimental.decrypt(keystore, Txt.of(password).bytes)
: await keystoreEthers.decrypt(keystore, password);

@@ -71,0 +71,0 @@ }

import * as n_utils from '@noble/curves/abstract/utils';
import { Hex, Hex0x } from '../hex';
import { Txt } from '../../vcdm';
import { INTEGER_REGEX, NUMERIC_REGEX, ZERO_BYTES } from '../const';
import { txt } from '../txt/txt';
import { InvalidDataType } from '@vechain/sdk-errors';

@@ -32,8 +32,8 @@

// Decode the encoded bytes 32 string to string by removing the padded zeros.
return txt.decode(valueInBytes.subarray(firstNotZeroIndex));
return Txt.of(valueInBytes.subarray(firstNotZeroIndex)).toString();
} else if (firstZeroIndex !== -1) {
// Decode the encoded bytes 32 string to string by removing the padded zeros.
return txt.decode(valueInBytes.subarray(0, firstZeroIndex));
return Txt.of(valueInBytes.subarray(0, firstZeroIndex)).toString();
} else {
return txt.decode(valueInBytes);
return Txt.of(valueInBytes).toString();
}

@@ -57,3 +57,3 @@ };

try {
const valueInBytes = txt.encode(value);
const valueInBytes = Txt.of(value).bytes;

@@ -60,0 +60,0 @@ if (valueInBytes.length > 32) {

@@ -7,4 +7,3 @@ export * from './const';

export * from './transaction';
export * from './txt';
export * from './units';
export * from './revision';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc