Git Product home page Git Product logo

ts-odd's People

Contributors

appcypher avatar avivash avatar bgins avatar bmann avatar dependabot[bot] avatar dholms avatar expede avatar fubuloubu avatar gozala avatar icidasset avatar jeffgca avatar jessmartin avatar matheus23 avatar meandavejustice avatar nathanmalishev avatar nichoth avatar walkah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ts-odd's Issues

Pins branch

Problem

  • Our server needs to pin a user's private file tree, but it can't crawl it because it's..... private
    • right now this is accomplished with loose pins which are cumbersome to deal with
  • when a subtree is shared with a user, they should retain access to it even if the CID changes. So they need to be able to look up the current CID of the tree by using a given filepath

Solution

  • Add a single-layer /pins node off of the FS root
  • That node will include a list of all nodes in the private file system. The names of the nodes will be a hash of the name plus their DID which acts as a salt: sha(filename + did)
    An example snippet of this:
{ name: sha("private/index/file" + did), cid: "Qm123..." },
{ name: sha("private/index/file/index" + did), cid: "Qm456..." },
{ name: sha("private/index/file/isFile" + did), cid: "Qm789..." },
{ name: sha("private/index/file/mtime" + did), cid: "Qmabc..." },
...

TS Fission Auth Lib

Probably will live in its own library, but tracking for now:

Needs to be able to:

  • Create EdDSA key
  • Store via WebAuthn
  • Retrieve key from _did.someusername.fission.name TXT record
  • Validate self-signed tokens via PK

Eliminate impossible states on initialise

User feedback πŸ’Œ

With the StrictNullCheck enabled in Typescript, users are required to do:

case Scenario.AuthSucceeded:
case Scenario.Continuation:
  if (state.fs != null) {
    if (state.fs.appPath != null) {
      const appPath = state.fs.appPath();
      ...
    }
  }

Ideally we would not need to do these "null" checks, but not sure how much we could eliminate these. Seeing that the presence of these things depends on the options given to initialise. state.fs can be undefined if given the loadFileSystem: false option (which one may do to load the file system themselves in a web worker), and fs.appPath can be undefined if the permissions.app option was not set.

FileSystem caching

Problem

Traversing the filesystem can take a long time especially for deeply nested & private files which require multiple back and forths to the network with decryption in between.

Solution

  • Store a "cache" in the header of dirs that contains the subtree.
  • Update the cache as the subtree is updated.

Note: implementation is similar to the current "pins" implementation that is used to track nested pins for the private tree

Add functions for all API endpoints

We're deprecating https://github.com/fission-suite/typescript-client/ and moving most of that here.

