-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from futureforging/jrayback_240327_make-npm-pa…
…ckage-from-synced-main Make npm package from synced main
- Loading branch information
Showing
99 changed files
with
1,853 additions
and
463 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,68 @@ | ||
# Instructions | ||
# simple-cesr | ||
|
||
- This project template uses `ts-node` and targets Node 20 | ||
- However, both the`start` and the `test` scripts in `package.json` are overly complicated due a [bug](https://github.com/TypeStrong/ts-node/issues/1997) in `ts-node` related to Node 20. When the bug is resolved, you should be able to revert to `npx ts-node [file or glob]` without any need to invoke the ESM loader directly (it is enabled by `"esm": true` in the `ts-node` section in `tsconfig.json`). | ||
- `no-emit` is set to `true` in `tsconfig.json` so don't expect any outputted javascript files. The `.ts` files are meant to be executed directly with `ts-node`. | ||
`simple-cesr` is a simple, limited, true-to-spec implementation of [Composable Event Streaming Representation (CESR)](https://weboftrust.github.io/ietf-cesr/draft-ssmith-cesr.html). It is compatible with Node.js and major browsers. It has a simple API for encoding primitives and transforming them across the three [domain representations](https://weboftrust.github.io/ietf-cesr/draft-ssmith-cesr.html#name-concrete-domain-representat) (Raw, Text, and Binary). It conspicuously adheres to terminology from the spec and carefully avoids introducing any outside concepts beyond CESR. In this initial version, only a selected subset of primitives from the [small fixed](https://weboftrust.github.io/ietf-cesr/draft-ssmith-cesr.html#name-small-fixed-raw-size-tables) and [large fixed](https://weboftrust.github.io/ietf-cesr/draft-ssmith-cesr.html#name-large-fixed-raw-size-tables) raw size tables have been implemented. Specifically, these primitives have been implemented (full table of potential options [here](https://weboftrust.github.io/ietf-cesr/draft-ssmith-cesr.html#name-master-code-table)): | ||
|
||
| Code | Description | | ||
| :--: | :-------------------------- | | ||
| A | Seed of Ed25519 private key | | ||
| B | Ed25519 non-transferable prefix public verification key | | ||
| C | X25519 public encryption key | | ||
| D | Ed25519 public verification key | | ||
| E | Blake3-256 Digest | | ||
| F | Blake2b-256 Digest | | ||
| G | Blake2s-256 Digest | | ||
| H | SHA3-256 Digest | | ||
| I | SHA2-256 Digest | | ||
| J | Seed of ECDSA secp256k1 private key | | ||
| M | Short number 2 byte base-2 | | ||
| N | Big number 8 byte base-2 | | ||
| O | X25519 private decryption key | | ||
| 0A | Random salt, seed, private key, or sequence number of length 128 bits | | ||
| 0B | Ed25519 signature | | ||
| 0C | ECDSA secp256k1 signature | | ||
| 0D | Blake3-512 Digest | | ||
| 0E | Blake2b-512 Digest | | ||
| 0F | SHA3-512 Digest | | ||
| 0G | SHA2-512 Digest | | ||
| 0H | Long number 4 byte base-2 | | ||
| 1AAA | ECDSA secp256k1 non-transferable prefix public verification key | | ||
| 1AAB | ECDSA secp256k1 public verification or encryption key | | ||
| 1AAC | Ed448 non-transferable prefix public verification key | | ||
| 1AAD | Ed448 public verification key | | ||
| 1AAE | Ed448 signature | | ||
| 1AAF | Tag Base64 4 chars or 3 byte base-2 number | | ||
|
||
This implementation is consistent with the [1.0](https://weboftrust.github.io/ietf-cesr/draft-ssmith-cesr.html) spec housed at IETF and has not yet considered the soon-to-be-finished CESR [2.0](https://trustoverip.github.io/tswg-cesr-specification/) spec coming from the Trust Over IP Foundation. | ||
|
||
## Usage | ||
|
||
```bash | ||
npm install @jrayback/simple-cesr | ||
``` | ||
|
||
## Development | ||
|
||
Unit tests can be run with: | ||
|
||
```bash | ||
npm test | ||
``` | ||
|
||
Additionally, a high-level test that verifies the compatibility of `simple-cesr` with other CESR implementations, like [`cesr-ts`](https://github.com/webOfTrust/cesr-ts/) (derived from [`signify-ts`](https://github.com/WebOfTrust/signify-ts)) can be run with: | ||
|
||
```bash | ||
npm run standards-test | ||
``` | ||
An all-inclusive run of tests can be done with: | ||
|
||
```bash | ||
npm run all-tests | ||
``` | ||
|
||
To get a feel for things: | ||
|
||
```bash | ||
npm start | ||
``` | ||
|
||
This will run `src/main.js` and is a good way to get oriented. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
// TO BE FILLED WITH EXTERNAL API | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
|
||
export * as cesr from './src/api/api.js' | ||
|
||
Object.assign(module.exports, require('./src/api/api.js')) // presumably for CommonJS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,22 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
export default { | ||
preset: 'ts-jest', | ||
// need esm preset to support esm modules | ||
preset: 'ts-jest/presets/default-esm', | ||
testEnvironment: 'node', | ||
// part of esm support, see: https://kulshekhar.github.io/ts-jest/docs/guides/esm-support/ | ||
moduleNameMapper: { | ||
'^(\\.{1,2}/.*)\\.js$': '$1' | ||
}, | ||
transform: { | ||
// allows jest to resolve module paths to a .ts source file using a .js extension | ||
// see dox for more information on this setting: https://kulshekhar.github.io/ts-jest/docs/guides/esm-support/ | ||
'^.+\\.[tj]sx?$': [ | ||
'ts-jest', | ||
{ | ||
useESM: true | ||
} | ||
] | ||
}, | ||
// use a fancier test reporter | ||
reporters: ['jest-ci-spec-reporter'] | ||
} |
Oops, something went wrong.