NameManager

Provides methods for managing names in an REST endpoint.

Constructor

new NameManager(clientKey, clientSecret)

Creates a new instance of the constructor.

Parameters:
NameTypeDescription
clientKeystring

The access key ID for authentication.

clientSecretstring

The secret access key for authentication.

Tutorials
Example
import { NameManager } from "@filebase/sdk";
const nameManager = new NameManager("KEY_FROM_DASHBOARD", "SECRET_FROM_DASHBOARD");

Methods

(async) create(label, cid, optionsopt) → {Promise.<name>}

Creates a new IPNS name with the given name as the label and CID.

Parameters:
NameTypeAttributesDescription
labelstring

The label of the new IPNS name.

cidstring

The CID of the IPNS name.

optionsnameOptions<optional>

Additional options for the IPNS name.

Returns:
  • A Promise that resolves with the response JSON.
Type: 
Promise.<name>
Example
// Create IPNS name with label of `create-name-example` and CID of `QmdmQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm`
await nameManager.create(`create-name-example`, `QmdmQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm`);

(async) import(label, cid, privateKey, optionsopt) → {Promise.<name>}

Imports a user's IPNS private key.

Parameters:
NameTypeAttributesDescription
labelstring

The label for the IPNS name.

cidstring

The CID (Content Identifier) of the data.

privateKeystring

The existing private key encoded in Base64.

optionsnameOptions<optional>

Additional options for the IPNS name.

Returns:
  • A Promise that resolves to the server response.
Type: 
Promise.<name>
Example
// Import IPNS private key with label of `create-name-example`, CID of `QmdmQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm`
// and a private key encoded with base64
await nameManager.import(
 `create-name-example`,
 `QmdmQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm`
 `BASE64_ENCODED_PRIVATEKEY`
);

(async) update(label, cid, options) → {Promise.<boolean>}

Updates the specified name with the given CID.

Parameters:
NameTypeDescription
labelstring

The label of the name to update.

cidstring

The cid to associate with the name.

optionsnameOptions

The options for the set operation.

Returns:
  • A Promise that resolves to true if the IPNS name was updated.
Type: 
Promise.<boolean>
Example
// Update name with label of `update-name-example` and set the value of the IPNS name.
await nameManager.update(`update-name-example`, `bafybeidt4nmaci476lyon2mvgfmwyzysdazienhxs2bqnfpdainzjuwjom`);

(async) get(label) → {Promise.<name>}

Returns the value of an IPNS name

Parameters:
NameTypeDescription
labelstring

Parameter representing the label of the name to resolve.

Returns:
  • A promise that resolves to the value of a name.
Type: 
Promise.<name>
Example
// Get IPNS name with label of `list-name-example`
await nameManager.get(`list-name-example`);

(async) list() → {Promise.<Array.<name>>}

Returns a list of IPNS names

Returns:
  • A promise that resolves to an array of names.
Type: 
Promise.<Array.<name>>
Example
// List all IPNS names
await nameManager.list();

(async) delete(label) → {Promise.<boolean>}

Deletes an IPNS name with the given label.

Parameters:
NameTypeDescription
labelstring

The label of the IPNS name to delete.

Returns:
  • A promise that resolves to true if the IPNS name was successfully deleted.
Type: 
Promise.<boolean>
Example
// List IPNS name with label of `delete-name-example`
await nameManager.delete(`delete-name-example`);

(async) toggle(label, targetState) → {Promise.<boolean>}

Toggles the enabled state of a given IPNS name.

Parameters:
NameTypeDescription
labelstring

The label of the IPNS name to toggle.

targetStateboolean

The new target state.

Returns:

A promise that resolves to true if the IPNS name was successfully toggled.

Type: 
Promise.<boolean>
Example
// Toggle IPNS name with label of `toggle-name-example`
await nameManager.toggle(`toggle-name-example`, true);  // Enabled
await nameManager.toggle(`toggle-name-example`, false); // Disabled