
Security News
Node.js Homepage Adds Paid Support Link, Prompting Contributor Pushback
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
zkfold-smart-wallet-api
Advanced tools
This package provides a Smart Wallet API to manage both mnemonic-based and Google OAuth-based wallets.
Exported modules:
wallet.sendTo(new SmartTxRecipient(WalletType.Google, "user@gmail.com", new BigIntWrap(1000000)))
A wallet can be created using a mnemonic. In this case, it will act as a classical wallet (i.e. create transactions signed with a private key), but it will still be able to send money to a gmail account.
import { Wallet, Initialiser, WalletType, SmartTxRecipient } from 'zkfold-smart-wallet-api';
import { Backend, BigIntWrap } from 'zkfold-smart-wallet-api'
import { Notifier } from 'zkfold-smart-wallet-api'
const backend = new Backend('https://api.wallet.zkfold.io', 'api-key'); // To communicate with the backend
const notifier = new Notifier("service@email.com", "application password"); // This will be used to send emails to the recipient
const initialiser = { method: WalletType.Mnemonic, data: "mnemonic of the wallet ..." };
const wallet = new Wallet(backend, initialiser, 'password', 'preprod'); // A Wallet is created with Backend, wallet type parameters, optional password and network type.
const address = await wallet.getAddress();
console.log(address.to_bech32());
const balance = await wallet.getBalance();
console.log(balance);
const txId = await wallet.sendTo(new SmartTxRecipient(WalletType.Google, "user@gmail.com", new BigIntWrap(1000000)));
console.log(txId);
notifier.sendMessage("user@gmail.com", "You've received funds", "html of the message body"); // Notify the recipient
A wallet can be created using Google OAuth. In this case, it will require a valid JSON Web Token signed by Google and intended to be used with the wallet web application.
import { Wallet, Initialiser, WalletType, SmartTxRecipient } from 'zkfold-smart-wallet-api';
import { Backend, BigIntWrap } from 'zkfold-smart-wallet-api'
import { Notifier } from 'zkfold-smart-wallet-api'
import { GoogleApi } from 'zkfold-smart-wallet-api'
import CSL from '@emurgo/cardano-serialization-lib-nodejs';
const backend = new Backend('https://api.wallet.zkfold.io', 'api-key'); // To communicate with the backend
const notifier = new Notifier("service@email.com", "application password"); // This will be used to send emails to the recipient
const gapi = new GoogleApi("client id of your web app", "client secret", "redirect url");
const prvKey = CSL.Bip32PrivateKey.generate_ed25519_bip32(); // Will be used to mint a token and sign transactions
const state = crypto.randomBytes(32).toString('hex'); // Google requires to use state to avoid CSRF attacks
const authUrl = gapi.getAuthUrl(state); // User should be redirecred here to obtain a JSON Web Token
// After a successful authentication, Google will send a request to the specified endpoint.
// The request will contain a url parameter 'code' which should be passed to getJWT()
const jwt = await gapi.getJWT(response.code);
const initialiser = { method: WalletType.Google, data: jwt, rootKey: prvKey };
const wallet = new Wallet(backend, initialiser, 'password', 'preprod'); // The Wallet can be used exactly as before, there's nothing new from a user's perspective
const address = await wallet.getAddress();
console.log(address.to_bech32());
const balance = await wallet.getBalance();
console.log(balance);
const txId = await wallet.sendTo(new SmartTxRecipient(WalletType.Google, "user@gmail.com", new BigIntWrap(1000000)));
console.log(txId);
notifier.sendMessage("user@gmail.com", "You've received funds", "html of the message body"); // Notify the recipient
FAQs
Smart wallet api
The npm package zkfold-smart-wallet-api receives a total of 2 weekly downloads. As such, zkfold-smart-wallet-api popularity was classified as not popular.
We found that zkfold-smart-wallet-api demonstrated a healthy version release cadence and project activity because the last version was released less than 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
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.
Research
Security News
The Socket Research Team investigates a malicious Python typosquat of a popular password library that forces Windows shutdowns when input is incorrect.