Compare commits

...

3 Commits

4 changed files with 10 additions and 5 deletions

View File

@ -1,3 +1,5 @@
# [0.2.0-develop.22](https://git.lumeweb.com/LumeWeb/libportal/compare/v0.2.0-develop.21...v0.2.0-develop.22) (2023-09-03)
# [0.2.0-develop.21](https://git.lumeweb.com/LumeWeb/libportal/compare/v0.2.0-develop.20...v0.2.0-develop.21) (2023-09-03)

4
npm-shrinkwrap.json generated
View File

@ -1,12 +1,12 @@
{
"name": "@lumeweb/libportal",
"version": "0.2.0-develop.21",
"version": "0.2.0-develop.22",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@lumeweb/libportal",
"version": "0.2.0-develop.21",
"version": "0.2.0-develop.22",
"dependencies": {
"@lumeweb/libs5": "^0.1.0-develop.44",
"@noble/curves": "^1.1.0",

View File

@ -1,6 +1,6 @@
{
"name": "@lumeweb/libportal",
"version": "0.2.0-develop.21",
"version": "0.2.0-develop.22",
"main": "lib/index.js",
"type": "module",
"repository": {

View File

@ -49,9 +49,12 @@ export function encodeCid(
return base58btc.encode(prefixedHash).toString();
}
export function decodeCid(cid: string): CID {
let bytes = base58btc.decode(cid);
export function decodeCid(cid: string | Uint8Array): CID {
let bytes = cid;
if (typeof bytes === "string") {
bytes = base58btc.decode(bytes);
}
if (!Object.values(CID_TYPES).includes(bytes[0])) {
throw new Error("Invalid cid type");
}