dDrive

所属分类:IPFS
开发工具:TypeScript
文件大小:0KB
下载次数:0
上传日期:2022-10-24 12:25:47
上 传 者sh-1993
说明:  Google Drive的替代存储解决方案,开源和完全去中心化,构建在InterPlanetary File Sy...之上...,
(?? An alternative storage solution to Google Drive, open-source and fully decentralized that is built on top of the InterPlanetary File System (IPFS))

文件列表:
.commitlintrc.json (63, 2022-10-24)
.editorconfig (245, 2022-10-24)
.env.example (401, 2022-10-24)
.eslintrc.json (753, 2022-10-24)
.husky/ (0, 2022-10-24)
.husky/commit-msg (80, 2022-10-24)
.prettierignore (74, 2022-10-24)
.prettierrc (26, 2022-10-24)
.vscode/ (0, 2022-10-24)
.vscode/extensions.json (181, 2022-10-24)
CONTRIBUTING.md (2172, 2022-10-24)
LICENSE (1068, 2022-10-24)
angular.json (134, 2022-10-24)
apps/ (0, 2022-10-24)
apps/browser/ (0, 2022-10-24)
apps/browser/.browserslistrc (600, 2022-10-24)
apps/browser/.eslintrc.json (799, 2022-10-24)
apps/browser/jest.config.ts (689, 2022-10-24)
apps/browser/ngsw-config.json (635, 2022-10-24)
apps/browser/project.json (6493, 2022-10-24)
apps/browser/src/ (0, 2022-10-24)
apps/browser/src/app/ (0, 2022-10-24)
apps/browser/src/app/app.component.html (137, 2022-10-24)
apps/browser/src/app/app.component.scss (0, 2022-10-24)
apps/browser/src/app/app.component.spec.ts (1017, 2022-10-24)
apps/browser/src/app/app.component.ts (448, 2022-10-24)
apps/browser/src/app/app.d.ts (284, 2022-10-24)
apps/browser/src/app/app.module.ts (6866, 2022-10-24)
apps/browser/src/app/components/ (0, 2022-10-24)
apps/browser/src/app/components/dropable/ (0, 2022-10-24)
apps/browser/src/app/components/dropable/dropable.component.html (398, 2022-10-24)
apps/browser/src/app/components/dropable/dropable.component.scss (1118, 2022-10-24)
apps/browser/src/app/components/dropable/dropable.component.spec.ts (607, 2022-10-24)
apps/browser/src/app/components/dropable/dropable.component.ts (341, 2022-10-24)
... ...

