Skip to content

Commit

Permalink
Added command to check keys of multiple sectors at once
Browse files Browse the repository at this point in the history
  • Loading branch information
taichunmin committed May 16, 2024
1 parent 3f4e570 commit 861a1fe
Show file tree
Hide file tree
Showing 10 changed files with 936 additions and 650 deletions.
13 changes: 7 additions & 6 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ module.exports = {
},
extends: ['standard-with-typescript'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
plugins: ['@typescript-eslint', 'eslint-plugin-tsdoc'],
root: true,
parserOptions: {
project: './tsconfig.json'
},
rules: {
'@typescript-eslint/no-unsafe-argument': 0, // 0 = off, 1 = warn, 2 = error
'@typescript-eslint/return-await': 0, // 0 = off, 1 = warn, 2 = error
'multiline-ternary': 0, // 0 = off, 1 = warn, 2 = error
'no-extra-boolean-cast': 0, // 0 = off, 1 = warn, 2 = error
'no-return-await': 0, // 0 = off, 1 = warn, 2 = error
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/return-await': 'off',
'multiline-ternary': 'off',
'no-extra-boolean-cast': 'off',
'no-return-await': 'off',
'tsdoc/syntax': 'warn',
'@typescript-eslint/no-invalid-void-type': ['error', {
allowAsThisParameter: true,
}],
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,21 @@ jobs:
uses: actions/deploy-pages@v4
- name: 發布至 npm
uses: JS-DevTools/npm-publish@v3
id: npm-publish
with:
access: public
token: ${{ secrets.NPM_TOKEN }}
- name: jsDelivr Purge
if: ${{ steps.npm-publish.outputs.type }}
uses: egad13/purge-jsdelivr-cache@v1
with:
url: |
https://cdn.jsdelivr.net/npm/chameleon-ultra.js/dist/iife/index.min.js
https://cdn.jsdelivr.net/npm/chameleon-ultra.js/dist/iife/Crypto1.min.js
https://cdn.jsdelivr.net/npm/chameleon-ultra.js/dist/iife/plugin/WebbleAdapter.min.js
https://cdn.jsdelivr.net/npm/chameleon-ultra.js/dist/iife/plugin/WebserialAdapter.min.js
https://cdn.jsdelivr.net/npm/chameleon-ultra.js@0/dist/iife/index.min.js
https://cdn.jsdelivr.net/npm/chameleon-ultra.js@0/dist/iife/Crypto1.min.js
https://cdn.jsdelivr.net/npm/chameleon-ultra.js@0/dist/iife/plugin/WebbleAdapter.min.js
https://cdn.jsdelivr.net/npm/chameleon-ultra.js@0/dist/iife/plugin/WebserialAdapter.min.js
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,4 @@ out
/src/example
/tsconfig.*.json
/tsconfig.json
/tsdoc.json
45 changes: 23 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"repository": "[email protected]:taichunmin/chameleon-ultra.js.git",
"type": "module",
"unpkg": "dist/iife/index.min.js",
"version": "0.2.21",
"version": "0.2.22",
"bugs": {
"url": "https://github.com/taichunmin/chameleon-ultra.js/issues"
},
Expand All @@ -26,62 +26,63 @@
"lodash": "^4.17.21",
"serialport": "^12.0.0",
"web-serial-polyfill": "^1.0.15",
"webbluetooth": "^3.1.0"
"webbluetooth": "^3.2.1"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.6",
"@tsconfig/node-lts": "^20.1.1",
"@tsconfig/node-lts": "^20.1.3",
"@types/debug": "^4.1.12",
"@types/finalhandler": "^1.2.3",
"@types/html-minifier": "^4.0.5",
"@types/jest": "^29.5.11",
"@types/jest": "^29.5.12",
"@types/livereload": "^0.9.5",
"@types/lodash": "^4.14.202",
"@types/node": "^20.11.4",
"@types/lodash": "^4.17.1",
"@types/node": "^20.12.11",
"@types/pug": "^2.0.10",
"@types/serve-static": "^1.15.5",
"@types/uglify-js": "^3.17.4",
"@types/serve-static": "^1.15.7",
"@types/uglify-js": "^3.17.5",
"@types/web-bluetooth": "^0.0.20",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"chokidar": "^3.5.3",
"@typescript-eslint/eslint-plugin": "^7.8.0",
"chokidar": "^3.6.0",
"concurrently": "^8.2.2",
"dayjs": "^1.11.10",
"dotenv": "^16.3.1",
"eslint": "^8.56.0",
"dayjs": "^1.11.11",
"dotenv": "^16.4.5",
"eslint": "^8.57.0",
"eslint-config-standard-with-typescript": "^43.0.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-n": "^17.6.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-pug": "^1.2.5",
"eslint-plugin-tsdoc": "^0.2.17",
"finalhandler": "^1.2.0",
"html-minifier": "^4.0.0",
"jest": "^29.7.0",
"jstransformer-sass": "^1.0.0",
"livereload": "^0.9.3",
"node-watch": "^0.7.4",
"nodemon": "^3.0.2",
"nodemon": "^3.1.0",
"pug": "^3.0.2",
"rimraf": "^5.0.5",
"rollup": "^4.9.5",
"rollup": "^4.17.2",
"rollup-plugin-dts": "^6.1.0",
"rollup-plugin-polyfill-node": "^0.13.0",
"rollup-plugin-version-injector": "^1.3.3",
"serve-static": "^1.15.0",
"supports-color": "^9.4.0",
"ts-jest": "^29.1.1",
"ts-jest": "^29.1.2",
"tslib": "^2.6.2",
"tsx": "^4.7.0",
"typedoc": "^0.25.7",
"typedoc-plugin-mdn-links": "^3.1.12",
"tsx": "^4.9.3",
"typedoc": "^0.25.13",
"typedoc-plugin-mdn-links": "^3.1.24",
"typedoc-plugin-missing-exports": "^2.2.0",
"typedoc-plugin-rename-defaults": "^0.7.0",
"typedoc-plugin-zod": "^1.1.2",
"typescript": "^5.3.3",
"typescript": "^5.4.5",
"uglify-js": "^3.17.4",
"utility-types": "^3.10.0"
"utility-types": "^3.11.0"
},
"exports": {
"./package.json": "./package.json",
Expand Down
18 changes: 6 additions & 12 deletions src/ChameleonUltra.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1218,8 +1218,7 @@ describe('ChameleonUltra with BufferMockAdapter', () => {
test('#mf1CheckSectorKeys()', async () => {
// arrange
adapter.send.push(Buffer.fromHexString('11ef 03e9 0068 0000 ac 00')) // DeviceMode.READER
adapter.send.push(Buffer.fromHexString('11ef 07d7 0000 0000 22 00'))
adapter.send.push(Buffer.fromHexString('11ef 07d8 0000 0010 11 000000000000ff078069ffffffffffff 17'))
adapter.send.push(Buffer.fromHexString('11ef 07dc 0000 01ea 32 c0000000000000000000ffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 4c'))

// act
const keys = Buffer.from('FFFFFFFFFFFF\n000000000000\nA0A1A2A3A4A5\nD3F7D3F7D3F7', 'hex').chunk(6)
Expand All @@ -1232,16 +1231,14 @@ describe('ChameleonUltra with BufferMockAdapter', () => {
})
expect(adapter.recv).toEqual([
Buffer.fromHexString('11ef 03e9 0000 0001 13 01 ff'), // DeviceMode.READER
Buffer.fromHexString('11ef 07d7 0000 0008 1a 6003ffffffffffff a3'),
Buffer.fromHexString('11ef 07d8 0000 0008 19 6003ffffffffffff a3'),
Buffer.fromHexString('11ef 07dc 0000 0022 fb 3fffffffffffffffffffffffffffffff000000000000a0a1a2a3a4a5d3f7d3f7d3f7 a3'),
])
})

test('#mf1ReadSectorByKeys()', async () => {
// arrange
adapter.send.push(Buffer.fromHexString('11ef 03e9 0068 0000 ac 00')) // DeviceMode.READER
adapter.send.push(Buffer.fromHexString('11ef 07d7 0000 0000 22 00'))
adapter.send.push(Buffer.fromHexString('11ef 07d8 0000 0010 11 000000000000ff078069ffffffffffff 17'))
adapter.send.push(Buffer.fromHexString('11ef 07dc 0000 01ea 32 c0000000000000000000ffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 4c'))
adapter.send.push(Buffer.fromHexString('11ef 07d8 0000 0010 11 877209e11d0804000392abdef258ec90 10'))
adapter.send.push(Buffer.fromHexString('11ef 07d8 0000 0010 11 00000000000000000000000000000000 00'))
adapter.send.push(Buffer.fromHexString('11ef 07d8 0000 0010 11 00000000000000000000000000000000 00'))
Expand All @@ -1263,8 +1260,7 @@ describe('ChameleonUltra with BufferMockAdapter', () => {
})
expect(adapter.recv).toEqual([
Buffer.fromHexString('11ef 03e9 0000 0001 13 01 ff'), // DeviceMode.READER
Buffer.fromHexString('11ef 07d7 0000 0008 1a 6003ffffffffffff a3'),
Buffer.fromHexString('11ef 07d8 0000 0008 19 6003ffffffffffff a3'),
Buffer.fromHexString('11ef 07dc 0000 0022 fb 3fffffffffffffffffffffffffffffff000000000000a0a1a2a3a4a5d3f7d3f7d3f7 a3'),
Buffer.fromHexString('11ef 07d8 0000 0008 19 6100ffffffffffff a5'),
Buffer.fromHexString('11ef 07d8 0000 0008 19 6101ffffffffffff a4'),
Buffer.fromHexString('11ef 07d8 0000 0008 19 6102ffffffffffff a3'),
Expand All @@ -1275,8 +1271,7 @@ describe('ChameleonUltra with BufferMockAdapter', () => {
test('#mf1WriteSectorByKeys()', async () => {
// arrange
adapter.send.push(Buffer.fromHexString('11ef 03e9 0068 0000 ac 00')) // DeviceMode.READER
adapter.send.push(Buffer.fromHexString('11ef 07d7 0000 0000 22 00'))
adapter.send.push(Buffer.fromHexString('11ef 07d8 0000 0010 11 000000000000ff078069ffffffffffff 17'))
adapter.send.push(Buffer.fromHexString('11ef 07dc 0000 01ea 32 30000000000000000000000000000000000000000000ffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 dc'))
adapter.send.push(Buffer.fromHexString('11ef 07d9 0000 0000 20 00'))
adapter.send.push(Buffer.fromHexString('11ef 07d9 0000 0000 20 00'))
adapter.send.push(Buffer.fromHexString('11ef 07d9 0000 0000 20 00'))
Expand All @@ -1296,8 +1291,7 @@ describe('ChameleonUltra with BufferMockAdapter', () => {
expect(actual).toEqual({ success: [true, true, true, true] })
expect(adapter.recv).toEqual([
Buffer.fromHexString('11ef 03e9 0000 0001 13 01 ff'), // DeviceMode.READER
Buffer.fromHexString('11ef 07d7 0000 0008 1a 6007ffffffffffff 9f'),
Buffer.fromHexString('11ef 07d8 0000 0008 19 6007ffffffffffff 9f'),
Buffer.fromHexString('11ef 07dc 0000 0022 fb cfffffffffffffffffffffffffffffff000000000000a0a1a2a3a4a5d3f7d3f7d3f7 13'),
Buffer.fromHexString('11ef 07d9 0000 0018 08 6104ffffffffffff00000000000000000000000000000000 a1'),
Buffer.fromHexString('11ef 07d9 0000 0018 08 6105ffffffffffff00000000000000000000000000000000 a0'),
Buffer.fromHexString('11ef 07d9 0000 0018 08 6106ffffffffffff00000000000000000000000000000000 9f'),
Expand Down
Loading

0 comments on commit 861a1fe

Please sign in to comment.