Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
septs committed Oct 16, 2024
0 parents commit 33ea940
Show file tree
Hide file tree
Showing 43 changed files with 9,867 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

[*]
charset = utf-8
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
32 changes: 32 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Publish to GitHub Pages

on:
workflow_dispatch:
push:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm ci
- run: npm run build --workspace examples
- uses: actions/upload-pages-artifact@v3
with:
path: examples/dist
deploy:
runs-on: ubuntu-latest
needs: build
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@v4
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/node_modules
/dist
/cjs
/esm
8 changes: 8 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extension": ["ts"],
"spec": "src/**/*.spec.ts",
"require": "ts-node/register",
"loader": "ts-node/esm",
"recursive": true,
"watch-files": ["src"]
}
7 changes: 7 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/examples
/docs
/dist
/src/**/*.spec.ts
/.*
/*.code-workspace
/tsconfig*
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"quoteProps": "consistent",
"singleQuote": true,
"semi": false,
"printWidth": 120
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": "always"
}
}
661 changes: 661 additions & 0 deletions LICENSE.txt

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# NotCCID

The NotCCID communication protocol is only available for [ESTKme-RED] product.

[ESTKme-RED]: https://www.estk.me/product/estkme-red/

## Installation

```bash
# Install from GitHub Packages (Unstable)
npm install @estkme-group/notccid --registry=https://npm.pkg.github.com
```

## References

- [Running the example locally](docs/examples.md)
- [Protocol Design](docs/protocol-design.md)
- [Debugging in Chrome](docs/chrome-debugger.md)
- [WebBLEBackend.ts](src/backends/WebBLEBackend.ts)
- [WebUSBBackend.ts](src/backends/WebUSBBackend.ts)

## LICENSE

[AGPLv3 only](LICENSE.txt)
18 changes: 18 additions & 0 deletions docs/chrome-debugger.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Debugging in Google Chrome

## WebUSB

Internal: `chrome://usb-internals`

Logging: `chrome://device-log/?refresh=1&types=USB`

## Web Bluetooth

Internal: `chrome://bluetooth-internals`

Logging: `chrome://device-log/?refresh=1&types=Bluetooth`

## References

- [Access USB Devices on the Web](https://developer.chrome.com/docs/capabilities/usb)
- [Communicating with Bluetooth devices over JavaScript](https://developer.chrome.com/docs/capabilities/bluetooth)
25 changes: 25 additions & 0 deletions docs/examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# NotCCID Examples

## Quick start

```console
$ # install dependencies
$ npm ci
...
$ # run the examples
$ npm run examples

> @estkme-group/notccid@0.0.0 examples
> npm start --workspace examples


> @estkme-group/notccid-examples@0.0.0 start
> webpack serve --mode development

<i> [webpack-dev-server] Generating SSL certificate...
<i> [webpack-dev-server] SSL certificate: ********
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: https://localhost:8080/, https://[::1]:8080/
<i> [webpack-dev-server] On Your Network (IPv4): ********
<i> [webpack-dev-server] Content not from webpack is served from '*' directory
```
49 changes: 49 additions & 0 deletions docs/protocol-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# NotCCID Protocol Design

The NotCCID communication protocol is only available for [ESTKme-RED] product.

[ESTKme-RED]: https://www.estk.me/product/estkme-red/

## Protocol format

### Packet Format

| Offset | Field | Type |
| ------ | -------------------- | -------------------- |
| 0 | [Type](#packet-type) | 1 byte |
| 1 | Length | 2 bytes (Uint16, LE) |
| 3…n | Payload | n bytes |

### Packet Type

| Type | Payload | Inserted | Claimed | Description |
| ---- | ----------- | :------: | :-----: | ---------------------- |
| `00` | \<empty> | N | N | Get Status |
| `01` | `RRGGBB` | N | N | Emit RGB LED |
| `01` | \<empty> | N | N | Reset RGB LED |
| `02` | `b'ESTKme'` | Y | N | Claim |
| `02` | \<empty> | Y | Y | Release |
| `03` | `0100` | Y | Y | Power On Card, No PPS |
| `03` | `0101` | Y | Y | Power On Card, Use PPS |
| `03` | \<empty> | Y | Y | Power Off Card |
| `04` | \<APDU> | Y | Y | Transmit APDU |
| `F0` | \<empty> | Y | N | eSTK.me Recovery Mode |

## Main Workflow

```mermaid
flowchart
claim["Claim"]
release["Release"]
transmit["Transmit APDU"]
powerOn["Power On"]
powerOff["Power Off"]
claim -- claimed --> powerOn
claim -- released --> release
powerOff -- released --> release
powerOn --> transmit
transmit --> powerOff
powerOff --> powerOn
```
45 changes: 45 additions & 0 deletions docs/red-diagram.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# ESTKme-RED Diagram

## Uncontrolled RGB LED State Diagram

### General

```mermaid
stateDiagram-v2
classDef white fill:white,color:#000
classDef blue fill:blue,color:#fff
classDef green fill:green,color:#000
classDef red fill:red,color:#000
classDef yellow fill:yellow,color:#000
[*] --> White:::white: Booting
White --> Red:::red: No response
White --> Green:::green: Using USB
White --> Yellow:::yellow: BLE Initializing
Yellow --> Blue:::blue: Using BLE
```

### DFU Mode

Short C1 and C3 pins to enter ESTKme-RED reader DFU mode

see [Smartcard Pinout](https://en.wikipedia.org/wiki/Smart_card#/media/File:SmartCardPinout.svg) definiton

```mermaid
stateDiagram-v2
classDef blue fill:blue,color:#fff
classDef green fill:green,color:#000
classDef red fill:red,color:#000
[*] --> Blue:::blue: Enter DFU mode
Blue --> Green:::green
Green --> Red:::red
Red --> Off: Erase firmware
Off --> [*]: Entered DFU mode
Blue --> Boot
Green --> Boot
Red --> Boot
Boot --> [*]: Booting App
```
12 changes: 12 additions & 0 deletions examples.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"folders": [
{ "name": "NotCCID", "path": "." },
{ "name": "NotCCID (Examples)", "path": "examples" }
],
"settings": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": "always"
}
}
}
8 changes: 8 additions & 0 deletions examples/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

[*]
charset = utf-8
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
2 changes: 2 additions & 0 deletions examples/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules
/dist
7 changes: 7 additions & 0 deletions examples/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"quoteProps": "consistent",
"singleQuote": true,
"jsxSingleQuote": true,
"semi": false,
"printWidth": 120
}
33 changes: 33 additions & 0 deletions examples/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "@estkme-group/notccid-examples",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "webpack serve --mode development",
"build": "webpack build --mode production"
},
"dependencies": {
"async-mutex": "^0.5.0",
"bootstrap": "^5.3.3",
"domready": "^1.0.8",
"react": "^18.3.1",
"react-bootstrap": "^2.10.5",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@types/domready": "~1.0.2",
"@types/react": "~18.3.11",
"@types/react-color": "^3.0.12",
"@types/react-dom": "~18.3.0",
"css-loader": "^7.1.2",
"html-webpack-plugin": "^5.6.0",
"mini-css-extract-plugin": "^2.9.1",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
"tsconfig-paths-webpack-plugin": "^4.1.0",
"typescript": "^5.6.3",
"webpack": "^5.95.0",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^5.1.0"
}
}
Loading

0 comments on commit 33ea940

Please sign in to comment.