From 2bd0cfc87097144a2aa858f56438c6151a2ef0d3 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Mon, 14 Nov 2022 15:08:58 +0000 Subject: [PATCH] Moving towards a publishable npm sdk package --- sdk/typescript/README.md | 28 ++----------------- sdk/typescript/packages/sdk/README.md | 35 ++++++++++++++++++++++++ sdk/typescript/packages/sdk/package.json | 9 +++--- 3 files changed, 43 insertions(+), 29 deletions(-) create mode 100644 sdk/typescript/packages/sdk/README.md diff --git a/sdk/typescript/README.md b/sdk/typescript/README.md index 5f17145e9f..fbfdd48fbe 100644 --- a/sdk/typescript/README.md +++ b/sdk/typescript/README.md @@ -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('<>'); -``` - -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('<>', '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 \ No newline at end of file +- [Get a bandwidth voucher](examples/coconut-bandwidth-voucher) - get a bandwidth voucher to use the mixnet diff --git a/sdk/typescript/packages/sdk/README.md b/sdk/typescript/packages/sdk/README.md new file mode 100644 index 0000000000..c1f1fc5a7f --- /dev/null +++ b/sdk/typescript/packages/sdk/README.md @@ -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('<>'); +``` + +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('<>', '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 diff --git a/sdk/typescript/packages/sdk/package.json b/sdk/typescript/packages/sdk/package.json index 1cf5c5ab48..1a5ce571fd 100644 --- a/sdk/typescript/packages/sdk/package.json +++ b/sdk/typescript/packages/sdk/package.json @@ -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" } -} +} \ No newline at end of file