# dDrive - Decentralized Drive System > An alternative storage solution to Google Drive, open-source and fully decentralized that is built on top of the InterPlanetary File System (IPFS) Launch dDrive PWA with Valist distribution software [https://app.valist.io/d-drive/d-drive-pwa](https://app.valist.io/d-drive/d-drive-pwa) ## Project Description dDrive is a fully decentralized and open-source Storage solution which replace traditional storage providers having centralized governance, cumbersome infrastructure, inadequate security and privacy measures with users datasets. dDrive is build on top of IPFS and inherits all the features of Blockchain Technology to emerge as an immutable, censorship-resistant, tamper-proof and privacy complient with user dataset. ## Value Proposition dDrive integrat IPFS Core powered by Filecoin to enable users to store, manage and share their files in a decentralized way. Few of the core value propositions are: - Increased User Adoption: Providing a smooth and intuitive process with seamless user experience to store, manage and share files in a decentralized way will increase the adoption of IPFS and Filecoin. - Real-world utility: dDrive provide a real-world utility for censorship-resistant, tamper-proof and privacy complient storage solution by providing multi services composition that allow users to store and share files with total privacy and security controls of data access by using Encryption and Decryption technologies to increase data acces security. ## Overview ## Features **File Management** - [x] Create folder - [x] Delete folder - [x] Rename folder - [x] Move folder - [x] List files from folder - [x] Search files in folder - [x] Upload files to specific folder - [x] Download file - [x] Delete file - [x] Rename file - [x] Move file - [x] Share file with public url link - [x] Share file with custom access controls - [x] Preview file in app **NFTs Management** - [x] List NFTs from connected wallet - [x] Search NFTs by name - [x] Filter NFTs by chain **Others** - [x] Dark mode support - [x] Multi chain support - [x] Shared file Notifications - [x] File encryption - [x] File access control with wallet address - [x] Desktop app support using PWA technology ## Technology Stack - [IFPS Core](https://js.ipfs.tech) Browser implementation of the IPFS protocol to manage files storage and retrieval to IPFS network - [Pinata API](https://pinata.cloud) Pinning CID service to pin files to IPFS network - [Ceramic](https://ceramic.network) Decentralized database to manage storage metadata files and user profile data - [Lit Protocol](https://litprotocol.com) Decentralized Cryptography Access Control service to encrypt files and manage access control - [XMTP](https://xmtp.org/) Decentralized messaging service to manage in app notifications - [Ceramic 3id Connect](https://github.com/ceramicstudio/js-3id) Decentralized authentication service to manage user identity - [Ethersjs](https://docs.ethers.io/v5/) Ethereum SDK to manage Web3 wallet connection and account management - [Moralis NFT API](https://moralis.io) SDK to manage NFTs from Evm networks - [Valist](https://app.valist.io/) Software distribution tool to manage releases and updates hosted on IPFS ## Usage & Installation dDrive is a web application that can be used in any modern browser that have a [Metamask](https://metamask.io/download.html) Extension install. You can also install dDrive as a desktop application using Progressive Web App (PWA) technology by click `install` icon from browser url section or from `options` section of your browser. You can find more informations about PWA installation and specification [here](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Add_to_home_screen). **Distribution link to install dDrive PWA application:** [https://app.valist.io/d-drive/d-drive-pwa](https://app.valist.io/d-drive/d-drive-pwa) ## How it's built ### Authentication: 3id Connect & Etherjs dDrive use 3id Connect to manage user identity and Etherjs to manage Web3 wallet connection and account management.
Click to toggle contents of `code` implementaion ```typescript export class DIDService { async init(ethereumProvider: any) { if (this.did) { return this.did; } this.web3Provider = new ethers.providers.Web3Provider(ethereumProvider, 'any'); // Request accounts from the Ethereum provider const accounts = await this.web3Provider .send('eth_requestAccounts', []) .catch((err: any) => { throw `Error during Web3 Authetication: ${err?.message||'Unknown error'}`; }); if ((accounts?.length||0) === 0) { throw 'No accounts found. Please unlock your Ethereum account, refresh the page and try again.'; } const { chainId = (await this.web3Provider?.getNetwork())?.chainId} = (this.web3Provider.provider as any); if (!chainId) { throw 'No chainId found. Please unlock your Ethereum account, refresh the page and try again.'; } this.chainId$.next(chainId.replace('0x', '')); // listen event from provider this._listenEvent(this.web3Provider); // Create an EthereumAuthProvider using the Ethereum provider and requested account const account: string = accounts[0]; this.accountId$.next(account); this.did = new DID(); return this.did; } async connect() { const authProvider = new EthereumAuthProvider(this.web3Provider.provider, this.accountId$.value); // Connect the created EthereumAuthProvider to the 3ID Connect instance so it can be used to // generate the authentication secret const threeID = new ThreeIdConnect() await threeID.connect(authProvider); // Set the DID provider from the 3ID Connect instance this.did.setProvider(threeID.getDidProvider()); } } ``` > full implementation can be found here: [./apps/browser/src/app/services/did.service.ts](./apps/browser/src/app/services/did.service.ts)

### Database: Ceramic Network dDrive use Ceramic Network to manage storage metadata files and user profile data.
Click to toggle contents of `code` implementaion ```typescript export class CeramicService { private readonly _db: CeramicClient = new CeramicClient(environment.ceramic.apiHost); private readonly _datastore: DIDDataStore = new DIDDataStore({ ceramic: this._db, model: this._getAliases() }); async getAll() { if (!this._db?.did) { throw 'No DID found'; } const {dDrive: {documentID = null} = {}} = await this._getProfileFromCeramic()||{}; if (!documentID) { throw new Error('No documentID found'); } this._mainDocuumentId = documentID; const datas = await this.getData(documentID); return datas; } async saveData(data: { [key: string|number]: any; }) { if (!this._db?.did) { throw 'No DID found'; } const doc = await TileDocument.create(this._db, data); const _id = doc.id.toString(); // The stream ID of the created document can then be accessed as the `id` property return {_id}; } async updateData(data: { [key: string|number]: any; }, docId?: string) { if (!data?.['_id'] && !docId) { throw new Error('No _id found'); } if (!this._db?.did) { throw 'No DID found'; } data['lastModifiedIsoDateTime'] = new Date().toISOString(); const doc = await TileDocument.load(this._db, docId||data['_id']); await doc.update(data); return { ...doc.content as any, }; } async getData(key: string) { if (!this._db?.did) { throw 'No DID found'; } const doc = await TileDocument.load(this._db, key); return { ...doc.content as any, _id: doc.id.toString() }; } async updateUserProfil(value: Partial) { if (!this._db?.did) { throw 'No DID found'; } const {dDrive: {documentID = null, ...previousProfilData} = {}} = await this._getProfileFromCeramic()||{}; if (!documentID) { throw new Error('No documentID found'); } // save the document `id` to the profile data const dDrive: IUserProfil = { ...previousProfilData, ...value, latestConnectionISODatetime: new Date().toISOString(), documentID, } as IUserProfil; const updatedProfil = { dDrive }; await this._datastore.merge('BasicProfile', updatedProfil); return updatedProfil; } private async _setupProfile() { // create Document to store all files data const doc = await TileDocument.create(this._db, { files: [], lastModifiedIsoDateTime: new Date().toISOString() }); // save the document `id` to the profile data const dDrive: IUserProfil = { latestConnectionISODatetime: new Date().toISOString(), creationISODatetime: new Date().toISOString(), documentID: doc.id.toString(), }; await this._datastore.merge('BasicProfile', { dDrive }); return dDrive; } } ``` > full implementation can be found here: [./apps/browser/src/app/services/ceramic.service.ts](./apps/browser/src/app/services/ceramic.service.ts)

