
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
ilp-protocol-psk2
Advanced tools
Javascript implementation of the Pre-Shared Key V2 Interledger Transport Protocol.
npm install ilp-protocol-psk2
See https://emschwartz.github.io/ilp-protocol-psk2
Uses createReceiver
and Receiver.generateAddressAndSecret
.
import { createReceiver } from 'ilp-protocol-psk2'
const receiver = await createReceiver({
plugin: myLedgerPlugin,
paymentHandler: async (params) => {
// Accept all incoming payments
const result = await params.accept()
console.log('Got payment for:', result.receivedAmount)
}
})
const { destinationAccount, sharedSecret } = receiver.generateAddressAndSecret()
// Give these two values to a sender to enable them to send payments to this Receiver
Uses sendSingleChunk
and quoteDestinationAmount
.
import { sendSingleChunk, quoteDestinationAmount } from 'ilp-protocol-psk2'
// These values must be communicated beforehand for the sender to send a payment
const { destinationAccount, sharedSecret } = await getAddressAndSecretFromReceiver()
const { sourceAmount } = await quoteDestinationAmount(myLedgerPlugin, {
destinationAccount,
sharedSecret,
destinationAmount: '1000'
})
const result = await sendSingleChunk(myLedgerPlugin, {
destinationAccount,
sharedSecret,
sourceAmount,
minDestinationAmount: '999'
})
console.log(`Sent payment of ${result.sourceAmount}, receiver got ${result.destinationAmount}`)
Uses sendSingleChunk
.
import { randomBytes } from 'crypto'
import { sendSingleChunk } from 'ilp-protocol-psk2'
// These values must be communicated beforehand for the sender to send a payment
const { destinationAccount, sharedSecret } = await getAddressAndSecretFromReceiver()
const id = randomBytes(16)
let sequence = 0
const firstChunkResult = await sendSingleChunk(myLedgerPlugin, {
destinationAccount,
sharedSecret,
sourceAmount,
minDestinationAmount: '0',
id,
sequence,
lastChunk: false
})
// Repeat as many times as desired, incrementing the sequence each time
// Note that the path exchange rate can be determined by dividing the destination amount returned by the chunk amount sent
const lastChunkResult = await sendSingleChunk(myLedgerPlugin, {
destinationAccount,
sharedSecret,
sourceAmount,
minDestinationAmount: '0',
id,
sequence,
lastChunk: true
})
WARNING: PSK2 Chunked Payments are experimental. Money can be lost if an error occurs mid-payment or if the exchange rate changes dramatically! This should not be used for payments that are significantly larger than the path's Maximum Payment Size.
See sendSourceAmount
and sendDestinationAmount
.
FAQs
Implementation of the ILP Pre-Shared Key V2 Transport Protocol
The npm package ilp-protocol-psk2 receives a total of 9 weekly downloads. As such, ilp-protocol-psk2 popularity was classified as not popular.
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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.