@nymproject/sdk-commonjs-full-fat v1.4.0-rc.0
Nym SDK (Typescript) CommonJS and ES5 - 🥛🥛🥛 Full Fat
⚠ WARNING: ES5 & CommonJS with inline blobs ⚠
Please note: this is a CommonJS package targeting ES5. Use this for older projects or when you have bundling issues. It includes inline blobs that will interfere with CSPs that disallow them.
Find the right package for you
Browsers:
ESM🥛 - @nymproject/sdk, not bundled, useimportsyntax, you will need to bundle itESM🥛🥛🥛 - @nymproject/sdk-full-fat, useimportsyntax, pre-bundled with inlined workers and WASM bundlesCJS🥛 - @nymproject/sdk, targets ES5, not bundled, you will need to bundle itCJS🥛🥛🥛 - @nymproject/sdk-full-fat, targets ES5, pre-bundled with inlined workers and WASM bundles
NodeJS:
ESM- @nymproject/sdk-nodejs, useimportsyntax in NodeJS 18 and laterCJS- @nymproject/sdk-nodejs-cjs, userequiresyntax in older NodeJS versions
Why have all these variations? Each project is different, so hopefully we have something for you!
Choose a package depending on how your project is transpiled and packaged:
ESM: useimportsyntax and have your bundler copy the WASM bundles into your output distributionCJS: you have an older project that needs ES5 Javascriptnodejs: you want to write your project server-side or locally without the browser on NodeJS
And then, to use *-full-fat or not, how do I choose? We have *-full-fat packages that are pre-bundled by including all web-workers and WASM as inline Base64.
Use the *-full-fat packages when you have trouble changing your bundler settings, or you can use an open CSP.
The Nym SDK for Typescript will get you creating apps that can use the Nym Mixnet and Coconut credentials quickly.
TL;DR
Include the SDK in your project:
npm install @nymproject/sdk-commonjsOpen a connection to a Gateway on the Nym Mixnet:
const { createNymMixnetClient } = require('@nymproject/sdk-commonjs');
const main = async () => {
const nym = await createNymMixnetClient();
const nymApiUrl = 'https://validator.nymtech.net/api';
// show message payload content when received
nym.events.subscribeToTextMessageReceivedEvent((e) => {
console.log('Got a message: ', e.args.payload);
});
// start the client and connect to a gateway
await nym.client.start({
clientId: 'My awesome client',
nymApiUrl,
});
// send a message to yourself
const payload = 'Hello mixnet';
const recipient = nym.client.selfAddress();
nym.client.send({ payload, recipient });
};This will start the WASM client on a worker thread, so that your code can stay nice and snappy.
Send a message to another user (you will need to know their address at a Gateway):
const payload = 'Hello mixnet';
const recipient = '<< RECIPIENT ADDRESS GOES HERE >>';
await nym.client.send({ payload, recipient });10 months ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago