Skip to content

Commit

Permalink
Replace @dcc/base58-universal with base-x dep.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrizagidulin committed Jan 23, 2024
1 parent af1a5fe commit 0017010
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# bnid ChangeLog

## 3.0.1 -

### Changed
- Replace `@digitalcredentials/base58-universal` with `base-x` dependency.

## 3.0.0 - 2024-01-23

### Removed
Expand Down
4 changes: 4 additions & 0 deletions lib/baseX.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import baseX from 'base-x';

const BASE58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
export const base58btc = baseX(BASE58);
9 changes: 3 additions & 6 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
/*!
* Copyright (c) 2020 Digital Bazaar, Inc. All rights reserved.
*/
import {
encode as base58encoder,
decode as base58decoder
} from '@digitalcredentials/base58-universal';
import {base58btc} from './baseX.js';
import {
getRandomBytes,
bytesToHex,
Expand Down Expand Up @@ -95,7 +92,7 @@ function _base16Encoder({bytes, idEncoder}) {

const _log2_58 = Math.log2(58);
function _base58Encoder({bytes, idEncoder}) {
const encoded = base58encoder(bytes);
const encoded = base58btc.encode(bytes);
if(idEncoder.fixedLength) {
const fixedBitLength = _calcDataBitLength({
bitLength: bytes.length * 8,
Expand Down Expand Up @@ -311,7 +308,7 @@ export class IdDecoder {
decoded = bytesFromHex(data);
break;
case 'base58':
decoded = base58decoder(data);
decoded = base58btc.decode(data);
break;
default:
throw new Error(`Unknown encoding "${encoding}".`);
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"./package.json": "./package.json"
},
"dependencies": {
"@digitalcredentials/base58-universal": "^1.0.1",
"base-x": "^4.0.0",
"react-native-securerandom": "^1.0.0"
},
"devDependencies": {
Expand Down Expand Up @@ -77,7 +77,6 @@
"./lib/util.js": "./lib/util-reactnative.js",
"./dist/util.js": "./dist/util-reactnative.js"
},
"bin": "./bnid",
"engines": {
"node": ">=14"
},
Expand Down
2 changes: 1 addition & 1 deletion test/test.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
maxEncodedIdBytes,
generateSecretKeySeed,
decodeSecretKeySeed,
} from '..';
} from '../lib/index.js';

describe('bnid', () => {
describe('utilities', () => {
Expand Down

0 comments on commit 0017010

Please sign in to comment.