Compare commits

...

3 Commits

Author SHA1 Message Date
semantic-release-bot 6c63da7354 chore(release): 0.1.0-develop.54 [skip ci]
# [0.1.0-develop.54](https://git.lumeweb.com/LumeWeb/libs5/compare/v0.1.0-develop.53...v0.1.0-develop.54) (2023-09-08)

### Features

* add valid to CID ([565bed4](565bed46d5))
2023-09-08 14:02:23 +00:00
Derrick Hammer 4d721ef4ab
Merge remote-tracking branch 'origin/develop' into develop 2023-09-08 10:01:33 -04:00
Derrick Hammer 565bed46d5
feat: add valid to CID 2023-09-08 10:01:29 -04:00
4 changed files with 20 additions and 3 deletions

View File

@ -1,3 +1,10 @@
# [0.1.0-develop.54](https://git.lumeweb.com/LumeWeb/libs5/compare/v0.1.0-develop.53...v0.1.0-develop.54) (2023-09-08)
### Features
* add valid to CID ([565bed4](https://git.lumeweb.com/LumeWeb/libs5/commit/565bed46d511340854c443013c2be000c1e9302d))
# [0.1.0-develop.53](https://git.lumeweb.com/LumeWeb/libs5/compare/v0.1.0-develop.52...v0.1.0-develop.53) (2023-09-08)

4
npm-shrinkwrap.json generated
View File

@ -1,12 +1,12 @@
{
"name": "@lumeweb/libs5",
"version": "0.1.0-develop.53",
"version": "0.1.0-develop.54",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@lumeweb/libs5",
"version": "0.1.0-develop.53",
"version": "0.1.0-develop.54",
"dependencies": {
"@noble/curves": "^1.1.0",
"@noble/hashes": "^1.3.1",

View File

@ -1,6 +1,6 @@
{
"name": "@lumeweb/libs5",
"version": "0.1.0-develop.53",
"version": "0.1.0-develop.54",
"type": "module",
"main": "lib/index.js",
"repository": {

View File

@ -52,6 +52,16 @@ export default class CID extends Multibase {
return new CID(type, new Multihash(bytes), size);
}
static valid(bytes: Uint8Array): boolean {
try {
CID._init(bytes);
} catch {
return false;
}
return true;
}
private static _init(bytes: Uint8Array): CID {
const type = bytes[0];
if (type === CID_TYPES.BRIDGE) {