fairDataSociety / fairdrive-opfs

Fairdrive OPFS - integrate data sources from Web 2.0 or Web 3.0 using Origin Private File System
MIT License
1 stars 0 forks source link

Implement FDP Connector core #1

Closed tfius closed 1 year ago

molekilla commented 2 years ago

Fairdrive Connector Core contains an architecture similar to Solido, where:

Core classes

FairdriveConnectorModule

Creates a FairdriveConnector module.

Example:

import {
  FairdriveConnectorModule,
  FardriveConnectorProvider
} from '@fairdatasociety/connector/core';
import {
 FairOSProvider,
 FairOSConfiguration,
} from '@fairdatasociety/connector/providers';
import {
 IPFSProvider,
 IPFSConfiguration,
} from '@fairdatasociety/ipfs-provider';

// Create a FairdriveConnectorModule
export const module = new FairdriveConnectorModule({
  scopes: ["files:read", "directory:read"],
  queryEngine: "graphql", // graphql or rest
  "providers": [
    "fairos": {
      url: "http://fairos",
      beeUrl: "http://bee",
      provider: FairOSProvider,
    } as FairOSConfiguration,
    "ipfs": {
      url: "http://ipfs",
      beesonBridgeSync: "http://beeson-block-bridge", // beeson-multiformats brige
      gatewayUrl: "http://ipfs-gateway",
      provider: IPFSProvider
    } as IPFSConfiguration
  ],
});

const privateKey = '0x............';
const chainId = '1';
const rpcUrl = 'http://localhost:8545';
const web3Provider = window.ethereum;
const rpcChain = new Web3(rpcUrl, chainId);

// Provider constructor interface: Provider(baseProvider, options { signer })
const fairosConnector = module.bindConnection('fairos', new EthereumRPCProvider(rpcChain, privateKey));
const ipfsCeramicConnector = module.bindConnection('ipfs', new 3IDProvider(web3Provider))

// Query with REST API
await fairosConnector.fileSystem.listPods();

// Query with GraphQL
await fairosConnector.fileSystem.query(`pods() { name  }`);

// Query with  GraphQL from module
await module.query(
`pods() { name }`,
[
    fairosConnector,
    ipfsCeramicConnector,
])

// Signing request
await fairosConnector.fileSystem.uploadFile(..., { requestSignatureApproval: true } )

// Multiformats traversal query
await ipfsCeramicConnector.queryTraversal(...)

FairdriveConnectorProvider

Implements Fairdrive interface

tfius commented 2 years ago

NextCloud common storage class https://github.com/nextcloud/server/blob/master/lib/private/Files/Storage/Common.php

tfius commented 2 years ago

some points to take into consideration:

molekilla commented 1 year ago

complete