Notes:

  • I don't think we need to support the legacy username/password stuff here.
  • Same thing for all the other deprecated things (correct me if I'm wrong)

Already implemented

  • Create user account with DID & UCAN (sdk.lobby.createAccount, lobby/index.ts)
  • Update user data root (sdk.dataRoot.update, data-root/index.ts)

Endpoints yet to implement

Apps

I would add this under sdk.apps

  • GET /app ☞ sdk.apps.index
  • POST /app ☞ sdk.apps.create
  • PATCH /app/{App URL}/{New CID} ☞ sdk.apps.setContent
  • DELETE /app/associated/{url} ☞ sdk.apps.deleteByUrl
  • DELETE /app/{appId} ☞ sdk.apps.deleteById

User

  • GET /user/whoami ☞ sdk.lobby.whoami or sdk.lobby.lookupUsername (not sure which)
  • PATCH /user/did ☞ sdk.did.update
  • PUT /user/exchange/keys/{did} ☞ sdk.exchange.addPublicKey (not a 100 on this)
  • DELETE /user/exchange/keys/{did} ☞ sdk.exchange.removePublicKey (not a 100 on this)

Error using chunk

The following occurs when I try to run:

var wnfs = await FileSystem.empty();
const cid = await wnfs.mkdir("private/gunclear/safe")

Error:

Unhandled Rejection (TypeError): o[Symbol.iterator] is not a function
./node_modules/fission-sdk/ipfs/basic.js/</__asyncValues<
http://localhost:3000/static/js/1.chunk.js:105016:96
./node_modules/fission-sdk/ipfs/basic.js/</add/</<
src/ipfs/basic.ts:11

   8 |     });
   9 | };
  10 | var __generator = (this && this.__generator) || function (thisArg, body) {
> 11 |     var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  12 |     return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  13 |     function verb(n) { return function (v) { return step([n, v]); }; }
  14 |     function step(op) {

step
http://localhost:3000/static/js/1.chunk.js:104996:17
./node_modules/fission-sdk/ipfs/basic.js/</__generator</verb/<
http://localhost:3000/static/js/1.chunk.js:104927:14
fulfilled

Delegated auth

Self-signed tokens with auth delegated via macaroons

  • Spec
  • Implementation

`Walk` method for trees

We need to walk trees for a few different features:

  • mv between branches of the FS
  • upgrade the structure of entire subtrees
  • any sort of aggregation

App API

const { app, state } = await sdk.initialise({
  permissions: {
    app: {
      creator: "Creator",
      name: "AppName"
    }
  }
})

// Clone the app to the user's filesystem (haven't decided how this will work yet)
app.clone()

// If the currently authed user has a copy of this app (ie. they cloned it), update those app files.
app.update()

// A sub graph, aka. scoped filesystem, of the app.
//
// ie. where you'd normally have `fs.ls("/private/Apps/Creator/AppName/...")`,
//     or `fs.ls(fs.appPath("..."))`
//     instead you would do:
app.fs.ls("...")

// Database
app.db()

Encrypt file's metadata with the header key not the parent key

Problem

Currently metadata for a node is encrypted with that node's parent key (the key used to encrypt that node), not the node's own key (the key contained as a header value in that node). Thus, when a user is given access to a file, they don't get access to the metadata that goes with it

Encrypt metadata with the node's ownKey instead of the parentKey

Specify js-ipfs version

So the filesystem doesn’t suddenly stop working. That said, window.ipfs is outside our control as well. Maybe switch entirely to js-ipfs (intead of get-ipfs), like we discussed before? πŸ€·β€β™‚οΈ

Stateful Filesystem

Problem

Right now the Filesystem is requires absolute paths to be passed to every function

Solution

Add a stateful Session class encapsulated by FileSystem so that a user can navigate the directory structure and use relative links

Some ideas here:

Adjust `isUsernameAvailable` function for new data-root lookup behaviour

Summary

Problem

isUsernameAvailable checks if dataRoot.lookup returns null, but dataRoot.lookup also returns null now for the initial appointed CID.

Impact

When creating an account it shows the username as available when the user hasn't created a file system yet. Thus falsy advertising the username as available.

Hard/soft links

hardLink :: Name -> VNode
softLink :: Name -> Maybe VNode

This means that hard links are guaranteed to have some data at the pointer. Soft links may not, hence the Maybe.

IPFS setup sometimes fails

Screenshot 2020-09-30 at 21 37 03

Browser: Firefox 81
OS: MacOS 11

Looks like the websocket connection fails and IPFS fails to start, causing initialise to fail entirely.

IPFS CIDv1

Upgrade IPFS CIDs to v1

We need to do this for dag nodes & for files

Shouldn't be able to make invalid UCANs

Problem

Currently you can make a UCAN that expires later than its proof. This shouldn't be possible. Additionally, less important, but still should be validated as well, the nbf should be greater than or equal to the nbf of the proof. To be precise regarding the exp field, it should be less than or equal to the exp of the proof.

Solution

When making a UCAN, get the exp and nbf of the proof (if it is present), and then adjust the default values if needed.

UCANs for app requests are missing their proof

https://github.com/fission-suite/webnative/blob/a4347b31cfec987ff718882e29cc88cff696091e/src/apps.ts#L24

This line, and the other similar ones for the other requests, should be something along the lines of:

proof: ucan_string

(see update-data-root function as an example: https://github.com/fission-suite/webnative/blob/a4347b31cfec987ff718882e29cc88cff696091e/src/data-root.ts)

Getting the proof

This is the "difficult" part of the changes need to be made.
We need to get the actual UCAN to use as the proof.
The easiest way to get this is by doing:

import * as ucanInternal from "./ucan/internal"
const proof = await ucanInternal.lookupFilesystemUcan("*")

We're revising various UCAN stuff soon, so this is just a temporary solution (hence the TODO's in the code).

PS.
In case you were wondering, this workaround works because the auth lobby returns a UCAN with the * resource. That UCAN is stored in indexeddb, which we then lookup by using lookupFilesystemUcan.

Typescript error: 'from' expected TS1005

Summary

Problem

I am in the process of switching out the old Fission Typescript client with the new webnative sdk in https://github.com/fission-suite/ipfs-photo-gallery/ and have run into a Typescript error:

/ipfs-photo-gallery/node_modules/webnative/index.d.ts
TypeScript error in /Users/patdryburgh/Development/ipfs-photo-gallery/node_modules/webnative/index.d.ts(49,10):
'from' expected.  TS1005

    47 | export * from './filesystem';
    48 | export declare const fs: typeof FileSystem;
  > 49 | export * as dataRoot from './data-root';
       |          ^
    50 | export * as did from './did';
    51 | export * as lobby from './lobby';
    52 | export * as setup from './setup';

Impact

Not sure how to proceed until this error is fixed and not sure exactly what's causing it. I've created a PR in the IPFS Photo Gallery repo so you can see what I've done so far and suggest what I might be doing wrong. Happy to provide any other details you require :)

fission-codes/ipfs-photo-gallery#20

Remove syncHook and move dataRoot updating to a submodule

A user of the SDK shouldn't have to know about the "data root".

To do:

  • The SDK should automatically update the data root after a file-system change
  • The API endpoint should be configurable
  • This data-root-updating call to the API should be debounced/throttled
  • Should not be called when offline
  • Should be called automatically when the user comes back online (after changes were made offline)

Metadata

Problem

Filesystem supports directories & files with a bare minimum of metadata (currently just mtime)

Solution

Add metadata layer:

  • dirs/files are 2-layers where a cid points to a folder containing metadata as well as an index link to the actual file/dir contents
  • semver for metadata so that filesystems can interop with filesystems on a different version

Registering via auth lobby fails on Brave fails

Summary

Creating a new user on the Brave browser fails.

Problem

Throws this error Public key MIIB...QAB already exists
Which is when the function call mkdir fails out.

Impact

Brave users can not register to the service

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: macbook pro
  • OS: macOS 10.15.6
  • Brave Version 1.11.104 Chromium: 84.0.4147.105 (Official Build) (64-bit)

Retry updating the data-root when 504 response from server

The API can return a 504 status when the IPFS gateway is still fetching the data from your in-browser js-ipfs node. We should retry this until it succeeds.

Additionally we should cancel long-running data-root requests, whenever a new request is made.

File system content not always available on Fission gateway

When setting the data root, we'll want to wait on the API to tell us the content was successfully fetched from our local js-ipfs node. In other words, the data from our file system lives on our local js-ipfs node and we need to wait until that is transferred to the Fission gateway.

More notes:

  • The user cannot close the window before this action is finished, show a dialogue when trying to close the window.
  • If this were not solved, you can have an infinite loader on your app and possibly lose your file system

DNSLink fallback doesn't work

We have a DNSLink-lookup fallback that uses Cloudflare, but instead of returning the CID (like ipfs.io's api does), it returns an IPNS reference (eg. ipns=icidasset-test-6.fissionuser.net/public)

Consider creating our own IPLD format

Problem

Encrypted DAG nodes are not dag-pb/dag-cbor formatted. They may be formatted as such under the hood but you won't be able to do file paths like Qm.../path/to/file.

Solution

We could define our own IPLD format for encrypted folders/files. This would also eliminate the need for a header subdir on every folder (thereby decreasing the # of objects needed to fetch by 2x)

Relevant discussion: ipld/ipld#64

Helper for adding file to folder

Problem

Adding a file to a folder needs to recurse up through the IPLD tree

Solution

  • Add a helper for doing that^
  • Handle private files by checking if the directory has a header folder w/ a key in it

Investigate CIDv1

Problem

FFS should handle CIDv1. Right now this causes conflicts when accessing uploading files from the gateway or through ipfs UnixFS commands (such as ipfs.ls)
See #16 for more details

Solution

Investigate some solutions to get this working. It might be as simple as upgrading the server node to the latest version of IPFS (a good practice regardless)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.