Class FileSystem

🪺 :: START HERE

Mounting

  • Create a new private node and mount it.

    Parameters

    • node: {
          exchangeKeyPair: {
              privateKey: CryptoKey;
              publicKey: Uint8Array | CryptoKey;
          };
          kind?: Kind;
          path: Segments;
      }
    • Optional mutationOptions: MutationOptions

    Returns Promise<{
        capsuleKey: Uint8Array;
        path: [Path.Private, ...string[]];
        shareId: string;
    }>

  • Parameters

    Returns Promise<{
        capsuleKey: Uint8Array;
        path: [Path.Private, ...string[]];
    }>

  • Mount a private node onto the file system.

    Parameters

    • node: {
          capsuleKey: Uint8Array;
          path: Segments;
      } | {
          exchangeKeyPair: {
              privateKey: CryptoKey;
              publicKey: Uint8Array | CryptoKey;
          };
          path: Segments;
          shareId?: string;
      }

    Returns Promise<void>

  • Mount private nodes onto the file system.

    This supports two scenarios:

    • Load a private node using a capsule key
    • Load a private node using an exchange key pair (this is a share made to one of your own exchange keys)

    Parameters

    • nodes: ({
          capsuleKey: Uint8Array;
          path: Segments;
      } | {
          exchangeKeyPair: {
              privateKey: CryptoKey;
              publicKey: Uint8Array | CryptoKey;
          };
          path: Segments;
          shareId?: string;
      })[]

    Returns Promise<void>

Querying

ls: {
    (path, listOptions): Promise<DirectoryItemWithKind[]>;
    (path, listOptions): Promise<DirectoryItem[]>;
    (path): Promise<DirectoryItem[]>;
    (path, listOptions?): Promise<DirectoryItem[] | DirectoryItemWithKind[]>;
} = ...

Type declaration

  • Type Parameters

    Parameters

    • path: [Partition, string, ...string[]] | {
          contentCID: CID<unknown, number, number, Version>;
      } | {
          capsuleCID: CID<unknown, number, number, Version>;
      } | {
          capsuleKey: Uint8Array;
      }
    • dataType: D
    • Optional options: {
          length?: number;
          offset?: number;
      }
      • Optional length?: number
      • Optional offset?: number

    Returns Promise<DataForType<D, V>>

Mutating

cp: (<From, To>(from, to, mutationOptions?) => Promise<MutationResult<To>>) = ...

Type declaration

mkdir: (<P>(path, mutationOptions?) => Promise<MutationResult<P>>) = ...

Type declaration

mv: (<From, To>(from, to, mutationOptions?) => Promise<MutationResult<To>>) = ...

Type declaration

rm: ((path, mutationOptions?) => Promise<"no-op" | {
    dataRoot: CID<unknown, number, number, Version>;
}>) = ...

Type declaration

    • (path, mutationOptions?): Promise<"no-op" | {
          dataRoot: CID<unknown, number, number, Version>;
      }>
    • Parameters

      Returns Promise<"no-op" | {
          dataRoot: CID<unknown, number, number, Version>;
      }>

Transacting

Events

  • Get an async iterator which buffers a tuple of an event name and data each time an event is emitted.

    Call return() on the iterator to remove the subscription.

    In the same way as for events, you can subscribe by using the for await statement.

    Returns AsyncIterable<[keyof Events, {
        dataRoot: CID<unknown, number, number, Version>;
        modifications: Modification[];
    } | {
        dataRoot: CID<unknown, number, number, Version>;
        modifications: Modification[];
    }]>

  • Remove an onAny subscription.

    Parameters

    • listener: ((eventName, eventData) => void | Promise<void>)
        • (eventName, eventData): void | Promise<void>
        • Parameters

          • eventName: keyof Events
          • eventData: {
                dataRoot: CID<unknown, number, number, Version>;
                modifications: Modification[];
            } | {
                dataRoot: CID<unknown, number, number, Version>;
                modifications: Modification[];
            }

          Returns void | Promise<void>

    Returns void