### File Storage: IPFS-Core & Pinata API dDrive use IPFS-Core to manage file storage.
Click to toggle contents of `code` implementaion ```typescript export class IPFSService { private _ipfsNode!: IPFS; constructor( private readonly _pinningService: IPFSPinningService ) {} async disconect() { if (this._ipfsNode) { await this._ipfsNode.stop(); } } async add(file: File | Blob) { if (!this._ipfsNode) { this._ipfsNode = await create(); } const nodeIsOnline = this._ipfsNode.isOnline(); if (!nodeIsOnline) { throw new Error('IPFS node is not online'); } const { cid } = await this._ipfsNode.add(file, { timeout: 10000, preload: true, progress: (prog) => console.log(`received: ${prog}`), }); // default call pin method await this.pin(cid.toString()); return { cid: cid.toString() }; } async pin(cid: string) { await this._pinningService.pin(cid); } async unpin(cid: string) { await this._pinningService.unpin(cid); } async getFromCID(cid: string, type?: string): Promise { if (!this._ipfsNode) { this._ipfsNode = await create(); } const nodeIsOnline = this._ipfsNode.isOnline(); if (!nodeIsOnline) { throw new Error('IPFS node is not online'); } const asyncUint8Array = this._ipfsNode.cat(cid, { timeout: 10000, preload: true, }); const blobsPart = []; for await (const chunk of asyncUint8Array) { blobsPart.push(chunk); } const file = new File(blobsPart, cid, { type }); return file; } } ``` > full implementation can be found here: [./apps/browser/src/app/services/ipfs.service.ts](./apps/browser/src/app/services/ipfs.service.ts) ```typescript export class PinataPinningService implements IPFSPinningService { constructor( private _pinningServiceConfig: { pinning_endpoint: string; unpinning_endpoint: string; token: string; } ) { } async pin(cid: string) { const url = this._pinningServiceConfig.pinning_endpoint; const token = this._pinningServiceConfig.token; if (!url || !token) { throw new Error('IPFS pinning service is not configured'); } const body = JSON.stringify({ "hashToPin": cid }); const config: RequestInit = { method: 'POST', body, headers: new Headers({ 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' }) }; await fetch(url, config) .then(res => res.json()) .catch(err => { throw err; }); } async unpin(cid: string) { const url = `${this._pinningServiceConfig.unpinning_endpoint}/${cid}`; const token = this._pinningServiceConfig.token; if (!url || !token) { throw new Error('IPFS pinning service is not configured'); } const config: RequestInit = { method: 'DELETE', headers: new Headers({ 'Authorization': `Bearer ${token}`, }) }; await fetch(url, config) .catch(err => { throw err; }); } } ``` > full implementation can be found here: [./apps/browser/src/app/services/pinata-pinning.service.ts](./apps/browser/src/app/services/pinata-pinning.service.ts)

