Moving towards a publishable npm sdk package

This commit is contained in:
Dave Hrycyszyn
2022-11-14 15:08:58 +00:00
parent aeaf31ed59
commit 2bd0cfc870
3 changed files with 43 additions and 29 deletions
+3 -25
View File
@@ -1,30 +1,8 @@
# Nym SDK (Typescript)
The Nym SDK for Typescript will get you creating apps that can use the Nym Mixnet and Coconut credentials quickly.
## Packages
## TL;DR
Include the SDK in your project:
```
npm install @nymproject/sdk
```
Open a connection to a Gateway on the Nym Mixnet:
```ts
import { client } from '@nymproject/sdk';
const session = await client.connect('<<GATEWAY>>');
```
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):
```ts
const result = await client.send('<<USER ADDRESS>>', 'Hello Timmy!');
```
- [SDK](packages/sdk) - the Nym SDK package
## Examples
@@ -35,4 +13,4 @@ Coming soon:
- [Node tester](examples/node-tester) - a React app that sends test packets to a mixnode and measure the network speed
- [Mixnet topology viewer](examples/topology) - a Svelte app that shows the mixnodes current in the active set
- [Get a bandwidth voucher](examples/coconut-bandwidth-voucher) - get a bandwidth voucher to use the mixnet
- [Get a bandwidth voucher](examples/coconut-bandwidth-voucher) - get a bandwidth voucher to use the mixnet
+35
View File
@@ -0,0 +1,35 @@
# Nym SDK (Typescript)
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
```
Open a connection to a Gateway on the Nym Mixnet:
```ts
import { client } from '@nymproject/sdk';
const session = await client.connect('<<GATEWAY>>');
```
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):
```ts
const result = await client.send('<<USER ADDRESS>>', 'Hello Timmy!');
```
### Packaging
If you're a Nym platform developer who's made changes to the Rust (or JS) files and wants to re-publish the package to NPM, here's how you do it:
1. bump version numbers as necessary for SemVer
2. `yarn build` builds the release directory
3. `npm publish --access=public` will publish your changed package to NPM
+5 -4
View File
@@ -1,6 +1,6 @@
{
"name": "@nymproject/sdk",
"version": "1.0.0",
"version": "1.1.1",
"license": "Apache-2.0",
"author": "Nym Technologies SA",
"main": "dist/index.js",
@@ -27,9 +27,10 @@
"build:dependencies:nym-client-wasm": "../nym-client-wasm/scripts/build.sh",
"prebuild": "yarn build:dependencies",
"build": "tsc",
"postbuild": "cp ../nym-client-wasm/nym_client_wasm* dist/mixnet/wasm",
"postbuild": "cp ../nym-client-wasm/nym_client_wasm* dist/mixnet/wasm && yarn copy:readme",
"build:only-this": "tsc",
"postbuild:only-this": "cp ../nym-client-wasm/nym_client_wasm* dist/mixnet/wasm"
"postbuild:only-this": "cp ../nym-client-wasm/nym_client_wasm* dist/mixnet/wasm",
"copy:readme": "cp README.md dist"
},
"dependencies": {
"comlink": "^4.3.1"
@@ -52,4 +53,4 @@
"eslint-plugin-react": "^7.29.2",
"eslint-plugin-react-hooks": "^4.3.0"
}
}
}