-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix node build, wnfs script and bump version
- Loading branch information
Showing
11 changed files
with
215 additions
and
84 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,25 +1,4 @@ | ||
{ | ||
"name": "wnfs", | ||
"version": "0.1.1", | ||
"homepage": "https://guide.fission.codes", | ||
"license": "Apache-2.0", | ||
"author": { | ||
"name": "Stephen Akinyemi", | ||
"email": "[email protected]" | ||
}, | ||
"keywords": [ | ||
"wnfs", | ||
"web", | ||
"webnative", | ||
"filesystem", | ||
"cryptography", | ||
"web-programming", | ||
"wasm" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/WebNativeFileSystem/rs-wnfs/tree/main/crates/wasm" | ||
}, | ||
"devDependencies": { | ||
"@playwright/test": "^1.21.1", | ||
"@wasm-tool/wasm-pack-plugin": "^1.6.0", | ||
|
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,11 @@ | ||
import { MemoryBlockStore } from "./store.js"; | ||
import { PublicDirectory } from "wnfs"; | ||
|
||
const time = new Date(); | ||
const dir = new PublicDirectory(time); | ||
const store = new MemoryBlockStore(); | ||
|
||
// Create a /pictures/cats directory. | ||
var { rootDir } = await dir.mkdir(["pictures", "cats"], time, store); | ||
|
||
console.log("Root Id =", rootDir.getId()); |
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,11 @@ | ||
{ | ||
"name": "test", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"dependencies": { | ||
"multiformats": "^9.6.5", | ||
"wnfs": "../pkg/" | ||
}, | ||
"type": "module" | ||
} |
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,36 @@ | ||
import { CID } from "multiformats/cid"; | ||
import { sha256 } from "multiformats/hashes/sha2"; | ||
|
||
/** A mock CID. */ | ||
const sampleCID = CID.parse( | ||
"bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea" | ||
).bytes; | ||
|
||
/** | ||
* An in-memory block store to simulate IPFS. | ||
* | ||
* IPFS is basically a glorified HashMap. | ||
*/ | ||
class MemoryBlockStore { | ||
// private store: Map<string, Uint8Array>; | ||
|
||
/** Creates a new in-memory block store. */ | ||
constructor() { | ||
this.store = new Map(); | ||
} | ||
|
||
/** Stores an array of bytes in the block store. */ | ||
async getBlock(cid) { | ||
const decoded_cid = CID.decode(cid); | ||
return this.store.get(decoded_cid.toString()); | ||
} | ||
|
||
/** Retrieves an array of bytes from the block store with given CID. */ | ||
async putBlock(bytes, code) { | ||
const hash = await sha256.digest(bytes); | ||
const cid = CID.create(1, code, hash); | ||
this.store.set(cid.toString(), bytes); | ||
} | ||
} | ||
|
||
export { sampleCID, MemoryBlockStore }; |
Oops, something went wrong.