@aeternity/aepp-calldata
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -15,2 +15,15 @@ # Changelog | ||
## [1.1.1] - 2022-03-15 | ||
## Fixed | ||
- Depend on Buffer ponyfill for browser compatibility (#122) | ||
## Added | ||
- Add tests from root to browser bundle (#120) | ||
## Changed | ||
- Use own implementation of base58check (#122) | ||
- Use blakejs version that doesn't refer to Buffer (#122) | ||
- Update dependencies (#121) | ||
## [1.1.0] - 2022-01-27 | ||
@@ -17,0 +30,0 @@ |
{ | ||
"name": "@aeternity/aepp-calldata", | ||
"description": "Aeternity data serialization library", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"author": "aeternity", | ||
@@ -32,15 +32,16 @@ "license": "ISC", | ||
"dependencies": { | ||
"blakejs": "^1.1.0", | ||
"bs58check": "^2.1.2", | ||
"rlp": "^2.2.4", | ||
"@aeternity/blakejs": "^1.1.2", | ||
"bs58": "^4.0.1", | ||
"rlp": "^3.0.0", | ||
"safe-buffer": "^5.2.1", | ||
"sha.js": "^2.4.11" | ||
}, | ||
"devDependencies": { | ||
"ava": "^3.1.0", | ||
"browserify": "^16.5.2", | ||
"eslint": "^8.2.0", | ||
"ava": "^4.0.1", | ||
"browserify": "^17.0.0", | ||
"eslint": "^8.8.0", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-plugin-import": "^2.25.3", | ||
"nyc": "^15.0.0", | ||
"tape": "^5.0.1" | ||
"eslint-plugin-import": "^2.25.4", | ||
"nyc": "^15.1.0", | ||
"tape": "^5.5.0" | ||
}, | ||
@@ -62,3 +63,3 @@ "ava": { | ||
"scripts": { | ||
"browser-test-bundle": "browserify tests/**/*.js > build/js/tests.js", | ||
"browser-test-bundle": "browserify tests/[A-Z]*.js tests/**/*.js > build/js/tests.js", | ||
"coverage": "nyc ava", | ||
@@ -65,0 +66,0 @@ "test": "ava --verbose", |
@@ -1,2 +0,2 @@ | ||
const bs58check = require('bs58check') | ||
const base58check = require('../utils/base58check') | ||
@@ -13,3 +13,3 @@ /** | ||
visitAddress(acceptor) { | ||
return acceptor.prefix + '_' + bs58check.encode(acceptor.value) | ||
return acceptor.prefix + '_' + base58check.encode(acceptor.value) | ||
} | ||
@@ -16,0 +16,0 @@ |
@@ -1,2 +0,2 @@ | ||
const bs58check = require('bs58check') | ||
const base58check = require('../utils/base58check') | ||
const FateTypeError = require('../Errors/FateTypeError') | ||
@@ -44,3 +44,3 @@ | ||
return bs58check.decode(asString.substring(prefix.length + 1)) | ||
return base58check.decode(asString.substring(prefix.length + 1)) | ||
} | ||
@@ -47,0 +47,0 @@ |
const shajs = require('sha.js') | ||
const { Buffer } = require('safe-buffer') | ||
const FormatError = require('../Errors/FormatError') | ||
@@ -12,14 +13,28 @@ | ||
const addChecksum = (payload) => { | ||
const buffer = Buffer.from(payload) | ||
const checksum = checkSumFn(payload) | ||
return Buffer.concat([buffer, checksum], buffer.length + 4) | ||
} | ||
const getPayload = (payloadWithChecksum) => { | ||
const payload = payloadWithChecksum.slice(0, -4) | ||
const checksum = payloadWithChecksum.slice(-4) | ||
const newChecksum = checkSumFn(payload) | ||
if (!checksum.equals(newChecksum)) { | ||
throw new FormatError('Invalid checksum') | ||
} | ||
return payload | ||
} | ||
/** | ||
* Base64check encode given `input` | ||
* @rtype (input: String|buffer) => Buffer | ||
* @param {String} input - Data to encode | ||
* @return {Buffer} Base64check encoded data | ||
* @param {String|Buffer} input - Data to encode | ||
* @return {String} Base64check encoded data | ||
*/ | ||
const encode = (input) => { | ||
const buffer = Buffer.from(input) | ||
const checksum = checkSumFn(input) | ||
const payloadWithChecksum = Buffer.concat([buffer, checksum], buffer.length + 4) | ||
return payloadWithChecksum.toString('base64') | ||
return addChecksum(input).toString('base64') | ||
} | ||
@@ -34,17 +49,10 @@ | ||
const decode = (str) => { | ||
const buffer = Buffer.from(str, 'base64') | ||
const payload = buffer.slice(0, -4) | ||
const checksum = buffer.slice(-4) | ||
const newChecksum = checkSumFn(payload) | ||
if (!checksum.equals(newChecksum)) { | ||
throw new FormatError('Invalid base64 checksum') | ||
} | ||
return Buffer.from(payload) | ||
return getPayload(Buffer.from(str, 'base64')) | ||
} | ||
module.exports = { | ||
addChecksum, | ||
getPayload, | ||
encode, | ||
decode | ||
} |
@@ -1,2 +0,2 @@ | ||
const blake = require('blakejs') | ||
const blake = require('@aeternity/blakejs') | ||
@@ -3,0 +3,0 @@ const HASH_BYTES = 32 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
92554
77
2503
5
+ Added@aeternity/blakejs@^1.1.2
+ Addedbs58@^4.0.1
+ Addedsafe-buffer@^5.2.1
+ Added@aeternity/blakejs@1.1.2(transitive)
+ Addedrlp@3.0.0(transitive)
- Removedblakejs@^1.1.0
- Removedbs58check@^2.1.2
- Removedblakejs@1.2.1(transitive)
- Removedbn.js@5.2.1(transitive)
- Removedbs58check@2.1.2(transitive)
- Removedcipher-base@1.0.5(transitive)
- Removedcreate-hash@1.2.0(transitive)
- Removedhash-base@3.1.0(transitive)
- Removedmd5.js@1.3.5(transitive)
- Removedreadable-stream@3.6.2(transitive)
- Removedripemd160@2.0.2(transitive)
- Removedrlp@2.2.7(transitive)
- Removedstring_decoder@1.3.0(transitive)
- Removedutil-deprecate@1.0.2(transitive)
Updatedrlp@^3.0.0