Node Sharing
Share device access with other users, transfer ownership, and manage sharing requests.
What This Module Does ?
Share — grant another user access (you stay owner). Transfer — hand off ownership. Manage requests — accept, decline, or cancel invitations.
| Goal | Method |
|---|---|
| Share access | node.shareWith() |
| Revoke access | node.removeSharingFor() |
| Transfer ownership | node.transferNode() |
| Invitations received | getReceivedNodeSharingRequests() |
| Invitations sent | getIssuedNodeSharingRequests() |
| Accept / decline | request.accept() / decline() |
| Cancel sent invite | request.remove() |
Expected outcome: Pending requests are created; recipients accept to gain access, or ownership transfers after acceptance.
Common Workflows
Share with another user
const requestId = await node.shareWith({
username: "family_member@example.com",
});
Revoke access
await node.removeSharingFor("former_user@example.com");
Transfer ownership
await node.transferNode({
toUserName: "new_owner@example.com",
selfToSecondary: false,
});
Accept a received invitation
const { sharedRequests } = await userInstance.getReceivedNodeSharingRequests();
const request = sharedRequests.find((r) => r.id === requestId);
await request.accept();
Decline or cancel
await request.decline();
const { sharedRequests } = await userInstance.getIssuedNodeSharingRequests();
await sharedRequests[0].remove();
End-to-end share flow
await node.shareWith({ username: "guest@example.com" });
// Guest session
const { sharedRequests } = await userInstance.getReceivedNodeSharingRequests();
await sharedRequests.find((r) => r.nodeId === node.id).accept();
// Owner revokes later
await node.removeSharingFor("guest@example.com");
Error Handling
try {
await node.shareWith({ username: targetUser });
} catch (error) {
console.error("Sharing failed:", error);
}
Fails if the username is invalid or sharing already exists.