12.1.0 • Published 1 month ago

@tkey/share-transfer v12.1.0

Weekly downloads
46
License
MIT
Repository
github
Last release
1 month ago

tKey Share Transfer Module

npm version minzip

The Share Transfer Module helps you add or remove the and password as a share for tkey. This module is the part of the tKey SDK.

Installation

npm install --save @tkey/share-transfer

Initialization

Import the ShareTransferModule class from @tkey/share-transfer

import ShareTransferModule from "@tkey/share-transfer";

Assign the ShareTransferModule class to a variable

const shareTransferModule = new ShareTransferModule();

Returns

The ShareTransferModule class returns an object with the following properties:

declare class ShareTransferModule implements IModule {
  moduleName: string;
  tbSDK: ITKeyApi;
  currentEncKey: BN;
  requestStatusCheckId: number;
  requestStatusCheckInterval: number;
  constructor();
  static refreshShareTransferMiddleware(
    generalStore: unknown,
    oldShareStores: ShareStoreMap,
    newShareStores: ShareStoreMap
  ): ShareTransferStorePointer;
  setModuleReferences(tbSDK: ITKeyApi): void;
  setRequestStatusCheckInterval(interval: number): void;
  initialize(): Promise<void>;
  requestNewShare(
    userAgent: string,
    availableShareIndexes: Array<string>,
    callback?: (err?: ITkeyError, shareStore?: ShareStore) => void
  ): Promise<string>;
  addCustomInfoToShareRequest(encPubKeyX: string, customInfo: string): Promise<void>;
  lookForRequests(): Promise<Array<string>>;
  approveRequest(encPubKeyX: string, shareStore?: ShareStore): Promise<void>;
  approveRequestWithShareIndex(encPubKeyX: string, shareIndex: string): Promise<void>;
  getShareTransferStore(): Promise<ShareTransferStore>;
  setShareTransferStore(shareTransferStore: ShareTransferStore): Promise<void>;
  startRequestStatusCheck(encPubKeyX: string, deleteRequestAfterCompletion: boolean): Promise<ShareStore>;
  cancelRequestStatusCheck(): Promise<void>;
  deleteShareTransferStore(encPubKey: string): Promise<void>;
  resetShareTransferStore(): Promise<void>;
  private _cleanUpCurrentRequest;
}

Usage

With the ShareTransferModule, you've access to the following functions:

Request a new share

requestNewShare(userAgent: string, availableShareIndexes: Array<string>, callback?: (err?: ITkeyError, shareStore?: ShareStore) => void)

  • userAgent: The user agent of the client that is requesting a new share.
  • availableShareIndexes: An array of share indexes that are available for the client.
  • callback: A callback function that is called when the request is complete.

Return

  • Promise<string>: Share index of the new share.

Add custom info to share request

addCustomInfoToShareRequest(encPubKeyX: string, customInfo: string)

  • encPubKeyX: The public key of the share that is being requested.
  • customInfo: The custom info that is being added to the share request.

Look for requests

lookForRequests()

Return

  • Promise<Array<string>>: An array of indexes of pending requests

Approve request

approveRequest(encPubKeyX: string, shareStore?: ShareStore)

  • encPubKeyX: The public key of the share that is being approved.
  • shareStore: The share store that is being approved.

Approve request with share index

approveRequestWithShareIndex(encPubKeyX: string, shareIndex: string)

  • encPubKeyX: The public key of the share that is being approved.
  • shareIndex: The share index that is being approved.

Get share transfer store

getShareTransferStore()

Return

  • Promise<ShareTransferStore>: The share transfer store.

Set share transfer store

setShareTransferStore(shareTransferStore: ShareTransferStore)

  • shareTransferStore: The share transfer store.

Start request status check

startRequestStatusCheck(encPubKeyX: string, deleteRequestAfterCompletion: boolean)

  • encPubKeyX: The public key of the share that is being checked.
  • deleteRequestAfterCompletion: Whether or not to delete the request after it is completed.

Return

  • Promise<ShareStore>: The share store.

Cancel request status check

cancelRequestStatusCheck()

Delete share transfer store

deleteShareTransferStore(encPubKey: string)

  • encPubKey: The public key of the share that is being deleted.

Reset share transfer store

resetShareTransferStore()

12.1.0

1 month ago

10.0.0

10 months ago

12.0.0

7 months ago

11.0.2

9 months ago

11.0.3

8 months ago

11.0.0

9 months ago

11.0.1

9 months ago

10.1.0

10 months ago

8.1.0-alpha.0

1 year ago

9.0.0

1 year ago

7.4.0

1 year ago

7.3.0

1 year ago

8.0.5-alpha.0

1 year ago

8.0.7-alpha.0

1 year ago

8.0.6-alpha.0

1 year ago

8.0.0-alpha.0

1 year ago

7.2.0

1 year ago

7.1.0

1 year ago

6.1.0

2 years ago

6.2.0

2 years ago

7.0.0

2 years ago

6.0.0

2 years ago

5.1.4

2 years ago

5.1.3

2 years ago

5.1.2

2 years ago

5.1.1

2 years ago

5.1.0

2 years ago

5.0.0

2 years ago

4.4.0-alpha.0

3 years ago

4.4.0-y.0

3 years ago

4.4.0-alpha.4

3 years ago

4.4.0-alpha.3

3 years ago

4.4.0-alpha.2

3 years ago

4.4.0-alpha.1

3 years ago

4.4.0

3 years ago

4.3.0

3 years ago

4.2.1

3 years ago

4.2.0

3 years ago

4.1.1

3 years ago

4.1.0

3 years ago

4.0.1

3 years ago

4.0.2

3 years ago

3.14.1

3 years ago

3.14.2

3 years ago

4.0.0

3 years ago

3.14.0

3 years ago

3.12.1

3 years ago

3.12.0

3 years ago

3.11.1

3 years ago

3.11.0

3 years ago

3.10.0

3 years ago

3.9.1

3 years ago

3.9.0

3 years ago

3.8.0

3 years ago

3.7.0

3 years ago

3.6.5

3 years ago

3.6.2

3 years ago

3.6.3

3 years ago

3.6.1

3 years ago

3.6.0

3 years ago

3.5.0

3 years ago

3.4.0

3 years ago

3.2.2

3 years ago

3.2.1

3 years ago

3.2.0

3 years ago

3.1.1

3 years ago

3.1.0

3 years ago

3.0.3

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago