![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
@l2-technology/sensei-client
Advanced tools
A javascript client for the Sensei HTTP API. This is designed to work in the browser and in NodeJS environments. It is written in typescript and all endpoints are fully typed.
Can be added to your project by running npm install --save @l2-technology/sensei-client
When using from the browser you can rely on login
and logout
to set a cookie with a macaroon
that will automatically be passed for future requests.
When using from nodeJS you can use setMacaroon
to explicitly set a macaroon to use for the client instance.
Instantiate and export a client to use from a utils/integration file
// src/utils/sensei.ts
import SenseiClient from '@l2-technology/sensei-client';
const senseiHost = 'http://localhost:3000';
const senseiClient = new SenseiClient({ basePath: senseiHost });
export default senseiClient;
Import your client and use it
import senseiClient from './src/utils/sensei';
// initialize your sensei node
const { pubkey, macaroon } = await senseiClient.init({
username: 'satoshi',
alias: 'satoshi',
passphrase: 'donthardcodethissomewhere',
electrumUrl: 'ssl://blockstream.info:993',
start: true,
});
senseiClient.setMacaroon(macaroon);
// send bitcoin to this address to fund your node
const { address } = await senseiClient.getUnusedAddress();
// create lightweight child node
const { alicePubkey, aliceMacaroon } = await senseiClient.createNode({
username: 'alice',
alias: 'alice',
passphrase: 'alicespassphrase',
start: true,
});
// search nodes for alice
const { nodes } = await senseiClient.getNodes({
page: 0,
searchTerm: alicePubkey,
take: 1,
});
const aliceNodeInfo = nodes[0];
const { listenAddr, listenPort } = aliceNodeInfo;
// open a public channel with alice
await senseiClient.openChannel({
nodeConnectionString: `${alicePubkey}@${listenAddr}:${listenPort}`,
amtSatoshis: 25000,
isPublic: true,
});
// have alice generate an invoice for 1000 satoshis
senseiClient.setMacaroon(aliceMacaroon);
const { invoice } = await senseiClient.createInvoice({
amountMillisats: 1000000,
description: 'paying for some coffee',
});
// have admin node pay the invoice
senseiClient.setMacaroon(macaroon);
await senseiClient.payInvoice(invoice);
FAQs
A javascript client for the Sensei HTTP API
The npm package @l2-technology/sensei-client receives a total of 0 weekly downloads. As such, @l2-technology/sensei-client popularity was classified as not popular.
We found that @l2-technology/sensei-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.