Skip to content

Commit 3a82976

Browse files
feat: init
0 parents  commit 3a82976

File tree

15 files changed

+7325
-0
lines changed

15 files changed

+7325
-0
lines changed

.github/workflows/main.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: CI
2+
on: [push]
3+
jobs:
4+
build:
5+
name: Build, lint, and test on Node ${{ matrix.node }} and ${{ matrix.os }}
6+
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
matrix:
10+
node: ['16.x']
11+
os: [ubuntu-latest, windows-latest, macOS-latest]
12+
13+
steps:
14+
- name: Checkout repo
15+
uses: actions/checkout@v2
16+
17+
- name: Use Node ${{ matrix.node }}
18+
uses: actions/setup-node@v1
19+
with:
20+
node-version: ${{ matrix.node }}
21+
22+
- name: Install deps and build (with cache)
23+
uses: bahmutov/npm-install@v1
24+
25+
- name: Lint
26+
run: yarn lint
27+
28+
- name: Test
29+
run: yarn test --ci --coverage --maxWorkers=2
30+
31+
- name: Build
32+
run: yarn build

.github/workflows/size.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: size
2+
on: [pull_request]
3+
jobs:
4+
size:
5+
runs-on: ubuntu-latest
6+
env:
7+
CI_JOB_NUMBER: 1
8+
steps:
9+
- uses: actions/checkout@v1
10+
- uses: andresz1/size-limit-action@v1
11+
with:
12+
github_token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.log
2+
.DS_Store
3+
node_modules
4+
dist