### Cryptography Access Control: Lit Protocol dDrive use Lit Protocol to encrypt datas saving to IPFS and manage access control datas to enable users to share mediafile with other users have supported blockain wallet address.
Click to toggle contents of `code` implementaion ```typescript export class LitService { private async _connect() { const client: { connect: () => Promise } = new LitJsSdk.LitNodeClient( { debug: false } ); await client.connect(); this._litNodeClient = client; } async encrypt( file: File | Blob, accessControlConditions: IAccessControlConditions[], chain = this._chain ): Promise<{ encryptedFile: Blob; encryptedSymmetricKey: string; }> { if (!this._litNodeClient) { await this._connect(); } if (!this._authSig) { this._authSig = await this._getAuthSig(chain); } const { encryptedFile, symmetricKey } = await LitJsSdk.encryptFile({ file: file, }); const encryptedSymmetricKey = await this._litNodeClient.saveEncryptionKey({ accessControlConditions, symmetricKey, authSig: this._authSig, chain, permanent: false, }); return { encryptedFile, encryptedSymmetricKey: LitJsSdk.uint8arrayToString( encryptedSymmetricKey, 'base16' ), }; } async decrypt( encryptedFile: File | Blob, encryptedSymmetricKey: string, accessControlConditions: IAccessControlConditions[], chain = this._chain ): Promise<{ decryptedArrayBuffer: ArrayBuffer }> { if (!this._litNodeClient) { await this._connect(); } if (!this._authSig) { this._authSig = await this._getAuthSig(chain); } const symmetricKey = await this._litNodeClient.getEncryptionKey({ accessControlConditions, toDecrypt: encryptedSymmetricKey, chain, authSig: this._authSig, }); const decryptedArrayBuffer: ArrayBuffer = await LitJsSdk.decryptFile({ symmetricKey: symmetricKey, file: encryptedFile, }); return { decryptedArrayBuffer }; } async disconnect() { if (!this._litNodeClient) { return; } await LitJsSdk.disconnectWeb3(); this._litNodeClient = null; this._authSig = null; } } ``` > full implementation can be found here: [./apps/browser/src/app/services/lit.service.ts](./apps/browser/src/app/services/lit.service.ts)

### Notifications: XMTP Protocol dDrive use XMTP Protocol to send notifications to users when they receive new shared mediafile from other users.
Click to toggle contents of `code` implementaion ```typescript export class XMTPService { async init(web3Provider: ethers.providers.Web3Provider, opts?: ListMessagesOptions | undefined) { this._web3Provider = web3Provider; // Create the client with your wallet. // This will connect to the XMTP development network by default const xmtp = await Client.create(this._web3Provider.getSigner()); this._xmtp.next(xmtp); const {conversations = []} = await this.getConversations(); this._conversations.next(conversations); const messages = await this.getPreviousMessagesFromExistingConverstion(opts); this.messages$.next(messages); this._listenAllUpcomingMessages(); return xmtp; } async disconnect() { const xmtp = this._xmtp.getValue(); if (!xmtp) { return; } await xmtp.close(); this._xmtp.next(null as any); } async getConversations() { if (!this._web3Provider) { throw '{XMTPService} Web3Provider not found. Please unlock your Ethereum account, refresh the page and try again.'; } let xmtp = this._xmtp.getValue(); if (!xmtp) { xmtp = await this.init(this._web3Provider); } const conversations = await xmtp.conversations.list(); return { conversations }; } async getPreviousMessagesFromExistingConverstion( opts?: ListMessagesOptions | undefined ): Promise { const xmtp = this._xmtp.value; const messages = []; const conversations = this._conversations.getValue(); for (const conversation of conversations) { // All parameters are optional and can be omitted opts = opts ? opts : { // Only show messages from last 24 hours startTime: new Date(new Date().setDate(new Date().getDate() - 1)), endTime: new Date(), }; // get messages from conversation const messagesInConversation = await conversation .messages(opts) .then((messages) => { // filter out messages from self and return return messages.filter( (message) => message.senderAddress !== xmtp.address ); }); // add conversation and messages to messages array if (messagesInConversation.length > 0) { messages.push({ conversation, messagesInConversation, }); } }; return messages; } async sendMessage(conversation: Conversation, message: string) { if (!this._web3Provider) { throw '{XMTPService} Web3Provider not found. Please unlock your Ethereum account, refresh the page and try again.'; } await conversation.send(message); } async startNewConversation(address: string) { if (!this._web3Provider) { throw '{XMTPService} Web3Provider not found. Please unlock your Ethereum account, refresh the page and try again.'; } let xmtp = this._xmtp.getValue(); if (!xmtp) { xmtp = await this.init(this._web3Provider); } const conversation = await xmtp.conversations .newConversation(address) .catch((e) => { throw e?.message || `Failed to start conversation with ${address}`; }); // this._addListener(conversation); thi ... ...

近期下载者

相关文件


收藏者