Compare commits
44 Commits
v0.0.1
...
v0.0.2-dev
Author | SHA1 | Date |
---|---|---|
semantic-release-bot | 7255ee7b86 | |
Derrick Hammer | 440fddda34 | |
Derrick Hammer | be8591985a | |
Derrick Hammer | 7fc2375fa2 | |
Derrick Hammer | 2ee6531298 | |
Derrick Hammer | e6a84d280e | |
Derrick Hammer | 020f02d958 | |
Derrick Hammer | 68fdd4e0ce | |
Derrick Hammer | 19d8e783fb | |
Derrick Hammer | 27dce710a6 | |
Derrick Hammer | b2c57a2ea7 | |
Derrick Hammer | ca22b4e753 | |
Derrick Hammer | 9bcf4a14b6 | |
Derrick Hammer | ea92a2541d | |
Derrick Hammer | 21486473c4 | |
Derrick Hammer | dbe399c477 | |
Derrick Hammer | b23289b8eb | |
Derrick Hammer | 73c94f03b4 | |
Derrick Hammer | d3e4577943 | |
Derrick Hammer | d813e271f0 | |
Derrick Hammer | 21a59cb49e | |
Derrick Hammer | 4b9c648e44 | |
Derrick Hammer | cac70c39f4 | |
Derrick Hammer | cbdd19a202 | |
Derrick Hammer | a731d066d6 | |
Derrick Hammer | de3daf7530 | |
Derrick Hammer | e2bfe2e7fe | |
Derrick Hammer | bf0919393d | |
Derrick Hammer | 1af416ef3a | |
Derrick Hammer | 99b28db224 | |
Derrick Hammer | 256c29adc2 | |
Derrick Hammer | fd7dba32e3 | |
Derrick Hammer | dd7cfcbfab | |
Derrick Hammer | 9d7cefd703 | |
Derrick Hammer | fe9045cf82 | |
Derrick Hammer | aad02e4901 | |
Derrick Hammer | bda0af49fa | |
Derrick Hammer | 19d6940a7e | |
Derrick Hammer | db5f00241d | |
Derrick Hammer | 1a31398647 | |
Derrick Hammer | a4990e99ef | |
Derrick Hammer | 80f6103180 | |
Derrick Hammer | bd27bf47f1 | |
Derrick Hammer | 0ecd526fa0 |
|
@ -0,0 +1,13 @@
|
||||||
|
name: Build/Publish
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- develop
|
||||||
|
- develop-*
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
main:
|
||||||
|
uses: lumeweb/github-node-deploy-workflow/.github/workflows/main.yml@master
|
||||||
|
secrets: inherit
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"preset": [
|
||||||
|
"@lumeweb/node-library-preset"
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
## [0.0.2-develop.1](https://git.lumeweb.com/LumeWeb/kernel-ipfs-client/compare/v0.0.1...v0.0.2-develop.1) (2023-07-14)
|
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2022 Derrick Hammer
|
Copyright (c) 2022 Hammer Technologies LLC
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
# kernel-ipfs-client
|
||||||
|
IPFS client interface to @lumeweb/kernel-ipfs module
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,31 @@
|
||||||
|
{
|
||||||
|
"name": "@lumeweb/kernel-ipfs-client",
|
||||||
|
"version": "0.0.2-develop.1",
|
||||||
|
"type": "module",
|
||||||
|
"main": "lib/index.js",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "gitea@git.lumeweb.com:LumeWeb/kernel-ipfs-client.git"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@helia/unixfs": "^1.4.0",
|
||||||
|
"@lumeweb/node-library-preset": "^0.2.7",
|
||||||
|
"presetter": "*"
|
||||||
|
},
|
||||||
|
"readme": "ERROR: No README data found!",
|
||||||
|
"scripts": {
|
||||||
|
"prepare": "presetter bootstrap",
|
||||||
|
"build": "run build",
|
||||||
|
"semantic-release": "semantic-release"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@lumeweb/libkernel": "^0.1.0-develop.16",
|
||||||
|
"p-defer": "^4.0.0"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"lib"
|
||||||
|
],
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,89 @@
|
||||||
|
import { Client, factory } from "@lumeweb/libkernel/module";
|
||||||
|
import defer from "p-defer";
|
||||||
|
import { CatOptions, LsOptions, StatOptions } from "@helia/unixfs";
|
||||||
|
|
||||||
|
interface AbortableGenerator {
|
||||||
|
abort: () => void;
|
||||||
|
iterable: () => AsyncIterable<Uint8Array>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const MODULE =
|
||||||
|
"zduTW8neeep7BcgyJyysyH5pSNPcLfS1EgTxVf3zncYbrJJQLxu9wjvzZM";
|
||||||
|
|
||||||
|
export class IPFSClient extends Client {
|
||||||
|
public async ready() {
|
||||||
|
return this.callModuleReturn("ready");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async stat(cid: string, options?: Partial<StatOptions>) {
|
||||||
|
return this.callModuleReturn("stat", { cid, options });
|
||||||
|
}
|
||||||
|
|
||||||
|
public ls(cid: string, options?: Partial<LsOptions>): AbortableGenerator {
|
||||||
|
return this.connectModuleGenerator("ls", { cid, options });
|
||||||
|
}
|
||||||
|
|
||||||
|
public cat(cid: string, options?: Partial<CatOptions>): AbortableGenerator {
|
||||||
|
return this.connectModuleGenerator("cat", { cid, options });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ipns(cid: string): Promise<string> {
|
||||||
|
return this.callModuleReturn("ipnsResolve", { cid });
|
||||||
|
}
|
||||||
|
|
||||||
|
public async activePeers(): Promise<number> {
|
||||||
|
return this.callModuleReturn("getActivePeers");
|
||||||
|
}
|
||||||
|
|
||||||
|
private connectModuleGenerator(
|
||||||
|
method: string,
|
||||||
|
data: any,
|
||||||
|
): AbortableGenerator {
|
||||||
|
let pipe = defer<Uint8Array>();
|
||||||
|
|
||||||
|
const [update, result] = this.connectModule(method, data, (item: any) => {
|
||||||
|
pipe.resolve(item);
|
||||||
|
});
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
const ret = await result;
|
||||||
|
this.handleError(ret);
|
||||||
|
pipe.resolve(undefined);
|
||||||
|
})();
|
||||||
|
|
||||||
|
return {
|
||||||
|
abort() {
|
||||||
|
update("abort");
|
||||||
|
},
|
||||||
|
|
||||||
|
iterable(): AsyncIterable<Uint8Array> {
|
||||||
|
return {
|
||||||
|
[Symbol.asyncIterator]() {
|
||||||
|
return {
|
||||||
|
async next(): Promise<IteratorResult<Uint8Array>> {
|
||||||
|
const chunk = await pipe.promise;
|
||||||
|
if (chunk === undefined) {
|
||||||
|
return {
|
||||||
|
value: new Uint8Array(),
|
||||||
|
done: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
pipe = defer();
|
||||||
|
|
||||||
|
update("next");
|
||||||
|
|
||||||
|
return {
|
||||||
|
value: chunk,
|
||||||
|
done: false,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const createClient = factory<IPFSClient>(IPFSClient, MODULE);
|
Loading…
Reference in New Issue