-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #499 from nervosnetwork/rc/v0.36.1
- Loading branch information
Showing
31 changed files
with
993 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ packages/*/lib | |
playground.ts | ||
|
||
#docs | ||
docs | ||
/docs | ||
# ignore for deploy docs | ||
package-lock.json | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,5 @@ | |
], | ||
"npmClient": "yarn", | ||
"useWorkspaces": true, | ||
"version": "0.36.0" | ||
"version": "0.36.1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@nervosnetwork/ckb-sdk-core", | ||
"version": "0.36.0", | ||
"version": "0.36.1", | ||
"description": "JavaScript SDK for Nervos Network CKB Project", | ||
"author": "Nervos <[email protected]>", | ||
"homepage": "https://github.com/nervosnetwork/ckb-sdk-js#readme", | ||
|
@@ -31,10 +31,10 @@ | |
"url": "https://github.com/nervosnetwork/ckb-sdk-js/issues" | ||
}, | ||
"dependencies": { | ||
"@nervosnetwork/ckb-sdk-rpc": "0.36.0", | ||
"@nervosnetwork/ckb-sdk-utils": "0.36.0", | ||
"@nervosnetwork/ckb-types": "0.36.0", | ||
"@nervosnetwork/ckb-sdk-rpc": "0.36.1", | ||
"@nervosnetwork/ckb-sdk-utils": "0.36.1", | ||
"@nervosnetwork/ckb-types": "0.36.1", | ||
"tslib": "2.0.1" | ||
}, | ||
"gitHead": "d0adcbb7e6743fdcc049984534afab13f5ede178" | ||
"gitHead": "b34332872a9168a1879d3020ca3546b72816823a" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@nervosnetwork/ckb-sdk-rpc", | ||
"version": "0.36.0", | ||
"version": "0.36.1", | ||
"description": "RPC module of @nervosnetwork/ckb-sdk-core", | ||
"author": "Nervos <[email protected]>", | ||
"homepage": "https://github.com/nervosnetwork/ckb-sdk-js/packages/ckb-rpc#readme", | ||
|
@@ -33,12 +33,12 @@ | |
"url": "https://github.com/nervosnetwork/ckb-sdk-js/issues" | ||
}, | ||
"dependencies": { | ||
"@nervosnetwork/ckb-sdk-utils": "0.36.0", | ||
"@nervosnetwork/ckb-sdk-utils": "0.36.1", | ||
"axios": "0.19.2", | ||
"tslib": "2.0.1" | ||
}, | ||
"devDependencies": { | ||
"@nervosnetwork/ckb-types": "0.36.0" | ||
"@nervosnetwork/ckb-types": "0.36.1" | ||
}, | ||
"gitHead": "d0adcbb7e6743fdcc049984534afab13f5ede178" | ||
"gitHead": "b34332872a9168a1879d3020ca3546b72816823a" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const { bech32 } = require('../..') | ||
const fixtures = require('./bech32.fixtures.json') | ||
|
||
describe('bech32', () => { | ||
fixtures.bech32.valid.forEach(f => { | ||
it(`fromWords/toWords ${f.hex}`, () => { | ||
if (f.hex) { | ||
const words = bech32.toWords(Buffer.from(f.hex, 'hex')) | ||
const bytes = Buffer.from(bech32.fromWords(f.words)) | ||
expect(words.join('')).toEqual(f.words.join('')) | ||
expect(bytes.toString('hex')).toBe(f.hex) | ||
} | ||
}) | ||
|
||
it(`encode ${f.prefix}`, () => { | ||
const encoded = bech32.encode(f.prefix, f.words, f.limit) | ||
expect(encoded).toBe(f.string.toLowerCase()) | ||
}) | ||
|
||
it(`decode ${f.string}`, () => { | ||
const decoded = bech32.decode(f.string, f.limit) | ||
expect(decoded.prefix).toBe(f.prefix.toLowerCase()) | ||
expect(decoded.words.join('')).toBe(f.words.join('')) | ||
}) | ||
|
||
it(`fails for ${f.string} with 1 bit flipped`, () => { | ||
const buf = Buffer.from(f.string, 'utf8') | ||
buf[f.string.lastIndexOf('1') + 1] ^= 0x1 | ||
const str = buf.toString('utf8') | ||
expect(() => { | ||
bech32.decode(str, f.limit) | ||
}).toThrow() | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const { blake160 } = require('../..') | ||
|
||
describe('blake160', () => { | ||
it('blake160', () => { | ||
const fixture = { | ||
message: '024a501efd328e062c8675f2365970728c859c592beeefd6be8ead3d901330bc01', | ||
digest: '36c329ed630d6ce750712a477543672adab57f4c', | ||
} | ||
const digest = blake160(new Uint8Array(Buffer.from(fixture.message, 'hex')), 'hex') | ||
expect(digest).toBe(fixture.digest) | ||
}) | ||
}) |
File renamed without changes.
101 changes: 101 additions & 0 deletions
101
packages/ckb-sdk-utils/__tests__/crypto/blake2b.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
const { blake2b, PERSONAL } = require('../..') | ||
const { ready } = require('../../lib/crypto/blake2b') | ||
const fixtures = require('./blake2b.fixtures.json') | ||
|
||
describe('blake2b', () => { | ||
it('blake2b([]) with personal', () => { | ||
const fixture = { | ||
message: new Uint8Array(), | ||
digest: '44f4c69744d5f8c55d642062949dcae49bc4e7ef43d388c5a12f42b5633d163e', | ||
} | ||
const s = blake2b(32, null, null, PERSONAL) | ||
s.update(fixture.message) | ||
const digest = s.digest('hex') | ||
expect(digest).toBe(fixture.digest) | ||
}) | ||
|
||
it('blake2b(Buffer.from("The quick brown fox jumps over the lazy dog")) with personal', () => { | ||
const fixture = { | ||
message: 'The quick brown fox jumps over the lazy dog', | ||
digest: 'abfa2c08d62f6f567d088d6ba41d3bbbb9a45c241a8e3789ef39700060b5cee2', | ||
} | ||
const s = blake2b(32, null, null, PERSONAL) | ||
s.update(new Uint8Array(Buffer.from(fixture.message, 'utf8'))) | ||
const digest = s.digest('hex') | ||
expect(digest).toBe(fixture.digest) | ||
}) | ||
|
||
test.each(fixtures)('%s', ({ outlen, out, input, key, salt, personal }) => { | ||
if (+outlen < 16) { | ||
expect(() => { | ||
blake2b( | ||
outlen, | ||
key ? new Uint8Array(Buffer.from(key, 'hex')) : null, | ||
salt ? new Uint8Array(Buffer.from(salt, 'hex')) : null, | ||
personal ? new Uint8Array(Buffer.from(personal, 'hex')) : null, | ||
) | ||
}).toThrowError(`Expect outlen to be at least 16, but ${outlen} received`) | ||
} else { | ||
const s = blake2b( | ||
outlen, | ||
key ? new Uint8Array(Buffer.from(key, 'hex')) : null, | ||
salt ? new Uint8Array(Buffer.from(salt, 'hex')) : null, | ||
personal ? new Uint8Array(Buffer.from(personal, 'hex')) : null, | ||
) | ||
s.update(new Uint8Array(Buffer.from(input, 'hex'))) | ||
const digest = s.digest('hex') | ||
expect(digest).toBe(out) | ||
} | ||
}) | ||
}) | ||
|
||
describe('blake2b-wasm-ready', () => { | ||
afterEach(() => { | ||
delete globalThis.navigator | ||
}) | ||
|
||
describe("When it's in browser but not iOS 11", () => { | ||
beforeEach(() => { | ||
Object.defineProperty(globalThis, 'navigator', { | ||
value: { | ||
userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_4 like Mac OS X)', | ||
}, | ||
}) | ||
}) | ||
|
||
it('callback should be invoked without error', () => { | ||
expect.assertions(1) | ||
ready(err => { | ||
expect(err).toBeUndefined() | ||
}) | ||
}) | ||
}) | ||
|
||
describe("When it's not in browser and navigator is undefined", () => { | ||
beforeEach(() => { | ||
delete globalThis.navigator | ||
}) | ||
it('callback should be invoked without error', () => { | ||
expect.assertions(1) | ||
ready(err => { | ||
expect(err).toBeUndefined() | ||
}) | ||
}) | ||
}) | ||
|
||
describe("When it's iOS 11", () => { | ||
beforeEach(() => { | ||
Object.defineProperty(globalThis, 'navigator', { | ||
value: { | ||
userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_2_1 like Mac OS X)', | ||
}, | ||
}) | ||
}) | ||
it('callback should be invoked with error', () => { | ||
expect.assertions(1) | ||
ready(err => { | ||
expect(err).toEqual(new Error('blake2b-wasm is unavailable on iOS 11')) | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.