-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(iso-signatures): initial commit for iso-signatures (#34)
- fix(iso-did): extract signatures to a new package and export common.js from key.js - feat(iso-signatures): initial commit for iso-signatures
- Loading branch information
1 parent
7af05df
commit a2e6265
Showing
32 changed files
with
440 additions
and
154 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
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
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: iso-signatures | ||
env: | ||
CI: true | ||
FORCE_COLOR: 1 | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'packages/iso-signatures/**' | ||
- '.github/workflows/iso-signatures.yml' | ||
- 'pnpm-lock.yaml' | ||
pull_request: | ||
paths: | ||
- 'packages/iso-signatures/**' | ||
- '.github/workflows/iso-signatures.yml' | ||
- 'pnpm-lock.yaml' | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: pnpm/action-setup@v2.2.4 | ||
with: | ||
version: 8 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
cache: 'pnpm' | ||
- run: pnpm install | ||
- run: pnpm run build | ||
- run: pnpm -r --filter iso-signatures run lint | ||
- run: pnpm -r --filter iso-signatures run test | ||
- run: pnpm -r --filter iso-signatures exec depcheck |
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
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,138 @@ | ||
{ | ||
"name": "iso-signatures", | ||
"version": "0.0.1", | ||
"description": "Signatures tooling.", | ||
"author": "Hugo Dias <hugomrdias@gmail.com> (hugodias.me)", | ||
"license": "MIT", | ||
"repository": { | ||
"url": "hugomrdias/iso-repo", | ||
"directory": "packages/iso-signatures" | ||
}, | ||
"homepage": "https://github.com/hugomrdias/iso-repo/tree/main/packages/iso-signatures", | ||
"keywords": [ | ||
"elliptic", | ||
"curve", | ||
"cryptography", | ||
"edwards", | ||
"p256", | ||
"p384", | ||
"p521", | ||
"secp256r1", | ||
"secp256k1", | ||
"ed25519", | ||
"ecdsa", | ||
"eddsa", | ||
"rsa", | ||
"signatures" | ||
], | ||
"type": "module", | ||
"main": "src/index.js", | ||
"types": "dist/src/index.d.ts", | ||
"exports": { | ||
".": { | ||
"types": "./dist/src/index.d.ts", | ||
"import": "./src/index.js" | ||
}, | ||
"./signers/ecdsa": { | ||
"types": "./dist/src/signers/ecdsa.d.ts", | ||
"import": "./src/signers/ecdsa.js" | ||
}, | ||
"./signers/eddsa": { | ||
"types": "./dist/src/signers/eddsa.d.ts", | ||
"import": "./src/signers/eddsa.js" | ||
}, | ||
"./signers/rsa-old": { | ||
"types": "./dist/src/signers/rsa-old.d.ts", | ||
"import": "./src/signers/rsa-old.js" | ||
}, | ||
"./signers/rsa": { | ||
"types": "./dist/src/signers/rsa.d.ts", | ||
"import": "./src/signers/rsa.js" | ||
}, | ||
"./verifiers/ecdsa": { | ||
"types": "./dist/src/verifiers/ecdsa.d.ts", | ||
"import": "./src/verifiers/ecdsa.js" | ||
}, | ||
"./verifiers/eddsa": { | ||
"types": "./dist/src/verifiers/eddsa.d.ts", | ||
"import": "./src/verifiers/eddsa.js" | ||
}, | ||
"./verifiers/rsa-old": { | ||
"types": "./dist/src/verifiers/rsa-old.d.ts", | ||
"import": "./src/verifiers/rsa-old.js" | ||
}, | ||
"./verifiers/rsa": { | ||
"types": "./dist/src/verifiers/rsa.d.ts", | ||
"import": "./src/verifiers/rsa.js" | ||
}, | ||
"./verifiers/resolver": { | ||
"types": "./dist/src/verifiers/resolver.d.ts", | ||
"import": "./src/verifiers/resolver.js" | ||
} | ||
}, | ||
"typesVersions": { | ||
"*": { | ||
".": [ | ||
"dist/src/index" | ||
], | ||
"signers/*": [ | ||
"dist/src/signers/*" | ||
], | ||
"verifiers/*": [ | ||
"dist/src/verifiers/*" | ||
] | ||
} | ||
}, | ||
"files": [ | ||
"src", | ||
"dist/src/*.d.ts", | ||
"dist/src/*.d.ts.map" | ||
], | ||
"scripts": { | ||
"lint": "tsc --build && eslint '**/*.{js,ts}' && prettier --check '**/*.{js,ts,yml,json}' --ignore-path ../../.gitignore", | ||
"test": "tsc --build && pnpm run test:node && pnpm run test:browser", | ||
"test:node": "mocha 'test/**/!(*.browser).test.js'", | ||
"test:browser": "playwright-test 'test/**/!(*.node).test.js'" | ||
}, | ||
"dependencies": { | ||
"@noble/ed25519": "^2.0.0", | ||
"iso-base": "workspace:^", | ||
"iso-did": "workspace:^" | ||
}, | ||
"devDependencies": { | ||
"@types/assert": "^1.5.6", | ||
"@types/mocha": "^10.0.1", | ||
"@types/node": "^20.3.1", | ||
"assert": "^2.0.0", | ||
"hd-scripts": "^7.0.0", | ||
"mocha": "^10.2.0", | ||
"playwright-test": "^9.2.0", | ||
"type-fest": "^3.12.0", | ||
"typescript": "5.1.3" | ||
}, | ||
"eslintConfig": { | ||
"extends": [ | ||
"../../node_modules/hd-scripts/eslint/index.js" | ||
], | ||
"parserOptions": { | ||
"project": "./tsconfig.json" | ||
}, | ||
"env": { | ||
"mocha": true | ||
}, | ||
"ignorePatterns": [ | ||
"dist" | ||
] | ||
}, | ||
"depcheck": { | ||
"specials": [ | ||
"bin" | ||
], | ||
"ignores": [ | ||
"@types/*", | ||
"hd-scripts", | ||
"assert", | ||
"type-fest" | ||
] | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# iso-signatures [![NPM Version](https://img.shields.io/npm/v/iso-signatures.svg)](https://www.npmjs.com/package/iso-signatures) [![License](https://img.shields.io/npm/l/iso-signatures.svg)](https://github.com/hugomrdias/iso-repo/blob/main/license) [![iso-did](https://github.com/hugomrdias/iso-repo/actions/workflows/iso-signatures.yml/badge.svg)](https://github.com/hugomrdias/iso-repo/actions/workflows/iso-signatures.yml) | ||
|
||
> Isomorphic signatures tooling | ||
## Install | ||
|
||
```bash | ||
pnpm install iso-signatures | ||
``` | ||
|
||
## Usage | ||
|
||
```js | ||
import { EdDSASigner } from 'iso-signatures/signers/eddsa' | ||
import * as EdDSA from 'iso-signatures/verifiers/eddsa' | ||
|
||
const message = new TextEncoder().encode('hello world') | ||
const resolver = new Resolver({ | ||
...EdDSA.verifier, | ||
}) | ||
const signer = await EdDSASigner.generate() | ||
const signature = await signer.sign(message) | ||
const verified = await resolver.verify({ | ||
signature, | ||
message, | ||
...signer, | ||
}) | ||
``` | ||
|
||
```js | ||
import { EdDSASigner } from 'iso-signatures/signers/eddsa' | ||
import * as EdDSA from 'iso-signatures/verifiers/eddsa' | ||
import * as ECDSA from 'iso-signatures/verifiers/ecdsa' | ||
import * as RSA from 'iso-signatures/verifiers/rsa' | ||
|
||
const message = new TextEncoder().encode('hello world') | ||
const resolver = new Resolver( | ||
{ | ||
...ECDSA.verifier, | ||
...EdDSA.verifier, | ||
}, | ||
{ cache: true } | ||
) | ||
const signer = await EdDSASigner.generate() | ||
const signature = await signer.sign(message) | ||
const verified = await resolver.verify({ | ||
signature, | ||
message, | ||
...signer.did, // Signer and DID both have `alg` property that the resolver uses to find the correct verifier | ||
}) | ||
``` | ||
|
||
## Docs | ||
|
||
Check <https://hugomrdias.github.io/iso-repo/modules/iso_signatures.html> | ||
|
||
## License | ||
|
||
MIT © [Hugo Dias](http://hugodias.me) |
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
throw new Error('Incorrect "iso-signatures" usage. Import submodules instead') |
7 changes: 3 additions & 4 deletions
7
...s/iso-did/src/signatures/signers/ecdsa.js → packages/iso-signatures/src/signers/ecdsa.js
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
Oops, something went wrong.