CODE_OF_CONDUCT.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6+
7+
## Our Standards
8+
9+
Examples of behavior that contributes to a positive environment for our community include:
10+
11+
* Demonstrating empathy and kindness toward other people
12+
* Being respectful of differing opinions, viewpoints, and experiences
13+
* Giving and gracefully accepting constructive feedback
14+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
15+
* Focusing on what is best not just for us as individuals, but for the overall community
16+
17+
Examples of unacceptable behavior include:
18+
19+
* The use of sexualized language or imagery, and sexual attention or advances
20+
* Trolling, insulting or derogatory comments, and personal or political attacks
21+
* Public or private harassment
22+
* Publishing others' private information, such as a physical or email address, without their explicit permission
23+
* Other conduct which could reasonably be considered inappropriate in a professional setting
24+
25+
## Our Responsibilities
26+
27+
Project maintainers are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28+
29+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30+
31+
## Scope
32+
33+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
34+
35+
## Enforcement
36+
37+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement.. All complaints will be reviewed and investigated promptly and fairly.
38+
39+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
40+
41+
## Attribution
42+
43+
This Code of Conduct is adapted from the [Contributor Covenant](https://contributor-covenant.org/), version [1.4](https://www.contributor-covenant.org version/1/4/code-of-conduct/code_of_conduct.md) and [2.0](https://www.contributor-covenant.org/version/2/0/code_of_conduct/code_of_conduct.md), and was generated by [contributing-gen](https://github.com/bttger/contributing-gen).

CONTRIBUTING.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Contributing
2+
3+
When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.
4+
5+
Please note we have a code of conduct, please follow it in all your interactions with the project.
6+
7+
## Pull Request Process
8+
9+
1. Ensure any install or build dependencies are removed before the end of the layer when doing a build.
10+
2. Update the README.md with details of changes to the interface, this includes new environment variables, exposed ports, useful file locations and container parameters.
11+
3. Increase the version numbers in any examples files and the README.md to the new version that this Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Hypereon
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
![Hypereon Message Banner](https://github.com/HypereonLabs/message/raw/master/media/repo-banner.png)
2+
3+
# Hypereon - Message
4+
5+
JavaScript functions for signing and verifying messages.
6+
7+
## Installation
8+
9+
```bash
10+
npm install @hypereon/message;
11+
```
12+
13+
## Usage
14+
15+
### Sign a message
16+
17+
```javascript
18+
import { sign } from '@hypereon/message';
19+
20+
const privateKey = 'L4rK1yDtCWekvXuE6oXD9jCYfFNV2cWRpVuPLBcCU2z8TrisoyY1';
21+
const message = 'This is an example of a signed message.';
22+
23+
const signature = sign({ message, privateKey });
24+
// Expected Result: H9L5yLFjti0QTHhPyFrZCT1V/MMnBtXKmoiKDZ78NDBjERki6ZTQZdSMCtkgoNmp17By9ItJr8o7ChX0XxY91nk=
25+
```
26+
27+
### Verify a message
28+
29+
```javascript
30+
import { verify } from '@hypereon/message';
31+
32+
const address = '<public_address_of_private_key_wif>';
33+
const message = 'This is an example of a signed message.';
34+
const signature = '<generated_signature_from_sign>';
35+
36+
const isVerified = verify({ address, message, signature });
37+
```
38+
39+
Message signing defaults to Bitcoin '\u0018Bitcoin Signed Message:\n'. See `@hypereon/message` for message prefixes to sign for a different blockchain.
40+
41+
```javascript
42+
import { sign, verify } from '@hypereon/message';
43+
import message from '@hypereon/message';
44+
45+
const { messagePrefix } = message.ltc.main;
46+
47+
const signature = sign({
48+
privateKey: '...',
49+
message: '...',
50+
messagePrefix,
51+
});
52+
53+
const isVerified = verify({
54+
address: '...',
55+
message: '...',
56+
signature: '...',
57+
messagePrefix,
58+
});
59+
```
60+
61+
## Contributing
62+
63+
If you're interested in contributing, please read the [contributing docs](https://github.com/HypereonLabs/message/blob/master/CONTRIBUTING.md) before submitting a pull request.
64+
65+
## Authors
66+
67+
- [@mikemcshinsky](https://twitter.com/mikemcshinsky)[Magitek](https://magitek.dev)
68+
69+
## License
70+
71+
[MIT](/LICENSE) License

media/repo-banner.png

29.2 KB
Loading

package.json

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"version": "0.0.1",
3+
"license": "MIT",
4+
"main": "dist/index.js",
5+
"typings": "dist/index.d.ts",
6+
"files": [
7+
"dist",
8+
"src"
9+
],
10+
"engines": {
11+
"node": ">=14"
12+
},
13+
"scripts": {
14+
"start": "tsdx watch",
15+
"build": "tsdx build",
16+
"test": "tsdx test",
17+
"lint": "tsdx lint",
18+
"prepare": "tsdx build",
19+
"size": "size-limit",
20+
"analyze": "size-limit --why"
21+
},
22+
"peerDependencies": {},
23+
"husky": {
24+
"hooks": {
25+
"pre-commit": "tsdx lint"
26+
}
27+
},
28+
"prettier": {
29+
"printWidth": 80,
30+
"semi": true,
31+
"singleQuote": true,
32+
"trailingComma": "es5"
33+
},
34+
"name": "@hypereon/message",
35+
"repository": {
36+
"type": "git",
37+
"url": "https://github.com/HypereonLabs/message.git"
38+
},
39+
"author": "Hypereon",
40+
"module": "dist/message.esm.js",
41+
"size-limit": [
42+
{
43+
"path": "dist/message.cjs.production.min.js",
44+
"limit": "10 KB"
45+
},
46+
{
47+
"path": "dist/message.esm.js",
48+
"limit": "10 KB"
49+
}
50+
],
51+
"devDependencies": {
52+
"@size-limit/preset-small-lib": "^8.1.0",
53+
"husky": "^8.0.2",
54+
"size-limit": "^8.1.0",
55+
"tsdx": "^0.14.1",
56+
"tslib": "^2.4.1",
57+
"typescript": "^4.8.4"
58+
},
59+
"dependencies": {
60+
"bitcoinjs-message": "^2.2.0",
61+
"coinkey": "^3.0.0"
62+
},
63+
"publishConfig": {
64+
"access": "public"
65+
}
66+
}

src/global.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
declare module 'bitcoinjs-message';
2+
declare module 'coinkey';

0 commit comments

Comments
 (0)