diff --git a/README.md b/README.md index 252a1b48..b5642385 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ User Interface widgets and utilities for Solid (solid-ui) These are HTML5 widgets which connect to a solid store. Building blocks for solid-based apps. -Vanilla JS. Includes large widgets like chat, table, matrix, form fields, and small widgets. +Vanilla JS. Includes large widgets like chat, table, matrix, form fields, and small widgets. See [Solid-Ui Storybook](http://solidos.github.io/solid-ui/examples/storybook/) for UI widgets. See [Solid-UI API](https://solidos.github.io/solid-ui/docs/api/) for UI functions. diff --git a/jest.config.mjs b/jest.config.mjs index 888cfb14..d1e7afbb 100644 --- a/jest.config.mjs +++ b/jest.config.mjs @@ -11,7 +11,7 @@ export default { '^.+\\.[tj]sx?$': ['babel-jest', { configFile: './babel.config.mjs' }], }, transformIgnorePatterns: [ - '/node_modules/(?!(lit-html|@exodus/bytes|uuid|jsdom|parse5)/)', + '/node_modules/(?!(lit-html|@noble/curves|@noble/hashes|@exodus/bytes|uuid|jsdom|parse5)/)', ], setupFilesAfterEnv: ['./test/helpers/setup.ts'], testMatch: ['**/?(*.)+(spec|test).[tj]s?(x)'], diff --git a/package-lock.json b/package-lock.json index b3b368ea..113ad99a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,8 +9,8 @@ "version": "3.0.1", "license": "MIT", "dependencies": { - "@noble/curves": "^1.9.6", - "@noble/hashes": "^1.8.0", + "@noble/curves": "^2.0.1", + "@noble/hashes": "^2.0.1", "escape-html": "^1.0.3", "mime-types": "^3.0.2", "pane-registry": "^3.0.0", @@ -3841,27 +3841,27 @@ "optional": true }, "node_modules/@noble/curves": { - "version": "1.9.7", - "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.9.7.tgz", - "integrity": "sha512-gbKGcRUYIjA3/zCCNaWDciTMFI0dCkvou3TL8Zmy5Nc7sJ47a0jtOeZoTaMxkuqRo9cRhjOdZJXegxYE5FN/xw==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-2.0.1.tgz", + "integrity": "sha512-vs1Az2OOTBiP4q0pwjW5aF0xp9n4MxVrmkFBxc6EKZc6ddYx5gaZiAsZoq0uRRXWbi3AT/sBqn05eRPtn1JCPw==", "license": "MIT", "dependencies": { - "@noble/hashes": "1.8.0" + "@noble/hashes": "2.0.1" }, "engines": { - "node": "^14.21.3 || >=16" + "node": ">= 20.19.0" }, "funding": { "url": "https://paulmillr.com/funding/" } }, "node_modules/@noble/hashes": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", - "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-2.0.1.tgz", + "integrity": "sha512-XlOlEbQcE9fmuXxrVTXCTlG2nlRXa9Rj3rr5Ue/+tX+nmkgbX720YHh0VR3hBF9xDvwnb8D2shVGOwNx+ulArw==", "license": "MIT", "engines": { - "node": "^14.21.3 || >=16" + "node": ">= 20.19.0" }, "funding": { "url": "https://paulmillr.com/funding/" diff --git a/package.json b/package.json index 60f8e9c3..5f7aca09 100644 --- a/package.json +++ b/package.json @@ -65,8 +65,8 @@ }, "homepage": "https://github.com/solidos/solid-ui", "dependencies": { - "@noble/curves": "^1.9.6", - "@noble/hashes": "^1.8.0", + "@noble/curves": "^2.0.1", + "@noble/hashes": "^2.0.1", "escape-html": "^1.0.3", "mime-types": "^3.0.2", "pane-registry": "^3.0.0", diff --git a/src/chat/keys.ts b/src/chat/keys.ts index fad766f5..283e331e 100644 --- a/src/chat/keys.ts +++ b/src/chat/keys.ts @@ -1,6 +1,6 @@ import * as debug from '../debug' -import { schnorr } from '@noble/curves/secp256k1' -import { bytesToHex } from '@noble/hashes/utils' +import { schnorr } from '@noble/curves/secp256k1.js' +import { bytesToHex, hexToBytes } from '@noble/hashes/utils.js' import ns from '../ns' import { store } from 'solid-logic' import { NamedNode } from 'rdflib' @@ -9,11 +9,11 @@ import { getExistingPublicKey, pubKeyUrl, privKeyUrl, getExistingPrivateKey } fr import { setAcl, keyContainerAclBody, keyAclBody } from '../utils/keyHelpers/acl' export function generatePrivateKey (): string { - return bytesToHex(schnorr.utils.randomPrivateKey()) + return bytesToHex(schnorr.utils.randomSecretKey()) } export function generatePublicKey (privateKey: string): string { - return bytesToHex(schnorr.getPublicKey(privateKey)) + return bytesToHex(schnorr.getPublicKey(hexToBytes(privateKey))) } /** diff --git a/src/chat/signature.ts b/src/chat/signature.ts index 1e1c66b3..1b74a6a8 100644 --- a/src/chat/signature.ts +++ b/src/chat/signature.ts @@ -1,6 +1,6 @@ -import { schnorr } from '@noble/curves/secp256k1' -import { bytesToHex } from '@noble/hashes/utils' -import { sha256 } from '@noble/hashes/sha256' +import { schnorr } from '@noble/curves/secp256k1.js' +import { bytesToHex, hexToBytes } from '@noble/hashes/utils.js' +import { sha256 } from '@noble/hashes/sha2.js' // import {utf8Encoder} from './utils' // import { getPublicKey } from './keys' @@ -110,14 +110,14 @@ export function getMsgHash (message: UnsignedMsg) { export function verifySignature (sig: string, message: Message, pubKey: string): boolean { return schnorr.verify( - sig, - getMsgHash(message), - pubKey + hexToBytes(sig), + hexToBytes(getMsgHash(message)), + hexToBytes(pubKey) ) } export function signMsg (message: UnsignedMsg, key: string): string { return bytesToHex( - schnorr.sign(getMsgHash(message), key) + schnorr.sign(hexToBytes(getMsgHash(message)), hexToBytes(key)) ) }