
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
@waves/signature-adapter
Advanced tools
$ npm install --save @waves/signature-adapter
import { SeedAdapter, SIGN_TYPE } from '@waves/signature-adapter';
import { Money, Asset } from '@waves/data-entities';
const asset = new Asset({
ticker: 'WAVES',
id: 'WAVES',
name: 'Waves',
precision: 8,
description: '',
height: 0,
timestamp: new Date('2016-04-11T21:00:00.000Z'),
sender: '',
quantity: 10000000000000000,
reissuable: false
});
const transferTransactionData = {
recipient: 'some address or alias',
amount: Money.fromTokens(1, asset),
attachment: 'Some attachment text less 140 bytes',
fee: Money.fromTokens(0.001, asset)
};
const adapter = new SeedAdapter('some seed phrase with 15 or more chars');
const signable = adapter.makeSignable({
type: SIGN_TYPE.TRANSFER,
data: transferTransactionData
});
signable.getDataForApi().then(data => fetch('node-url', {
method: 'POST',
body: JSON.stringify(data)
}));
Adapters are used to sign data. There are two types of adapters: SeedAdapter - is an adapter for usage with seed in string representation LedgerAdapter - is an adapter for usage with Ledger hardware wallet
SeedAdapter accepts either a seed phrase or an object containing information about the seed phrase on create Object structure: encryptedSeed {string} - seed phrase encoded with passwords password {string} - password that is encrypted seed phrase encryptionRounds {number} - encryption complexity
For change network byte use @waves/signature-generator config:
import { config } from '@waves/signature-generator';
config.set('networkByte', 'T'.charCodeAt(0))
If you use seed phrase to create SeedAdapter note that the minimum length of a phrase is 15 characters. See the documentation @waves/signature-generator for more details
Example of creation SeedAdapter with seed phrase:
import { SeedAdapter } from '@waves/signature-adapter';
const adapter = new SeedAdapter('some seed phrase more 15 chars');
SeedAdapter accepts an object that contains information about an address and wallet ID in Ledger on create Object structure:
To get an objects for creating an instance of LedgerAdapter there is a static method of the class "getUserList".
Where ‘from’ is wallet ID in the Ledger from which to start receiving data, ‘to’ - the number to finish.
Example:
import { LedgerAdapter } from '@waves/signature-adapter';
LedgerAdapter.getUserList().then(([userData]) => new LedgerAdapter(userData));
isAvailable(): Promise<void>; Returns promise which returns an error in case the adapter is unavailable.
getPublicKey(): Promise<string>; Returns a public key
getAddress(): Promise<string>; Returns an address
getPrivateKey(): Promise<string>; Returns a private key or an error If adapter is not able to return it (in case of LedgerAdapter)
signRequest(bytes: Uint8Array): Promise<string>; Accepts byte array for signing, returns promise with a signature. This method is used for signing any data except transactions and orders
signTransaction(bytes: Uint8Array): Promise<string>; Accepts byte array for signing, returns promise with a signature. This method is used for signing transactions
signOrder(bytes: Uint8Array): Promise<string>; Accepts byte array for signing, returns promise with a signature. This method is used for signing orders
signData(bytes: Uint8Array): Promise<string>; Accepts byte array for signing, returns promise with a signature. This method is used for signing any data This method is not recommended for signing transactions due to incorrect confirmation display on Ledger
getSeed(): Promise<string>; Returns the seed phrase or an error If adapter is not able to return it (in case of LedgerAdapter)
makeSignable(signData): Signable; Accepts data for signature (Visit interfaces for more information about “TSignData” interface) and returns an instance of the Signable class
getTxData(): {object}; Returns a copy of the object data transferred for signature
getSignData(): Promise<object>; Returns data for signing as received for making signature @waves/signature-generator
addProof(proof: string): Signable; Accepts the signature for adding it to the signature list. Signature list is used for "getDataForApi" method
getId(): Promise<string>; Returns promise with hash of all data used for signature
sign(): Promise<Signable>; Method initiates signing and returns promise that waits the completion of signing. This method adds only one signature for the lifetime of one instance of the Signable class. When you call it again it returns a previously created promise
getSignature(): Promise<string>; Acts same as sign() method, but returns promise with signature
getBytes(): Promise<Uint8Array>; Returns bytes for signing
getMyProofs(): Promise<Array<string>>; Returns array of signatures that belongs to public key of the adapter from which the instance of class Signable was created
hasMySignature(): Promise<boolean>; Returns promise with boolean status about presence of “own” signature (Same as in “getMyProofs” method)
addMyProof(): Promise<string>; This method checks the presence of “own” signature. If signature exists it returns the last “own” signature, otherwise its signs and returns the new signature
getDataForApi():Promise<object>; Calls the method “addMyProof” to guarantee the presence of one “own” signature. Returns the data that is prepared to send into node. Adds the list of signatures
FAQs
## Installation
We found that @waves/signature-adapter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 14 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
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.