![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.
ilp-protocol-psk2
Advanced tools
Javascript implementation of the Pre-Shared Key V2 Interledger Transport Protocol.
PSK2 is a request/response protocol built on ILP that can send value and/or data. It handles generating conditions and fulfillments for ILP Prepare/Fulfill packets to send value, and it encrypts and authenticates request and response data.
PSK2 can be used to send indivdiual payment chunks, unfulfillable test payments for quotes, and it can be used as part of a protocol/module for streaming or chunked payments.
npm install ilp-protocol-psk2
See https://interledgerjs.github.io/ilp-protocol-psk2
Uses createReceiver
and Receiver.generateAddressAndSecret
.
const { createReceive } = require('ilp-protocol-psk2')
const receiver = await createReceiver({
plugin: myLedgerPlugin,
requestHandler: (params) => {
// Fulfill the incoming request
// Note the data format and encoding is up to the application protocol / module
params.accept(Buffer.from('thanks for the payment!'))
console.log(`Got paid: ${params.amount} and got this data: ${params.data.toString()}`)
}
})
const { destinationAccount, sharedSecret } = receiver.generateAddressAndSecret()
// Give these two values to a sender to enable them to send payments to this Receiver
Try it out by running the example script.
Uses sendRequest
.
const { sendRequest } = require('ilp-protocol-psk2')
// These values must be communicated beforehand for the sender to send a payment
const { destinationAccount, sharedSecret } = await getAddressAndSecretFromReceiver()
const { fulfilled, destinationAmount, data } = await sendRequest(myLedgerPlugin, {
destinationAccount,
sharedSecret,
sourceAmount: '1000',
minDestinationAmount: '500',
data: Buffer.from('here you go!')
})
if (fulfilled) {
console.log(`Sent request with 1000 units of value attached, receiver got ${destinationAmount} and responded with the message: ${data.toString('utf8')}`)
// Note the data format and encoding is up to the application protocol / module
}
Try it out by running the example script.
Uses sendRequest
.
const { sendRequest } = require('ilp-protocol-psk2')
const { randomBytes } = require('crypto')
// These values must be communicated beforehand for the sender to send a payment
const { destinationAccount, sharedSecret } = await getAddressAndSecretFromReceiver()
const { destinationAmount } = await sendRequest(myLedgerPlugin, {
destinationAccount,
sharedSecret,
sourceAmount: '1000',
unfulfillableCondition: randomBytes(32)
})
console.log(`Path exchange rate is: ${destinationAmount.dividedBy(1000)}`
Try it out by running the example script.
FAQs
Implementation of the ILP Pre-Shared Key V2 Transport Protocol
We found that ilp-protocol-psk2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.