From d1b07e0a81b4d9485c9b44d9fba80dd4963d1398 Mon Sep 17 00:00:00 2001 From: Niccolo Borgioli Date: Fri, 13 Jan 2023 20:42:36 +0100 Subject: [PATCH] add generate key --- package.json | 14 +-- pnpm-lock.yaml | 298 ++++++++++++++++++++++++++++++---------------- src/crypto/aes.ts | 17 ++- src/index.ts | 2 +- test/aes.spec.js | 35 ++++-- test/values.js | 7 +- 6 files changed, 244 insertions(+), 129 deletions(-) diff --git a/package.json b/package.json index 30a8dba..db8d7f4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "occulto", - "version": "2.0.0-rc.9", + "version": "2.0.0-rc.10", "license": "MIT", "description": "crypt utility", "keywords": [ @@ -41,15 +41,15 @@ }, "devDependencies": { "@endyjasmi/karma-playwright-launcher": "^0.0.4", - "@types/node": "^16.11.66", - "chai": "^4.3.6", + "@types/node": "^16.18.11", + "chai": "^4.3.7", "karma": "^6.4.1", "karma-mocha": "^2.0.1", - "mocha": "^10.1.0", + "mocha": "^10.2.0", "npm-run-all": "^4.1.5", - "playwright": "^1.27.1", - "typedoc": "^0.23.17", - "typescript": "^4.8.4" + "playwright": "^1.29.2", + "typedoc": "^0.23.24", + "typescript": "^4.9.4" }, "repository": { "type": "git", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 53eee9f..5cc2473 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2,27 +2,27 @@ lockfileVersion: 5.4 specifiers: '@endyjasmi/karma-playwright-launcher': ^0.0.4 - '@types/node': ^16.11.66 - chai: ^4.3.6 + '@types/node': ^16.18.11 + chai: ^4.3.7 karma: ^6.4.1 karma-mocha: ^2.0.1 - mocha: ^10.1.0 + mocha: ^10.2.0 npm-run-all: ^4.1.5 - playwright: ^1.27.1 - typedoc: ^0.23.17 - typescript: ^4.8.4 + playwright: ^1.29.2 + typedoc: ^0.23.24 + typescript: ^4.9.4 devDependencies: - '@endyjasmi/karma-playwright-launcher': 0.0.4_playwright@1.27.1 - '@types/node': 16.11.66 - chai: 4.3.6 + '@endyjasmi/karma-playwright-launcher': 0.0.4_playwright@1.29.2 + '@types/node': 16.18.11 + chai: 4.3.7 karma: 6.4.1 karma-mocha: 2.0.1 - mocha: 10.1.0 + mocha: 10.2.0 npm-run-all: 4.1.5 - playwright: 1.27.1 - typedoc: 0.23.17_typescript@4.8.4 - typescript: 4.8.4 + playwright: 1.29.2 + typedoc: 0.23.24_typescript@4.9.4 + typescript: 4.9.4 packages: @@ -31,12 +31,12 @@ packages: engines: {node: '>=0.1.90'} dev: true - /@endyjasmi/karma-playwright-launcher/0.0.4_playwright@1.27.1: + /@endyjasmi/karma-playwright-launcher/0.0.4_playwright@1.29.2: resolution: {integrity: sha512-1QFuPRSukNE/mjc0ONRgZsJ0zRQyZG3vt5ISPMxWjvGsm4K5Xfv51t82rwB21jTpe7zauesUXCGHpalY6RZpTg==} peerDependencies: playwright: 1.x dependencies: - playwright: 1.27.1 + playwright: 1.29.2 dev: true /@socket.io/component-emitter/3.1.0: @@ -47,12 +47,14 @@ packages: resolution: {integrity: sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==} dev: true - /@types/cors/2.8.12: - resolution: {integrity: sha512-vt+kDhq/M2ayberEtJcIN/hxXy1Pk+59g2FV/ZQceeaTyCtCucjL2Q7FXlFjtWn4n15KCr1NE2lNNFhp0lEThw==} + /@types/cors/2.8.13: + resolution: {integrity: sha512-RG8AStHlUiV5ysZQKq97copd2UmVYw3/pRMLefISZ3S1hK104Cwm7iLQ3fTKx+lsUH2CE8FlLaYeEA2LSeqYUA==} + dependencies: + '@types/node': 16.18.11 dev: true - /@types/node/16.11.66: - resolution: {integrity: sha512-+xvMrGl3eAygKcf5jm+4zA4tbfEgmKM9o6/glTmN0RFVdu2VuFXMYYtRmuv3zTGCgAYMnEZLde3B7BTp+Yxcig==} + /@types/node/16.18.11: + resolution: {integrity: sha512-3oJbGBUWuS6ahSnEq1eN2XrCyf4YsWI8OyCvo7c64zQJNplk3mO84t53o8lfTk+2ji59g5ycfc6qQ3fdHliHuA==} dev: true /accepts/1.3.8: @@ -87,8 +89,8 @@ packages: color-convert: 2.0.1 dev: true - /anymatch/3.1.2: - resolution: {integrity: sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==} + /anymatch/3.1.3: + resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==} engines: {node: '>= 8'} dependencies: normalize-path: 3.0.0 @@ -103,6 +105,11 @@ packages: resolution: {integrity: sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==} dev: true + /available-typed-arrays/1.0.5: + resolution: {integrity: sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==} + engines: {node: '>= 0.4'} + dev: true + /balanced-match/1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} dev: true @@ -178,15 +185,15 @@ packages: engines: {node: '>=10'} dev: true - /chai/4.3.6: - resolution: {integrity: sha512-bbcp3YfHCUzMOvKqsztczerVgBKSsEijCySNlHHbX3VG1nskvqjz5Rfso1gGwD6w6oOV3eI60pKuMOV5MV7p3Q==} + /chai/4.3.7: + resolution: {integrity: sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A==} engines: {node: '>=4'} dependencies: assertion-error: 1.1.0 check-error: 1.0.2 - deep-eql: 3.0.1 + deep-eql: 4.1.3 get-func-name: 2.0.0 - loupe: 2.3.4 + loupe: 2.3.6 pathval: 1.1.1 type-detect: 4.0.8 dev: true @@ -216,7 +223,7 @@ packages: resolution: {integrity: sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==} engines: {node: '>= 8.10.0'} dependencies: - anymatch: 3.1.2 + anymatch: 3.1.3 braces: 3.0.2 glob-parent: 5.1.2 is-binary-path: 2.1.0 @@ -257,7 +264,7 @@ packages: dev: true /concat-map/0.0.1: - resolution: {integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=} + resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} dev: true /connect/3.7.0: @@ -351,9 +358,9 @@ packages: engines: {node: '>=10'} dev: true - /deep-eql/3.0.1: - resolution: {integrity: sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==} - engines: {node: '>=0.12'} + /deep-eql/4.1.3: + resolution: {integrity: sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==} + engines: {node: '>=6'} dependencies: type-detect: 4.0.8 dev: true @@ -395,7 +402,7 @@ packages: dev: true /ee-first/1.1.1: - resolution: {integrity: sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=} + resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==} dev: true /emoji-regex/8.0.0: @@ -407,24 +414,24 @@ packages: engines: {node: '>= 0.8'} dev: true - /engine.io-parser/5.0.4: - resolution: {integrity: sha512-+nVFp+5z1E3HcToEnO7ZIj3g+3k9389DvWtvJZz0T6/eOCPIyyxehFcedoYrZQrp0LgQbD9pPXhpMBKMd5QURg==} + /engine.io-parser/5.0.5: + resolution: {integrity: sha512-mjEyaa4zhuuRhaSLOdjEb57X0XPP9JEsnXI4E+ivhwT0GgzUogARx4MqoY1jQyB+4Bkz3BUOmzL7t9RMKmlG3g==} engines: {node: '>=10.0.0'} dev: true - /engine.io/6.2.0: - resolution: {integrity: sha512-4KzwW3F3bk+KlzSOY57fj/Jx6LyRQ1nbcyIadehl+AnXjKT7gDO0ORdRi/84ixvMKTym6ZKuxvbzN62HDDU1Lg==} + /engine.io/6.2.1: + resolution: {integrity: sha512-ECceEFcAaNRybd3lsGQKas3ZlMVjN3cyWwMP25D2i0zWfyiytVbTpRPa34qrr+FHddtpBVOmq4H/DCv1O0lZRA==} engines: {node: '>=10.0.0'} dependencies: '@types/cookie': 0.4.1 - '@types/cors': 2.8.12 - '@types/node': 16.11.66 + '@types/cors': 2.8.13 + '@types/node': 16.18.11 accepts: 1.3.8 base64id: 2.0.0 cookie: 0.4.2 cors: 2.8.5 debug: 4.3.4 - engine.io-parser: 5.0.4 + engine.io-parser: 5.0.5 ws: 8.2.3 transitivePeerDependencies: - bufferutil @@ -442,34 +449,52 @@ packages: is-arrayish: 0.2.1 dev: true - /es-abstract/1.20.4: - resolution: {integrity: sha512-0UtvRN79eMe2L+UNEF1BwRe364sj/DXhQ/k5FmivgoSdpM90b8Jc0mDzKMGo7QS0BVbOP/bTwBKNnDc9rNzaPA==} + /es-abstract/1.21.1: + resolution: {integrity: sha512-QudMsPOz86xYz/1dG1OuGBKOELjCh99IIWHLzy5znUB6j8xG2yMA7bfTV86VSqKF+Y/H08vQPR+9jyXpuC6hfg==} engines: {node: '>= 0.4'} dependencies: + available-typed-arrays: 1.0.5 call-bind: 1.0.2 + es-set-tostringtag: 2.0.1 es-to-primitive: 1.2.1 function-bind: 1.1.1 function.prototype.name: 1.1.5 get-intrinsic: 1.1.3 get-symbol-description: 1.0.0 + globalthis: 1.0.3 + gopd: 1.0.1 has: 1.0.3 has-property-descriptors: 1.0.0 + has-proto: 1.0.1 has-symbols: 1.0.3 - internal-slot: 1.0.3 + internal-slot: 1.0.4 + is-array-buffer: 3.0.1 is-callable: 1.2.7 is-negative-zero: 2.0.2 is-regex: 1.1.4 is-shared-array-buffer: 1.0.2 is-string: 1.0.7 + is-typed-array: 1.1.10 is-weakref: 1.0.2 - object-inspect: 1.12.2 + object-inspect: 1.12.3 object-keys: 1.1.1 object.assign: 4.1.4 regexp.prototype.flags: 1.4.3 safe-regex-test: 1.0.0 - string.prototype.trimend: 1.0.5 - string.prototype.trimstart: 1.0.5 + string.prototype.trimend: 1.0.6 + string.prototype.trimstart: 1.0.6 + typed-array-length: 1.0.4 unbox-primitive: 1.0.2 + which-typed-array: 1.1.9 + dev: true + + /es-set-tostringtag/2.0.1: + resolution: {integrity: sha512-g3OMbtlwY3QewlqAiMLI47KywjWZoEytKr8pf6iTC8uJq5bIAH52Z9pnQ8pVL6whrCto53JZDuUIsifGeLorTg==} + engines: {node: '>= 0.4'} + dependencies: + get-intrinsic: 1.1.3 + has: 1.0.3 + has-tostringtag: 1.0.0 dev: true /es-to-primitive/1.2.1: @@ -557,6 +582,12 @@ packages: optional: true dev: true + /for-each/0.3.3: + resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==} + dependencies: + is-callable: 1.2.7 + dev: true + /fs-extra/8.1.0: resolution: {integrity: sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==} engines: {node: '>=6 <7 || >=8'} @@ -588,7 +619,7 @@ packages: dependencies: call-bind: 1.0.2 define-properties: 1.1.4 - es-abstract: 1.20.4 + es-abstract: 1.21.1 functions-have-names: 1.2.3 dev: true @@ -650,6 +681,19 @@ packages: path-is-absolute: 1.0.1 dev: true + /globalthis/1.0.3: + resolution: {integrity: sha512-sFdI5LyBiNTHjRd7cGPWapiHWMOXKyuBNX/cWJ3NfzrZQVa8GI/8cofCl74AOVqq9W5kNmguTIzJ/1s2gyI9wA==} + engines: {node: '>= 0.4'} + dependencies: + define-properties: 1.1.4 + dev: true + + /gopd/1.0.1: + resolution: {integrity: sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==} + dependencies: + get-intrinsic: 1.1.3 + dev: true + /graceful-fs/4.2.10: resolution: {integrity: sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==} dev: true @@ -674,6 +718,11 @@ packages: get-intrinsic: 1.1.3 dev: true + /has-proto/1.0.1: + resolution: {integrity: sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==} + engines: {node: '>= 0.4'} + dev: true + /has-symbols/1.0.3: resolution: {integrity: sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==} engines: {node: '>= 0.4'} @@ -742,8 +791,8 @@ packages: resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} dev: true - /internal-slot/1.0.3: - resolution: {integrity: sha512-O0DB1JC/sPyZl7cIo78n5dR7eUSwwpYPiXRhTzNxZVAMUuB8vlnRFyLxdrVToks6XPLVnFfbzaVd5WLjhgg+vA==} + /internal-slot/1.0.4: + resolution: {integrity: sha512-tA8URYccNzMo94s5MQZgH8NB/XTa6HsOo0MLfXTKKEnHVVdegzaQoFZ7Jp44bdvLvY2waT5dc+j5ICEswhi7UQ==} engines: {node: '>= 0.4'} dependencies: get-intrinsic: 1.1.3 @@ -751,6 +800,14 @@ packages: side-channel: 1.0.4 dev: true + /is-array-buffer/3.0.1: + resolution: {integrity: sha512-ASfLknmY8Xa2XtB4wmbz13Wu202baeA18cJBCeCy0wXUHZF0IPyVEXqKEcd+t2fNSLLL1vC6k7lxZEojNbISXQ==} + dependencies: + call-bind: 1.0.2 + get-intrinsic: 1.1.3 + is-typed-array: 1.1.10 + dev: true + /is-arrayish/0.2.1: resolution: {integrity: sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==} dev: true @@ -781,8 +838,8 @@ packages: engines: {node: '>= 0.4'} dev: true - /is-core-module/2.10.0: - resolution: {integrity: sha512-Erxj2n/LDAZ7H8WNJXd9tw38GYM3dv8rk8Zcs+jJuxYTW7sozH+SS8NtrSjVL1/vpLvWi1hxy96IzjJ3EHTJJg==} + /is-core-module/2.11.0: + resolution: {integrity: sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==} dependencies: has: 1.0.3 dev: true @@ -861,6 +918,17 @@ packages: has-symbols: 1.0.3 dev: true + /is-typed-array/1.1.10: + resolution: {integrity: sha512-PJqgEHiWZvMpaFZ3uTc8kHPM4+4ADTlDniuQL7cU/UDA0Ql7F70yGfHph3cLNe+c9toaigv+DFzTJKhc2CtO6A==} + engines: {node: '>= 0.4'} + dependencies: + available-typed-arrays: 1.0.5 + call-bind: 1.0.2 + for-each: 0.3.3 + gopd: 1.0.1 + has-tostringtag: 1.0.0 + dev: true + /is-unicode-supported/0.1.0: resolution: {integrity: sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==} engines: {node: '>=10'} @@ -925,14 +993,14 @@ packages: http-proxy: 1.18.1 isbinaryfile: 4.0.10 lodash: 4.17.21 - log4js: 6.7.0 + log4js: 6.7.1 mime: 2.6.0 minimatch: 3.1.2 mkdirp: 0.5.6 qjobs: 1.2.0 range-parser: 1.2.1 rimraf: 3.0.2 - socket.io: 4.5.3 + socket.io: 4.5.4 source-map: 0.6.1 tmp: 0.2.1 ua-parser-js: 0.7.32 @@ -973,21 +1041,21 @@ packages: is-unicode-supported: 0.1.0 dev: true - /log4js/6.7.0: - resolution: {integrity: sha512-KA0W9ffgNBLDj6fZCq/lRbgR6ABAodRIDHrZnS48vOtfKa4PzWImb0Md1lmGCdO3n3sbCm/n1/WmrNlZ8kCI3Q==} + /log4js/6.7.1: + resolution: {integrity: sha512-lzbd0Eq1HRdWM2abSD7mk6YIVY0AogGJzb/z+lqzRk+8+XJP+M6L1MS5FUSc3jjGru4dbKjEMJmqlsoYYpuivQ==} engines: {node: '>=8.0'} dependencies: date-format: 4.0.14 debug: 4.3.4 flatted: 3.2.7 rfdc: 1.3.0 - streamroller: 3.1.3 + streamroller: 3.1.4 transitivePeerDependencies: - supports-color dev: true - /loupe/2.3.4: - resolution: {integrity: sha512-OvKfgCC2Ndby6aSTREl5aCCPTNIzlDfQZvZxNUrBrihDhL3xcrYegTblhmEiCrg2kKQz4XsFIaemE5BF4ybSaQ==} + /loupe/2.3.6: + resolution: {integrity: sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==} dependencies: get-func-name: 2.0.0 dev: true @@ -996,14 +1064,14 @@ packages: resolution: {integrity: sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==} dev: true - /marked/4.1.1: - resolution: {integrity: sha512-0cNMnTcUJPxbA6uWmCmjWz4NJRe/0Xfk2NhXCUHjew9qJzFN20krFnsUe7QynwqOwa5m1fZ4UDg0ycKFVC0ccw==} + /marked/4.2.5: + resolution: {integrity: sha512-jPueVhumq7idETHkb203WDD4fMA3yV9emQ5vLwop58lu8bTclMghBWcYAavlDqIEMaisADinV1TooIFCfqOsYQ==} engines: {node: '>= 12'} hasBin: true dev: true /media-typer/0.3.0: - resolution: {integrity: sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=} + resolution: {integrity: sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==} engines: {node: '>= 0.6'} dev: true @@ -1043,8 +1111,8 @@ packages: brace-expansion: 2.0.1 dev: true - /minimatch/5.1.0: - resolution: {integrity: sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==} + /minimatch/5.1.2: + resolution: {integrity: sha512-bNH9mmM9qsJ2X4r2Nat1B//1dJVcn3+iBLa3IgqJ7EbGaDNepL9QSHOxN4ng33s52VMMhhIfgCYDk3C4ZmlDAg==} engines: {node: '>=10'} dependencies: brace-expansion: 2.0.1 @@ -1061,8 +1129,8 @@ packages: minimist: 1.2.7 dev: true - /mocha/10.1.0: - resolution: {integrity: sha512-vUF7IYxEoN7XhQpFLxQAEMtE4W91acW4B6En9l97MwE9stL1A9gusXfoHZCLVHDUJ/7V5+lbCM6yMqzo5vNymg==} + /mocha/10.2.0: + resolution: {integrity: sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==} engines: {node: '>= 14.0.0'} hasBin: true dependencies: @@ -1143,7 +1211,7 @@ packages: pidtree: 0.3.1 read-pkg: 3.0.0 shell-quote: 1.7.4 - string.prototype.padend: 3.1.3 + string.prototype.padend: 3.1.4 dev: true /object-assign/4.1.1: @@ -1151,8 +1219,8 @@ packages: engines: {node: '>=0.10.0'} dev: true - /object-inspect/1.12.2: - resolution: {integrity: sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ==} + /object-inspect/1.12.3: + resolution: {integrity: sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==} dev: true /object-keys/1.1.1: @@ -1263,19 +1331,19 @@ packages: engines: {node: '>=4'} dev: true - /playwright-core/1.27.1: - resolution: {integrity: sha512-9EmeXDncC2Pmp/z+teoVYlvmPWUC6ejSSYZUln7YaP89Z6lpAaiaAnqroUt/BoLo8tn7WYShcfaCh+xofZa44Q==} + /playwright-core/1.29.2: + resolution: {integrity: sha512-94QXm4PMgFoHAhlCuoWyaBYKb92yOcGVHdQLoxQ7Wjlc7Flg4aC/jbFW7xMR52OfXMVkWicue4WXE7QEegbIRA==} engines: {node: '>=14'} hasBin: true dev: true - /playwright/1.27.1: - resolution: {integrity: sha512-xXYZ7m36yTtC+oFgqH0eTgullGztKSRMb4yuwLPl8IYSmgBM88QiB+3IWb1mRIC9/NNwcgbG0RwtFlg+EAFQHQ==} + /playwright/1.29.2: + resolution: {integrity: sha512-hKBYJUtdmYzcjdhYDkP9WGtORwwZBBKAW8+Lz7sr0ZMxtJr04ASXVzH5eBWtDkdb0c3LLFsehfPBTRfvlfKJOA==} engines: {node: '>=14'} hasBin: true requiresBuild: true dependencies: - playwright-core: 1.27.1 + playwright-core: 1.29.2 dev: true /qjobs/1.2.0: @@ -1349,7 +1417,7 @@ packages: resolution: {integrity: sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==} hasBin: true dependencies: - is-core-module: 2.10.0 + is-core-module: 2.11.0 path-parse: 1.0.7 supports-preserve-symlinks-flag: 1.0.0 dev: true @@ -1412,12 +1480,12 @@ packages: resolution: {integrity: sha512-8o/QEhSSRb1a5i7TFR0iM4G16Z0vYB2OQVs4G3aAFXjn3T6yEx8AZxy1PgDF7I00LZHYA3WxaSYIf5e5sAX8Rw==} dev: true - /shiki/0.11.1: - resolution: {integrity: sha512-EugY9VASFuDqOexOgXR18ZV+TbFrQHeCpEYaXamO+SZlsnT/2LxuLBX25GGtIrwaEVFXUAbUQ601SWE2rMwWHA==} + /shiki/0.12.1: + resolution: {integrity: sha512-aieaV1m349rZINEBkjxh2QbBvFFQOlgqYTNtCal82hHj4dDZ76oMlQIX+C7ryerBTDiga3e5NfH6smjdJ02BbQ==} dependencies: jsonc-parser: 3.2.0 - vscode-oniguruma: 1.6.2 - vscode-textmate: 6.0.0 + vscode-oniguruma: 1.7.0 + vscode-textmate: 8.0.0 dev: true /side-channel/1.0.4: @@ -1425,7 +1493,7 @@ packages: dependencies: call-bind: 1.0.2 get-intrinsic: 1.1.3 - object-inspect: 1.12.2 + object-inspect: 1.12.3 dev: true /socket.io-adapter/2.4.0: @@ -1442,14 +1510,14 @@ packages: - supports-color dev: true - /socket.io/4.5.3: - resolution: {integrity: sha512-zdpnnKU+H6mOp7nYRXH4GNv1ux6HL6+lHL8g7Ds7Lj8CkdK1jJK/dlwsKDculbyOHifcJ0Pr/yeXnZQ5GeFrcg==} + /socket.io/4.5.4: + resolution: {integrity: sha512-m3GC94iK9MfIEeIBfbhJs5BqFibMtkRk8ZpKwG2QwxV0m/eEhPIV4ara6XCF1LWNAus7z58RodiZlAH71U3EhQ==} engines: {node: '>=10.0.0'} dependencies: accepts: 1.3.8 base64id: 2.0.0 debug: 4.3.4 - engine.io: 6.2.0 + engine.io: 6.2.1 socket.io-adapter: 2.4.0 socket.io-parser: 4.2.1 transitivePeerDependencies: @@ -1495,8 +1563,8 @@ packages: engines: {node: '>= 0.8'} dev: true - /streamroller/3.1.3: - resolution: {integrity: sha512-CphIJyFx2SALGHeINanjFRKQ4l7x2c+rXYJ4BMq0gd+ZK0gi4VT8b+eHe2wi58x4UayBAKx4xtHpXT/ea1cz8w==} + /streamroller/3.1.4: + resolution: {integrity: sha512-Ha1Ccw2/N5C/IF8Do6zgNe8F3jQo8MPBnMBGvX0QjNv/I97BcNRzK6/mzOpZHHK7DjMLTI3c7Xw7Y1KvdChkvw==} engines: {node: '>=8.0'} dependencies: date-format: 4.0.14 @@ -1515,29 +1583,29 @@ packages: strip-ansi: 6.0.1 dev: true - /string.prototype.padend/3.1.3: - resolution: {integrity: sha512-jNIIeokznm8SD/TZISQsZKYu7RJyheFNt84DUPrh482GC8RVp2MKqm2O5oBRdGxbDQoXrhhWtPIWQOiy20svUg==} + /string.prototype.padend/3.1.4: + resolution: {integrity: sha512-67otBXoksdjsnXXRUq+KMVTdlVRZ2af422Y0aTyTjVaoQkGr3mxl2Bc5emi7dOQ3OGVVQQskmLEWwFXwommpNw==} engines: {node: '>= 0.4'} dependencies: call-bind: 1.0.2 define-properties: 1.1.4 - es-abstract: 1.20.4 + es-abstract: 1.21.1 dev: true - /string.prototype.trimend/1.0.5: - resolution: {integrity: sha512-I7RGvmjV4pJ7O3kdf+LXFpVfdNOxtCW/2C8f6jNiW4+PQchwxkCDzlk1/7p+Wl4bqFIZeF47qAHXLuHHWKAxog==} + /string.prototype.trimend/1.0.6: + resolution: {integrity: sha512-JySq+4mrPf9EsDBEDYMOb/lM7XQLulwg5R/m1r0PXEFqrV0qHvl58sdTilSXtKOflCsK2E8jxf+GKC0T07RWwQ==} dependencies: call-bind: 1.0.2 define-properties: 1.1.4 - es-abstract: 1.20.4 + es-abstract: 1.21.1 dev: true - /string.prototype.trimstart/1.0.5: - resolution: {integrity: sha512-THx16TJCGlsN0o6dl2o6ncWUsdgnLRSA23rRE5pyGBw/mLr3Ej/R2LaqCtgP8VNMGZsvMWnf9ooZPyY2bHvUFg==} + /string.prototype.trimstart/1.0.6: + resolution: {integrity: sha512-omqjMDaY92pbn5HOX7f9IccLA+U1tA9GvtU4JrodiXFfYB7jPzzHpRzpglLAjtUV6bB557zwClJezTqnAiYnQA==} dependencies: call-bind: 1.0.2 define-properties: 1.1.4 - es-abstract: 1.20.4 + es-abstract: 1.21.1 dev: true /strip-ansi/6.0.1: @@ -1615,22 +1683,30 @@ packages: mime-types: 2.1.35 dev: true - /typedoc/0.23.17_typescript@4.8.4: - resolution: {integrity: sha512-3rtNubo1dK0pvs6ixpMAq4pESULd5/JNUqJbdyZoeilI14reb1RNVomN4fMgIadd0RMX1aenYjJSSMBOJ+/+0Q==} + /typed-array-length/1.0.4: + resolution: {integrity: sha512-KjZypGq+I/H7HI5HlOoGHkWUUGq+Q0TPhQurLbyrVrvnKTBgzLhIJ7j6J/XTQOi0d1RjyZ0wdas8bKs2p0x3Ng==} + dependencies: + call-bind: 1.0.2 + for-each: 0.3.3 + is-typed-array: 1.1.10 + dev: true + + /typedoc/0.23.24_typescript@4.9.4: + resolution: {integrity: sha512-bfmy8lNQh+WrPYcJbtjQ6JEEsVl/ce1ZIXyXhyW+a1vFrjO39t6J8sL/d6FfAGrJTc7McCXgk9AanYBSNvLdIA==} engines: {node: '>= 14.14'} hasBin: true peerDependencies: - typescript: 4.6.x || 4.7.x || 4.8.x + typescript: 4.6.x || 4.7.x || 4.8.x || 4.9.x dependencies: lunr: 2.3.9 - marked: 4.1.1 - minimatch: 5.1.0 - shiki: 0.11.1 - typescript: 4.8.4 + marked: 4.2.5 + minimatch: 5.1.2 + shiki: 0.12.1 + typescript: 4.9.4 dev: true - /typescript/4.8.4: - resolution: {integrity: sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==} + /typescript/4.9.4: + resolution: {integrity: sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==} engines: {node: '>=4.2.0'} hasBin: true dev: true @@ -1659,7 +1735,7 @@ packages: dev: true /utils-merge/1.0.1: - resolution: {integrity: sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=} + resolution: {integrity: sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==} engines: {node: '>= 0.4.0'} dev: true @@ -1680,12 +1756,12 @@ packages: engines: {node: '>=0.10.0'} dev: true - /vscode-oniguruma/1.6.2: - resolution: {integrity: sha512-KH8+KKov5eS/9WhofZR8M8dMHWN2gTxjMsG4jd04YhpbPR91fUj7rYQ2/XjeHCJWbg7X++ApRIU9NUwM2vTvLA==} + /vscode-oniguruma/1.7.0: + resolution: {integrity: sha512-L9WMGRfrjOhgHSdOYgCt/yRMsXzLDJSL7BPrOZt73gU0iWO4mpqzqQzOz5srxqTvMBaR0XZTSrVWo4j55Rc6cA==} dev: true - /vscode-textmate/6.0.0: - resolution: {integrity: sha512-gu73tuZfJgu+mvCSy4UZwd2JXykjK9zAZsfmDeut5dx/1a7FeTk0XwJsSuqQn+cuMCGVbIBfl+s53X4T19DnzQ==} + /vscode-textmate/8.0.0: + resolution: {integrity: sha512-AFbieoL7a5LMqcnOF04ji+rpXadgOXnZsxQr//r83kLPr7biP7am3g9zbaZIaBGwBRWeSvoMD4mgPdX3e4NWBg==} dev: true /which-boxed-primitive/1.0.2: @@ -1698,6 +1774,18 @@ packages: is-symbol: 1.0.4 dev: true + /which-typed-array/1.1.9: + resolution: {integrity: sha512-w9c4xkx6mPidwp7180ckYWfMmvxpjlZuIudNtDf4N/tTAUB8VJbX25qZoAsrtGuYNnGw3pa0AXgbGKRB8/EceA==} + engines: {node: '>= 0.4'} + dependencies: + available-typed-arrays: 1.0.5 + call-bind: 1.0.2 + for-each: 0.3.3 + gopd: 1.0.1 + has-tostringtag: 1.0.0 + is-typed-array: 1.1.10 + dev: true + /which/1.3.1: resolution: {integrity: sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==} hasBin: true diff --git a/src/crypto/aes.ts b/src/crypto/aes.ts index ffb452a..f9d8fec 100644 --- a/src/crypto/aes.ts +++ b/src/crypto/aes.ts @@ -29,7 +29,8 @@ export enum Modes { export class AES { static Modes = Modes - private static delimiter = '--' // delimiter with a character that is not allowed in base64 or hex + // delimiter with a character that is not allowed in base64 or hex + private static delimiter = '--' private static delimiterEasy = '---' private static InvalidCiphertext = new Error('Invalid ciphertext') @@ -141,4 +142,18 @@ export class AES { const decrypted = await this.decrypt(data, keyDerived) return Bytes.decode(decrypted) } + + static async generateKey(): Promise { + const c = await getCrypto() + const key = await c.subtle.generateKey( + { + name: 'AES-GCM', + length: 256, + }, + true, + ['encrypt', 'decrypt'] + ) + const buffer = await c.subtle.exportKey('raw', key) + return new Uint8Array(buffer) + } } diff --git a/src/index.ts b/src/index.ts index 3181fb7..e156607 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,4 +3,4 @@ export * from './crypto/encoding.js' export * from './crypto/hash.js' export * from './crypto/random.js' export * from './crypto/rsa.js' -export * from './utils/base.js' +export { TypedArray } from './utils/base.js' diff --git a/test/aes.spec.js b/test/aes.spec.js index 733565a..45baebf 100644 --- a/test/aes.spec.js +++ b/test/aes.spec.js @@ -2,11 +2,11 @@ import { AES, Bytes, Hashes, Hex } from '../dist/index.js' import { Precomputed } from './values.js' describe('AES', () => { - for (const keySize of [128, 192, 256]) { - describe('Key Size: ' + keySize, () => { - for (const message of Object.values(Precomputed.Crypto.Messages)) { - describe(`Message: ${message.slice(0, 8)}...`, () => { - it('Basic API', async () => { + for (const message of Object.values(Precomputed.Crypto.Messages)) { + describe(`Message: ${message.slice(0, 8)}...`, () => { + describe('Basic API', () => { + for (const keySize of [128, 256]) { + it('Key Size: ' + keySize, async () => { const data = Bytes.encode(message) const [key] = await AES.derive('foo', { name: 'PBKDF2', @@ -20,15 +20,24 @@ describe('AES', () => { chai.expect(data).to.be.deep.equal(plaintext) chai.expect(message).to.be.equal(Bytes.decode(plaintext)) }) + } + }) - it('Easy API', async () => { - const password = 'foobar' - const encrypted = await AES.encryptEasy(message, password) - const decrypted = await AES.decryptEasy(encrypted, password) - chai.expect(message).to.be.equal(decrypted) - }) - }) - } + it('Generated Key', async () => { + const key = await AES.generateKey() + const data = Bytes.encode(message) + const ciphertext = await AES.encrypt(data, key) + const plaintext = await AES.decrypt(ciphertext, key) + chai.expect(data).to.be.deep.equal(plaintext) + chai.expect(message).to.be.equal(Bytes.decode(plaintext)) + }) + + it('Easy API', async () => { + const password = 'foobar' + const encrypted = await AES.encryptEasy(message, password) + const decrypted = await AES.decryptEasy(encrypted, password) + chai.expect(message).to.be.equal(decrypted) + }) }) } }) diff --git a/test/values.js b/test/values.js index 3221963..0327abc 100644 --- a/test/values.js +++ b/test/values.js @@ -11,8 +11,11 @@ export const Precomputed = { 'hello world': '68656c6c6f20776f726c64', }, Bytes: { - test: [0x74, 0x65, 0x73, 0x74], - occulto: [0x6f, 0x63, 0x63, 0x75, 0x6c, 0x74, 0x6f], + test: new Uint8Array([0x74, 0x65, 0x73, 0x74]), + occulto: new Uint8Array([0x6f, 0x63, 0x63, 0x75, 0x6c, 0x74, 0x6f]), + 'entropy is king': new Uint8Array([ + 0x65, 0x6e, 0x74, 0x72, 0x6f, 0x70, 0x79, 0x20, 0x69, 0x73, 0x20, 0x6b, 0x69, 0x6e, 0x67, + ]), }, }, Hash: {