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) # [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", "name": "@lumeweb/libportal",
"version": "0.2.0-develop.21", "version": "0.2.0-develop.22",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@lumeweb/libportal", "name": "@lumeweb/libportal",
"version": "0.2.0-develop.21", "version": "0.2.0-develop.22",
"dependencies": { "dependencies": {
"@lumeweb/libs5": "^0.1.0-develop.44", "@lumeweb/libs5": "^0.1.0-develop.44",
"@noble/curves": "^1.1.0", "@noble/curves": "^1.1.0",

View File

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

View File

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