Misc

Methods

Properties

#blockstore: Blockstore<{}, {}, {}, {}, {}, {}, {}, {}>

Type declaration

    Type declaration

      Type declaration

        Type declaration

          Type declaration

            Type declaration

              Type declaration

                Type declaration

                  #debouncedDataRootUpdate: ((...args) => Promise<void>)

                  Type declaration

                    • (...args): Promise<void>
                    • Parameters

                      • Rest ...args: {
                            dataRoot: CID<unknown, number, number, Version>;
                            modifications: Modification[];
                        }[]

                      Returns Promise<void>

                  #eventEmitter: Emittery<Events, Events & OmnipresentEventData, never>
                  #onCommit: CommitVerifier
                  #privateNodes: MountedPrivateNodes = {}
                  #rng: Rng
                  #rootTree: RootTree

                  Sharing

                  • Check if an exchange key was already registered.

                    Parameters

                    Returns Promise<boolean>

                  • Load a shared item.

                    NOTE: A share can only be received if the exchange key was registered and the receiver is in possession of the associated private key.

                    Parameters

                    • sharerDataRoot: CID<unknown, number, number, Version>

                      The data root CID from the sharer

                    • exchangeKeyPair: {
                          privateKey: CryptoKey;
                          publicKey: Uint8Array | CryptoKey;
                      }

                      A RSA-OAEP-256 key pair

                      • privateKey: CryptoKey

                        A RSA-OAEP-256 private key in the form of a CryptoKey

                      • publicKey: Uint8Array | CryptoKey

                        A RSA-OAEP-256 public key in the form of a CryptoKey or its modulus bytes

                    • opts: {
                          shareId?: string;
                          sharerBlockstore?: Blockstore<{}, {}, {}, {}, {}, {}, {}, {}>;
                          sharerRootTreeClass?: typeof RootTree;
                      } = {}

                      Optional overrides

                      • Optional shareId?: string

                        Specify what shareId to use, otherwise this'll load the last share that was made to the given exchange key.

                      • Optional sharerBlockstore?: Blockstore<{}, {}, {}, {}, {}, {}, {}, {}>

                        Specify what blockstore to use to load the sharer's file system.

                      • Optional sharerRootTreeClass?: typeof RootTree

                        Specify what root tree class was used for the sharer's file system.

                    Returns Promise<Share>

                  • Register an exchange key.

                    Parameters

                    • name: string

                      A name for the key (using an existing name overrides the old key)

                    • exchangePublicKey: Uint8Array | CryptoKey

                      A RSA-OAEP-256 public key in the form of a CryptoKey or its modulus bytes

                    • mutationOptions: MutationOptions = {}

                      Mutation options

                    Returns Promise<{
                        dataRoot: CID<unknown, number, number, Version>;
                    }>

                  • Share a private file or directory.

                    NOTE: A share can only be received if the exchange key was registered and the receiver is in possession of the associated private key.

                    Parameters

                    • path: [Path.Private, ...string[]]

                      Path to the private file or directory to share (with 'private' prefix)

                    • receiverDataRoot: CID<unknown, number, number, Version>

                      Data root CID of the receiver

                    • opts: {
                          mutationOptions?: MutationOptions;
                          receiverBlockstore?: Blockstore<{}, {}, {}, {}, {}, {}, {}, {}>;
                          receiverRootTreeClass?: typeof RootTree;
                      } = {}

                      Optional overrides

                      • Optional mutationOptions?: MutationOptions

                        Mutation options

                      • Optional receiverBlockstore?: Blockstore<{}, {}, {}, {}, {}, {}, {}, {}>

                        Specify what blockstore to use to load the receiver's file system

                      • Optional receiverRootTreeClass?: typeof RootTree

                        Specify what root tree class was used for the receiver's file system

                    Returns Promise<{
                        shareId: string;
                    } & {
                        capsuleKey: Uint8Array;
                        dataRoot: CID<unknown, number, number, Version>;
                    }>

                  Generated using TypeDoc