Skip to content

Commit

Permalink
docs: add usage example
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Jan 27, 2023
1 parent c6a6067 commit 6fcee29
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
16 changes: 1 addition & 15 deletions src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,5 @@ export enum codes {
ERR_INVALID_PARAMETERS = 'ERR_INVALID_PARAMETERS',
ERR_INVALID_CMS = 'ERR_INVALID_CMS',
ERR_MISSING_KEYS = 'ERR_MISSING_KEYS',
ERR_NO_KEY = 'ERR_NO_KEY',
ERR_INVALID_KEY_NAME = 'ERR_INVALID_KEY_NAME',
ERR_INVALID_KEY_TYPE = 'ERR_INVALID_KEY_TYPE',
ERR_KEY_ALREADY_EXISTS = 'ERR_KEY_ALREADY_EXISTS',
ERR_INVALID_KEY_SIZE = 'ERR_INVALID_KEY_SIZE',
ERR_KEY_NOT_FOUND = 'ERR_KEY_NOT_FOUND',
ERR_OLD_KEY_NAME_INVALID = 'ERR_OLD_KEY_NAME_INVALID',
ERR_NEW_KEY_NAME_INVALID = 'ERR_NEW_KEY_NAME_INVALID',
ERR_PASSWORD_REQUIRED = 'ERR_PASSWORD_REQUIRED',
ERR_PEM_REQUIRED = 'ERR_PEM_REQUIRED',
ERR_CANNOT_READ_KEY = 'ERR_CANNOT_READ_KEY',
ERR_MISSING_PRIVATE_KEY = 'ERR_MISSING_PRIVATE_KEY',
ERR_INVALID_OLD_PASS_TYPE = 'ERR_INVALID_OLD_PASS_TYPE',
ERR_INVALID_NEW_PASS_TYPE = 'ERR_INVALID_NEW_PASS_TYPE',
ERR_INVALID_PASS_LENGTH = 'ERR_INVALID_PASS_LENGTH'
ERR_NO_KEY = 'ERR_NO_KEY'
}
25 changes: 25 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
/**
* @packageDocumentation
*
* Cryptographically protected messages using the libp2p keychain
*
* @example
*
* ```typescript
* import { createLibp2p } from 'libp2p'
* import { CMS } from '@libp2p/cms'
*
* // Create a libp2p node
* const node = await createLibp2p({
* // ...other options
* connectionEncryption: [plaintext()]
* })
*
* const cms = new CMS(libp2p.keychain)
*
* // Use CMS operations
* const plaintext = Uint8Array.from([0, 1, 2, 3])
* const ciphertext = await cms.encrypt('key-name', plaintext)
* ```
*/

import 'node-forge/lib/pkcs7.js'
import 'node-forge/lib/pbe.js'
// @ts-expect-error types are missing
Expand Down

0 comments on commit 6fcee29

Please sign in to comment.