Skip to content
This repository was archived by the owner on Apr 19, 2024. It is now read-only.
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions docs/didkit-packages/Node.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,38 @@ sidebar_title: JavaScript

## At a Glance

- Three slightly different versions of the DIDKit binary can be installed via `npm`, all under the organization "@spruceid":
- **[didkit-neon](https://www.npmjs.com/package/@spruceid/didkit)** is optimized for Node.JS environments, with bindings generated with **[neon](https://github.com/neon-bindings/neon)**
- Two slightly different versions of the DIDKit binary can be installed via `npm`, all under the organization "@spruceid":
<!--- - **[didkit-neon](https://www.npmjs.com/package/@spruceid/didkit)** is optimized for Node.JS environments, with bindings generated with **[neon](https://github.com/neon-bindings/neon)** Removed this entry as I could not get didkit-neon to install via npm --->
- **[didkit-wasm](https://www.npmjs.com/package/@spruceid/didkit-wasm)** is packed to operate in the browser and blockchain contexts via **[wasm-pack](https://github.com/rustwasm/wasm-pack/)**
- **[didkit-wasm-node](https://www.npmjs.com/package/@spruceid/didkit-wasm)** is packed to operate in Node.JS and blockchain contexts via **[wasm-pack](https://github.com/rustwasm/wasm-pack/)**
- For a quick function & type reference, you can check out the [Issuing a Credential](https://github.com/spruceid/didkit/lib/node/README.md#Issuing-a-Credential) and [Options](https://github.com/spruceid/didkit/lib/node/README.md#Options) sections of the `/lib/node/README.md` file in the DIDKit repo. Better yet, install it and run the commands yourself!
- To test your installation or just to see examples of calls and returns with valid DID-key test vectors, see the provided [test script](https://github.com/spruceid/didkit/lib/node/test/index.spec.js)
- To test your installation or just to see examples of calls and returns with valid DID-key test vectors, see the provided [test script](https://github.com/spruceid/didkit/blob/main/lib/node/test/index.spec.js)

## Installation

Installation over node package managers is quite simple. Run this command to confirm version number and proper operation of basic functions:
Installation over node package managers is quite simple. For example, 'npm install @spruceid/didkit-wasm-node' will install the Node.js version.

Once installed, this Javascript program can be run to display the didkit version number and confirm the proper operation of the basic functions:
```js
console.log("Testing didkit");
// Import the module
const DIDKit = require('@spruceid/didkit');
const DIDKit = require('@spruceid/didkit-wasm-node');

console.log(DIDKit.getVersion());
// Print the Didkit version information
console.log("DIDKit version = " + DIDKit.getVersion());

// To issue credentials and presentations, you need a key.
// The library provides a function to generate one.
const key = DIDKit.generateEd25519Key();
console.log("Key = " + key);

// There are two helpful functions to obtain a DID and the `did:key`
// `verificationMethod` from the key.
const did = DIDKit.keyToDID('key', key);
console.log("DID = " + did);

const verificationMethod = DIDKit.keyToVerificationMethod('key', key);
console.log("Verification method = " + verificationMethod);
```

## Examples
Expand All @@ -43,4 +50,4 @@ const verificationMethod = DIDKit.keyToVerificationMethod('key', key);
## Code

- [WASM](https://github.com/spruceid/didkit/tree/main/lib/web)
- [Neon](https://github.com/spruceid/didkit/tree/main/lib/node)
- [WASm-node](https://github.com/spruceid/didkit/tree/main/lib/node)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could there be some confusion around the Neon version and the node specific WASM package?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could only find 2 versions to install via npm, the WASM version, and the node specific version. I could not find a third neon version to install.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sbihel. I tried to install it via 'npm install @spruceid/didkit' and got errors. Attached is the npm error log. I don't have time at the moment to debug, but will look when I get a chance. Am open to ideas/suggestions. TIA
2022-03-09T21_53_08_161Z-debug-0.log

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, looks like the Neon version doesn't support Windows. I think you can drop the PR for now, we'll have to decide internally what to do with the Neon version and the other packages.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I'll try it out on Windows WSL also when I get a chance. See if I get the same/similar errors.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also go errors when trying to install "@spruceid/didkit" on Windows WSL (Ubuntu). I think I'll make one more update to Node,md to clarify what works on Linux and what works on Windows.