Constructor
new NameManager(clientKey, clientSecret)
Creates a new instance of the constructor.
Name | Type | Description |
---|---|---|
clientKey | string | The access key ID for authentication. |
clientSecret | string | The secret access key for authentication. |
- Source
- Tutorials
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.
Name | Type | Attributes | Description |
---|---|---|---|
label | string | The label of the new IPNS name. | |
cid | string | The CID of the IPNS name. | |
options | nameOptions | <optional> | Additional options for the IPNS name. |
- Source
- A Promise that resolves with the response JSON.
- Type:
- Promise.<name>
// 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.
Name | Type | Attributes | Description |
---|---|---|---|
label | string | The label for the IPNS name. | |
cid | string | The CID (Content Identifier) of the data. | |
privateKey | string | The existing private key encoded in Base64. | |
options | nameOptions | <optional> | Additional options for the IPNS name. |
- Source
- A Promise that resolves to the server response.
- Type:
- Promise.<name>
// 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.
Name | Type | Description |
---|---|---|
label | string | The label of the name to update. |
cid | string | The cid to associate with the name. |
options | nameOptions | The options for the set operation. |
- Source
- A Promise that resolves to true if the IPNS name was updated.
- Type:
- Promise.<boolean>
// 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
Name | Type | Description |
---|---|---|
label | string | Parameter representing the label of the name to resolve. |
- Source
- A promise that resolves to the value of a name.
- Type:
- Promise.<name>
// 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
- Source
- A promise that resolves to an array of names.
- Type:
- Promise.<Array.<name>>
// List all IPNS names
await nameManager.list();
(async) delete(label) → {Promise.<boolean>}
Deletes an IPNS name with the given label.
Name | Type | Description |
---|---|---|
label | string | The label of the IPNS name to delete. |
- Source
- A promise that resolves to true if the IPNS name was successfully deleted.
- Type:
- Promise.<boolean>
// 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.
Name | Type | Description |
---|---|---|
label | string | The label of the IPNS name to toggle. |
targetState | boolean | The new target state. |
- Source
A promise that resolves to true if the IPNS name was successfully toggled.
- Type:
- Promise.<boolean>
// 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