From a787653db600440b5db565bdfed7acc9be6e4511 Mon Sep 17 00:00:00 2001 From: Timo Glastra Date: Sun, 25 Aug 2024 13:11:52 +0200 Subject: [PATCH] chore: some improvements (#9) Signed-off-by: Timo Glastra --- .eslintrc.js | 5 -- .github/workflows/ci.yaml | 6 ++ .release-it.json | 1 + biome.json | 35 ++++++++++ example/App.tsx | 104 ++++++++++++++--------------- example/app.json | 5 +- example/babel.config.js | 8 +-- example/index.js | 6 +- example/metro.config.js | 20 +++--- example/package.json | 4 +- example/pnpm-lock.yaml | 6 -- example/tsconfig.json | 3 +- ios/SecureEnvironment.swift | 19 +++--- package.json | 16 ++--- pnpm-lock.yaml | 94 ++++++++++++++++++++++++++ src/ExpoSecureEnvironmentModule.ts | 4 +- src/index.ts | 66 ++++++++---------- 17 files changed, 258 insertions(+), 144 deletions(-) delete mode 100644 .eslintrc.js create mode 100644 biome.json diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 45cf2c1..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - root: true, - extends: ['universe/native', 'universe/web'], - ignorePatterns: ['build'], -}; diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5e6a32b..80e1549 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -35,9 +35,15 @@ jobs: - name: Install dependencies run: pnpm install + - name: Style + run: pnpm style:check + - name: Build run: pnpm build + - name: Check types + run: pnpm types:check + continuous-deployment: if: github.event_name == 'workflow_dispatch' diff --git a/.release-it.json b/.release-it.json index da9bcc6..de3f599 100644 --- a/.release-it.json +++ b/.release-it.json @@ -4,6 +4,7 @@ }, "npm": { "skipChecks": true, + "ignoreVersion": true, "tag": "latest" }, "git": { diff --git a/biome.json b/biome.json new file mode 100644 index 0000000..27e72e9 --- /dev/null +++ b/biome.json @@ -0,0 +1,35 @@ +{ + "$schema": "https://biomejs.dev/schemas/1.8.1/schema.json", + "formatter": { + "lineWidth": 120, + "indentStyle": "space" + }, + "javascript": { + "parser": { + "unsafeParameterDecoratorsEnabled": true + }, + "formatter": { + "semicolons": "asNeeded", + "quoteStyle": "single", + "trailingCommas": "es5", + "lineWidth": 120, + "indentStyle": "space" + } + }, + "json": { + "parser": { + "allowComments": true + } + }, + "organizeImports": { + "enabled": true + }, + "linter": { + "enabled": true + }, + "vcs": { + "useIgnoreFile": true, + "clientKind": "git", + "enabled": true + } +} diff --git a/example/App.tsx b/example/App.tsx index 5fca13c..d241eee 100644 --- a/example/App.tsx +++ b/example/App.tsx @@ -1,74 +1,70 @@ -import { - ariesAskar, - KeyAlgs, - LocalKeyHandle, -} from "@hyperledger/aries-askar-react-native"; -import { - sign, - generateKeypair, - getPublicBytesForKeyId, -} from "expo-secure-environment"; -import { Button } from "react-native"; -import { StyleSheet, View } from "react-native"; +import { generateKeypair, getPublicBytesForKeyId, sign } from '@animo-id/expo-secure-environment' +import { KeyAlgs, LocalKeyHandle, ariesAskar } from '@hyperledger/aries-askar-react-native' +import { Button } from 'react-native' +import { StyleSheet, View } from 'react-native' export default function App() { const testBiometrics = async () => { - try{ - const id = new Date().toString(); - generateKeypair(id, true); - const publicKey = getPublicBytesForKeyId(id); - const key = ariesAskar.keyFromPublicBytes({ - algorithm: KeyAlgs.EcSecp256r1, - publicKey, - }); - const kHandle = new LocalKeyHandle(key.handle); - const message = new Uint8Array(10).fill(10); - const signature = await sign(id, new Uint8Array(message), true); - const isValid = ariesAskar.keyVerifySignature({ - message, - signature, - localKeyHandle: kHandle, - }); + try { + const id = new Date().toString() + generateKeypair(id, true) + const publicKey = getPublicBytesForKeyId(id) + const key = ariesAskar.keyFromPublicBytes({ + algorithm: KeyAlgs.EcSecp256r1, + publicKey, + }) + const kHandle = new LocalKeyHandle(key.handle) + const message = new Uint8Array(10).fill(10) + const signature = await sign(id, new Uint8Array(message), true) + const isValid = ariesAskar.keyVerifySignature({ + message, + signature, + localKeyHandle: kHandle, + }) - console.log(isValid); - }catch(e) { - console.error('ERRRRRR', e) + console.log('Signing with biometrics enabled isValid: ', isValid) + } catch (e) { + console.error('Error signing with biometrics enabled', e) } - }; + } const testNoBiometrics = async () => { - const id = new Date().toString(); - generateKeypair(id, false); - const publicKey = getPublicBytesForKeyId(id); - const key = ariesAskar.keyFromPublicBytes({ - algorithm: KeyAlgs.EcSecp256r1, - publicKey, - }); - const kHandle = new LocalKeyHandle(key.handle); - const message = new Uint8Array(10).fill(10); - const signature = await sign(id, new Uint8Array(message), false); - const isValid = ariesAskar.keyVerifySignature({ - message, - signature, - localKeyHandle: kHandle, - }); + try { + const id = new Date().toString() + generateKeypair(id, false) + const publicKey = getPublicBytesForKeyId(id) + const key = ariesAskar.keyFromPublicBytes({ + algorithm: KeyAlgs.EcSecp256r1, + publicKey, + }) + const kHandle = new LocalKeyHandle(key.handle) + const message = new Uint8Array(10).fill(10) + const signature = await sign(id, new Uint8Array(message), false) + const isValid = ariesAskar.keyVerifySignature({ + message, + signature, + localKeyHandle: kHandle, + }) - console.log(isValid); - }; + console.log('Signing with biometrics disabled isValid: ', isValid) + } catch (e) { + console.error('Error signing with biometrics disabled', e) + } + } return (