Skip to content

Commit

Permalink
feat: implement key and encrypt0
Browse files Browse the repository at this point in the history
  • Loading branch information
zensh committed Jan 15, 2024
1 parent 9293b1a commit f863bf6
Show file tree
Hide file tree
Showing 19 changed files with 4,168 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
src/**/*.test.ts
node_modules
coverage
dist
debug
19 changes: 19 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* eslint-env node */
module.exports = {
env: {
browser: true,
es2021: true,
},
extends: [
'plugin:@typescript-eslint/recommended-type-checked',
'plugin:@typescript-eslint/stylistic-type-checked',
],
plugins: ['@typescript-eslint'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: ['./tsconfig.json'],
ecmaVersion: 'latest',
sourceType: 'module',
},
root: true,
}
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: 'npm test'

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- run: npm install -g pnpm
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: '20.x'
cache: 'pnpm'
registry-url: 'https://registry.npmjs.org'
- run: |
pnpm install
pnpm lint
pnpm test
pnpm build
30 changes: 30 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: 'npm test && publish'

on:
push:
tags:
- 'v*'

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- run: npm install -g pnpm
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: '20.x'
cache: 'pnpm'
registry-url: 'https://registry.npmjs.org'
- run: |
pnpm install
pnpm lint
pnpm test
pnpm build
- run: npm publish .
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
40 changes: 38 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,38 @@
# cose-ts
Implemented Keys, Algorithms (RFC9053), COSE (RFC9052) and CWT (RFC8392) in TypeScript.
# Keys, Algorithms, COSE and CWT in TypeScript

[![CI](https://github.com/ldclabs/cose-ts/actions/workflows/ci.yml/badge.svg)](https://github.com/ldclabs/cose-ts/actions/workflows/ci.yml)
[![Codecov](https://codecov.io/gh/ldclabs/cose-ts/branch/main/graph/badge.svg)](https://codecov.io/gh/ldclabs/cose-ts)
[![CodeQL](https://github.com/ldclabs/cose-ts/actions/workflows/codeql.yml/badge.svg)](https://github.com/ldclabs/cose-ts/actions/workflows/codeql.yml)
[![License](http://img.shields.io/badge/license-mit-blue.svg?style=flat-square)](https://raw.githubusercontent.com/ldclabs/cose-ts/main/LICENSE)

*A golang library for the [CBOR Object Signing and Encryption (COSE)][cose-spec] and [CBOR Web Token (CWT)][cwt-spec].*

Golang version: [https://github.com/ldclabs/cose](https://github.com/ldclabs/cose)
Rust version: [https://github.com/google/coset](https://github.com/google/coset)

## Security Reviews

Todo.

## Reference

1. [RFC9052: CBOR Object Signing and Encryption (COSE)][cose-spec]
2. [RFC8392: CBOR Web Token (CWT)][cwt-spec]
3. [RFC9053: CBOR Object Signing and Encryption (COSE): Initial Algorithms][algorithms-spec]
4. [IANA: CBOR Object Signing and Encryption (COSE)][iana-cose]
5. [IANA: CBOR Web Token (CWT) Claims][iana-cwt]
6. [IANA: Concise Binary Object Representation (CBOR) Tags][iana-cbor-tags]


[cbor]: https://datatracker.ietf.org/doc/html/rfc8949
[cose-spec]: https://datatracker.ietf.org/doc/html/rfc9052
[cwt-spec]: https://datatracker.ietf.org/doc/html/rfc8392
[algorithms-spec]: https://datatracker.ietf.org/doc/html/rfc9053
[iana-cose]: https://www.iana.org/assignments/cose/cose.xhtml
[iana-cwt]: https://www.iana.org/assignments/cwt/cwt.xhtml
[iana-cbor-tags]: https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml

## License
Copyright © 2022-2024 [LDC Labs](https://github.com/ldclabs).

ldclabs/cose is licensed under the MIT License. See [LICENSE](LICENSE) for the full license text.
96 changes: 96 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"name": "@ldclabs/cose-ts",
"type": "module",
"version": "0.1.0",
"author": "0xZensh <[email protected]>",
"description": "Implemented Keys, Algorithms (RFC9053), COSE (RFC9052) and CWT (RFC8392) in TypeScript.",
"license": "MIT",
"homepage": "https://github.com/ldclabs/cose-ts",
"repository": {
"type": "git",
"url": "git+https://github.com/ldclabs/cose-ts.git"
},
"files": [
"dist",
"package.json",
"LICENSE",
"README.md"
],
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"browser": "./dist/index.js",
"default": "./dist/index.js"
},
"./aesgcm": {
"types": "./dist/aesgcm.d.ts",
"browser": "./dist/aesgcm.js",
"default": "./dist/aesgcm.js"
},
"./encrypt0": {
"types": "./dist/encrypt0.d.ts",
"browser": "./dist/encrypt0.js",
"default": "./dist/encrypt0.js"
},
"./iana": {
"types": "./dist/iana.d.ts",
"browser": "./dist/iana.js",
"default": "./dist/iana.js"
},
"./key": {
"types": "./dist/key.d.ts",
"browser": "./dist/key.js",
"default": "./dist/key.js"
},
"./map": {
"types": "./dist/map.d.ts",
"browser": "./dist/map.js",
"default": "./dist/map.js"
},
"./tag": {
"types": "./dist/tag.d.ts",
"browser": "./dist/tag.js",
"default": "./dist/tag.js"
},
"./utils": {
"types": "./dist/utils.d.ts",
"browser": "./dist/utils.js",
"default": "./dist/utils.js"
}
},
"browser": {
"node:crypto": false
},
"engines": {
"node": ">=18.0.0"
},
"scripts": {
"build": "npm run clean && tsc -p tsconfig.json",
"clean": "rm -rf dist",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"test": "vitest src --coverage --run"
},
"devDependencies": {
"@types/node": "^20.11.0",
"@typescript-eslint/eslint-plugin": "^6.18.1",
"@typescript-eslint/parser": "^6.18.1",
"@vitest/coverage-v8": "^1.2.0",
"cborg": "^4.0.7",
"eslint": "^8.56.0",
"eslint-plugin-import": "^2.29.1",
"typescript": "^5.3.3",
"vitest": "^1.2.0"
},
"keywords": [
"cose",
"cbor",
"RFC9052",
"RFC9053"
],
"dependencies": {
"@noble/ciphers": "=0.4.1"
}
}
Loading

0 comments on commit f863bf6

Please sign in to comment.