Compare commits
98 Commits
Author | SHA1 | Date | |
---|---|---|---|
34f5ce38ed | |||
ce19d0e50d | |||
dd47c28d18 | |||
a3698e7dec | |||
13044d6b39 | |||
b1d86b3c33 | |||
|
dd2aa3dc40 | ||
ec9c4dad5d | |||
|
493390bdc1 | ||
|
4f5dcc0336 | ||
|
afdc9449b1 | ||
|
c1a9475a89 | ||
|
745ba377d4 | ||
|
8de86aac28 | ||
|
c8f0d135f1 | ||
|
cc681af11a | ||
|
8e23a2d8a1 | ||
|
cc65d85806 | ||
c399dbf56c | |||
|
1d6131bf82 | ||
093416a481 | |||
|
bb9febe25d | ||
826be97b8b | |||
e95fabd4ae | |||
|
4b5625e5bd | ||
|
08b13c291b | ||
|
f422ee338c | ||
|
9f4a891d50 | ||
|
13b88516ca | ||
|
f7d0718b78 | ||
|
6f4b41d84b | ||
|
1474fafde7 | ||
|
e405b735f7 | ||
|
25780a6789 | ||
|
6c1c97a598 | ||
a82cab36ef | |||
0834e52316 | |||
![]() |
673516e3ce | ||
|
f05b9477f6 | ||
8d66573a5e | |||
ee3381d376 | |||
![]() |
889bc0e4fc | ||
|
8da99c0ed6 | ||
896c18fff0 | |||
02063e1ea5 | |||
![]() |
aa32dae622 | ||
|
233dbdf7db | ||
02120d6b4c | |||
1c35512ddf | |||
![]() |
031deef6ca | ||
b828e75858 | |||
870ac9bb30 | |||
![]() |
57c1002c2a | ||
|
47fcdea385 | ||
|
37baf57093 | ||
|
eb2aa98860 | ||
89dc4c01aa | |||
ae7e09c4ca | |||
e80c4024f8 | |||
|
37fe28c070 | ||
05051e49fa | |||
8582f70652 | |||
![]() |
354312bd96 | ||
d72250b6dc | |||
b18e891341 | |||
461d43e2e1 | |||
35e7ac4086 | |||
|
5db4d1b429 | ||
af036b1bb7 | |||
c0b903929d | |||
|
efe3c2c9c7 | ||
|
4b5955fa9c | ||
|
664ed9de06 | ||
|
1e643c60e5 | ||
15000a2d14 | |||
b97afdecfd | |||
feea3197d0 | |||
c45e3912a2 | |||
f72fa1a886 | |||
|
a4310675c1 | ||
|
5f3d92d62f | ||
|
04f1d692a4 | ||
|
99d562a3ed | ||
|
e60c4cbc31 | ||
|
3f01ab8fca | ||
|
b7410c7d33 | ||
|
b6a84dedbe | ||
|
8b5abe02e2 | ||
|
7b2537e355 | ||
|
bcd57138ca | ||
|
5079b68bdf | ||
b361ab3d99 | |||
|
dbcc96aca2 | ||
|
9a1d3d98bf | ||
5ed3d2f389 | |||
b04f4fb88d | |||
3b4bf9aa29 | |||
e85e9519d2 |
.gitea/workflows
.gitignore.releasercCHANGELOG.mdindex.htmlpackage-lock.jsonpackage.jsonpublic
app.webmanifestfavicon-128x128.pngfavicon-144x144.pngfavicon-192x192.pngfavicon-256x256.pngfavicon-384x384.pngfavicon-512x512.pngfavicon-64x64.pngfavicon-72x72.pngfavicon-96x96.pngfavicon.svg
src
App.tsx
vite.config.tscomponents
AppBar
ButtonUnderline
DisplaySigit
DrawPDFFields
FileList
MarkFormField
MarkTypeStrategy
PDFView
hooks
layouts
pages
routes
services
types
utils
@ -15,20 +15,47 @@ jobs:
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 18
|
||||
node-version: 20
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm ci
|
||||
run: |
|
||||
npm ci
|
||||
apt-get update
|
||||
apt-get install zip -y
|
||||
apt-get install jq -y
|
||||
|
||||
- name: Create .env File
|
||||
run: echo "VITE_MOST_POPULAR_RELAYS=${{ vars.VITE_MOST_POPULAR_RELAYS }}" > .env
|
||||
|
||||
- name: Create Build
|
||||
run: npm run build
|
||||
run: |
|
||||
npm run build
|
||||
zip -r frontend.zip dist/*
|
||||
|
||||
- name: Release Build
|
||||
- name: Deploy Build
|
||||
run: |
|
||||
npm -g install cloudron-surfer
|
||||
surfer config --token ${{ secrets.CLOUDRON_SURFER_TOKEN }} --server sigit.io
|
||||
surfer config --token ${{ secrets.CLOUDRON_SURFER_TOKEN }} --server sigit.io
|
||||
surfer put dist/* / --all -d
|
||||
surfer put dist/.well-known / --all
|
||||
surfer put dist/.well-known / --all
|
||||
|
||||
- name: Create Empty Release (assets are posted later)
|
||||
run: |
|
||||
npm i
|
||||
npm i -g semantic-release
|
||||
echo "do a semantic-release DRY RUN to make the job fail if there are no changes to release"
|
||||
GITEA_TOKEN=${{ secrets.RELEASE_TOKEN }} GITEA_URL=https://git.nostrdev.com/sigit/sigit.io semantic-release --dry-run | grep -q "There are no relevant changes, so no new version is released." && exit 1
|
||||
echo "now do the actual release"
|
||||
GITEA_TOKEN=${{ secrets.RELEASE_TOKEN }} GITEA_URL=https://git.nostrdev.com/sigit/sigit.io semantic-release
|
||||
|
||||
- name: Upload assets to release
|
||||
run: |
|
||||
echo "fetching release id"
|
||||
RELEASE_ID=`curl -k 'https://git.nostrdev.com/api/v1/repos/sigit/sigit.io/releases/latest?access_token=${{ secrets.RELEASE_TOKEN }}' | jq -r '.id'`
|
||||
echo "fetching release body"
|
||||
RELEASE_BODY=`curl -k 'https://git.nostrdev.com/api/v1/repos/sigit/sigit.io/releases/latest?access_token=${{ secrets.RELEASE_TOKEN }}' | jq -r '.body'`
|
||||
echo "Updating release body"
|
||||
curl --data '{"draft": false,"body":"'"$RELEASE_BODY\n\nFor installation instructions, please visit https://docs.sigit.io/#/"'"}' -X PATCH --header 'Content-Type: application/json' -k https://git.nostrdev.com/sigit/sigit.io/releases/$RELEASE_ID?access_token=${{ secrets.RELEASE_TOKEN }}
|
||||
echo "Uploading assets"
|
||||
URL="https://git.nostrdev.com/api/v1/repos/sigit/sigit.io/releases/$RELEASE_ID/assets?access_token=${{ secrets.RELEASE_TOKEN }}"
|
||||
curl -k $URL -F attachment=@frontend.zip
|
||||
|
@ -15,7 +15,7 @@ jobs:
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 18
|
||||
node-version: 20
|
||||
|
||||
- name: Audit
|
||||
run: npm audit --omit=dev
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -9,6 +9,7 @@ lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-zip
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
|
31
.releaserc
Normal file
31
.releaserc
Normal file
@ -0,0 +1,31 @@
|
||||
{
|
||||
"branches": [
|
||||
"main"
|
||||
],
|
||||
"plugins": [
|
||||
"@semantic-release/commit-analyzer",
|
||||
"@semantic-release/release-notes-generator",
|
||||
"@semantic-release/changelog",
|
||||
"@semantic-release/npm",
|
||||
[
|
||||
"@semantic-release/git",
|
||||
{
|
||||
"assets": [
|
||||
"CHANGELOG.md",
|
||||
"package.json"
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
"@saithodev/semantic-release-gitea",
|
||||
{
|
||||
"giteaUrl": "https://git.nostrdev.com/",
|
||||
"assets": [
|
||||
{
|
||||
"path": "dist-zip/dist.zip"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
435
CHANGELOG.md
Normal file
435
CHANGELOG.md
Normal file
@ -0,0 +1,435 @@
|
||||
## [1.0.4](https://git.nostrdev.com/sigit/sigit.io/compare/v1.0.3...v1.0.4) (2025-01-31)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- adding jq package ([673516e](https://git.nostrdev.com/sigit/sigit.io/commit/673516e3ce26a4006c112cd19d5987e181a4b10d))
|
||||
|
||||
## [1.0.3](https://git.nostrdev.com/sigit/sigit.io/compare/v1.0.2...v1.0.3) (2025-01-31)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- bundling frontend with release ([889bc0e](https://git.nostrdev.com/sigit/sigit.io/commit/889bc0e4fcc21b79d6fc643317ae3423497e265e))
|
||||
|
||||
## [1.0.2](https://git.nostrdev.com/sigit/sigit.io/compare/v1.0.1...v1.0.2) (2025-01-31)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- adding api to release url ([aa32dae](https://git.nostrdev.com/sigit/sigit.io/commit/aa32dae62282be9c07ea6e4af514925585d97a2b))
|
||||
|
||||
## [1.0.1](https://git.nostrdev.com/sigit/sigit.io/compare/v1.0.0...v1.0.1) (2025-01-31)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- test to see if the automated release works ([031deef](https://git.nostrdev.com/sigit/sigit.io/commit/031deef6ca3b9794d3fadf67b67884137e6af9f2))
|
||||
|
||||
# 1.0.0 (2025-01-31)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- add default title for sigit ([ef5376e](https://git.nostrdev.com/sigit/sigit.io/commit/ef5376e2d1ec08a3327850a7035c03af2e16693d))
|
||||
- add default typography styles ([2cd851a](https://git.nostrdev.com/sigit/sigit.io/commit/2cd851a7c153c051b55365481a4e9ea6938e8be3))
|
||||
- add file and page index, hide select if not active ([5f92906](https://git.nostrdev.com/sigit/sigit.io/commit/5f92906032ab0ea6a09ae9d104a64f81fd10c095))
|
||||
- add files and marked to sign page exports ([9dd190d](https://git.nostrdev.com/sigit/sigit.io/commit/9dd190d65b18429ded79213bdfdf91a88aac0062))
|
||||
- add keys and show name for counterparts ([8267eb6](https://git.nostrdev.com/sigit/sigit.io/commit/8267eb624b76b0efc62a917da962a9865affad38))
|
||||
- add mark label ([c3dacbe](https://git.nostrdev.com/sigit/sigit.io/commit/c3dacbe1114cdcc408a4dde3019a31c1570afa3e))
|
||||
- add missing null and reduce warning limit ([bec3c92](https://git.nostrdev.com/sigit/sigit.io/commit/bec3c92b03c4127c9f768770640f6c41d0c329be))
|
||||
- add parantheses, invoke unixNow ([07d25eb](https://git.nostrdev.com/sigit/sigit.io/commit/07d25ebbd2e125e5a51ddcb27696a3de3d58f0f9))
|
||||
- add Roboto font ([6a1f04e](https://git.nostrdev.com/sigit/sigit.io/commit/6a1f04ec6b11f7a054ef9ce43283961ff40c6e78))
|
||||
- add show username ([62c1f1b](https://git.nostrdev.com/sigit/sigit.io/commit/62c1f1b37ba9dc78a29d3f73617177a90c9b6eba))
|
||||
- add small avatar when select is not showing ([d8d51be](https://git.nostrdev.com/sigit/sigit.io/commit/d8d51be603a9817ffc449eb2ffd81382cba47ec8))
|
||||
- add timeout in publishing updated app data and sending notifications ([6b135ac](https://git.nostrdev.com/sigit/sigit.io/commit/6b135ac54dd9d8e4c9948be92edcfa907d419940))
|
||||
- add types to rootReducer, rename userRobotImage types ([70f6464](https://git.nostrdev.com/sigit/sigit.io/commit/70f646444b9ed39798737851edc9b401c759a3d2))
|
||||
- adding link to source and updating home page wording ([c3d5a10](https://git.nostrdev.com/sigit/sigit.io/commit/c3d5a1042c3d66e75b8cb537d5bfff8a99909a02))
|
||||
- addressing comments ([8d8c38e](https://git.nostrdev.com/sigit/sigit.io/commit/8d8c38e90bce13c3a0b833a5598a790c2086a267))
|
||||
- adds notifications ([f38344b](https://git.nostrdev.com/sigit/sigit.io/commit/f38344b9acbb538f617d76796f75139db626164f))
|
||||
- AGPL Licence, closes [#197](https://git.nostrdev.com/sigit/sigit.io/issues/197) ([55abe81](https://git.nostrdev.com/sigit/sigit.io/commit/55abe814c967e3e126d40408239f62ac111ba9e7))
|
||||
- amends RelayMap to return a default sigit relay when no other relays are found ([2355da0](https://git.nostrdev.com/sigit/sigit.io/commit/2355da02d2c760f94509bcb4e375e75b61a2ce9f))
|
||||
- amends the relay look up method to return default relay set ([52fe523](https://git.nostrdev.com/sigit/sigit.io/commit/52fe523196986d651c7fa14224e2b4324683a6f4))
|
||||
- app bar z-index ([87c6807](https://git.nostrdev.com/sigit/sigit.io/commit/87c6807ba08ef0217bed4744e6241d479bf74967))
|
||||
- arrayBuffer access ([b3fc3c6](https://git.nostrdev.com/sigit/sigit.io/commit/b3fc3c6715739b92e63e3a14013fb97dc81360f7))
|
||||
- background overlap ([202c98c](https://git.nostrdev.com/sigit/sigit.io/commit/202c98c94c3b0ae99d28055b002c6120e9845451))
|
||||
- bad margin value ([734026b](https://git.nostrdev.com/sigit/sigit.io/commit/734026b2eeba2c5109ebdf0d8b5ef77f7ca36249))
|
||||
- better UX when clicking on logo when on home screen or `home` button in footer ([834d70d](https://git.nostrdev.com/sigit/sigit.io/commit/834d70d7747148d08b3c19720aca8d56b3d0de68))
|
||||
- bug, when valid npub, clicking + was saying npub was invalid ([99fa3ad](https://git.nostrdev.com/sigit/sigit.io/commit/99fa3add562c4efa013954c0e0df95723b9aea3d))
|
||||
- build failing due to type issue ([652ea06](https://git.nostrdev.com/sigit/sigit.io/commit/652ea06c0de77af453f1c4aeee4d473fe265d93a))
|
||||
- button colour ([4c04c12](https://git.nostrdev.com/sigit/sigit.io/commit/4c04c1240344c0f07a503bb0a5f56e7bfc791c8f))
|
||||
- card icons ([0d49c49](https://git.nostrdev.com/sigit/sigit.io/commit/0d49c4945977826cf90f2002ca1e06880f646003))
|
||||
- center block scrolling on mark items ([aec0d0b](https://git.nostrdev.com/sigit/sigit.io/commit/aec0d0bdd8bf435003e96fa90d1e9966e1b0b3e0))
|
||||
- change sign to create ([f35f469](https://git.nostrdev.com/sigit/sigit.io/commit/f35f469547737aea8b50e29fb7813a69a482d85b))
|
||||
- **ci:** add license check in staging workflow ([4af5781](https://git.nostrdev.com/sigit/sigit.io/commit/4af578133c17bbb5f3c4f60873dd1ae37e679e18))
|
||||
- **ci:** fix hook colors ([ea7fde4](https://git.nostrdev.com/sigit/sigit.io/commit/ea7fde4b38234128920de116609ad05e367bf9dd))
|
||||
- **CI:** fixed secret ([3e360aa](https://git.nostrdev.com/sigit/sigit.io/commit/3e360aab1510dc07c8c67b712ea666a72bb28469))
|
||||
- **ci:** run lint-staged always, fix lint-stage commands ([d43067f](https://git.nostrdev.com/sigit/sigit.io/commit/d43067f70ebb5d52c08452402540406ca9ff4cfa))
|
||||
- clear hasSubscribed after the logout ([1d1986f](https://git.nostrdev.com/sigit/sigit.io/commit/1d1986f0829f4c1ca183b017150ecfdbaa96a86c))
|
||||
- clicking logo not redirecting to home ([69efd9e](https://git.nostrdev.com/sigit/sigit.io/commit/69efd9e09d043403c987a5ab7fddd68158a1d22a))
|
||||
- clicking on marked fileds is losing input text/squiggle, squiggle field is mobile friendly ([602e23c](https://git.nostrdev.com/sigit/sigit.io/commit/602e23c719a0d583b194d627761efff14fb9b074))
|
||||
- color scheme ([d7f9807](https://git.nostrdev.com/sigit/sigit.io/commit/d7f9807e20d0bb4d85ab8794173e3bd71adb4ca4))
|
||||
- **column-layout:** wrap content column to prevent expanding ([a8020e6](https://git.nostrdev.com/sigit/sigit.io/commit/a8020e6db2ad88f29e6cf2bb35cca1cace56cb07))
|
||||
- composition for links and buttons ([804bb6c](https://git.nostrdev.com/sigit/sigit.io/commit/804bb6c9acb7f4eedd547eba7516e91e4a218d86))
|
||||
- convert npub/nip05 to lowercase on adding as signer/viewer ([fff0fd7](https://git.nostrdev.com/sigit/sigit.io/commit/fff0fd762dc0b3ddde04657207d09c795cdaa341))
|
||||
- counterpart search NIP05 glitching ([0fd0f26](https://git.nostrdev.com/sigit/sigit.io/commit/0fd0f26fc7ef87aea7c48ccddae822d23d2b8853))
|
||||
- create page, improving message "preparing document for signing" ([98fbe80](https://git.nostrdev.com/sigit/sigit.io/commit/98fbe80648e6b8e80af1e6c15de8bb963d27c070))
|
||||
- **create-page:** file list ([1caeb48](https://git.nostrdev.com/sigit/sigit.io/commit/1caeb48e6c91e0c8fd052caa8df0a5299f3e5f03))
|
||||
- **create-page:** only show signers in counterpart select ([29e6c85](https://git.nostrdev.com/sigit/sigit.io/commit/29e6c851504f884cdeae738bb70323a7703f2f74))
|
||||
- **create-page:** show other file types in content ([b12ce25](https://git.nostrdev.com/sigit/sigit.io/commit/b12ce258eb83620aa0dae546f146d381b9d61093))
|
||||
- **create:** block if no signers ([15aaef9](https://git.nostrdev.com/sigit/sigit.io/commit/15aaef948d264ad76b27dfa80ff22051e0eb1021))
|
||||
- **create:** remove small drawn fields ([902ad73](https://git.nostrdev.com/sigit/sigit.io/commit/902ad73fafa184d8f36b03d3e4b839afa724bded)), closes [#234](https://git.nostrdev.com/sigit/sigit.io/issues/234)
|
||||
- **create:** throw on mark with no counterpart ([624afae](https://git.nostrdev.com/sigit/sigit.io/commit/624afae8514420a36034ef29814920579da308f6))
|
||||
- **create:** uploading file adds to the existing file list, dedupe file list ([6d78d9e](https://git.nostrdev.com/sigit/sigit.io/commit/6d78d9ed643296b6dfa6ab3ffd0ae5295a46243a)), closes [#184](https://git.nostrdev.com/sigit/sigit.io/issues/184)
|
||||
- **deps:** update axios ([115a397](https://git.nostrdev.com/sigit/sigit.io/commit/115a3974e278c137aa2d490327bcc92e4ed0c492))
|
||||
- disable login, register fields, add coming soon ([0a74ad9](https://git.nostrdev.com/sigit/sigit.io/commit/0a74ad97b2a54f36acb39f8f57bf646f595b7e37))
|
||||
- disables redundant metaInNavState updates ([7463384](https://git.nostrdev.com/sigit/sigit.io/commit/746338465d1c370b503be257a9d57e132e0d7192))
|
||||
- display `no results` when no submissions are found ([bbe34b6](https://git.nostrdev.com/sigit/sigit.io/commit/bbe34b60116af3081a45ec55dde6e6e7620818a3))
|
||||
- displays complete marks from other users ([4d4a5b6](https://git.nostrdev.com/sigit/sigit.io/commit/4d4a5b63cf466af15d2b2414a52adeda8bd7cb8a))
|
||||
- **DM:** removed direct download link ([0fab6b5](https://git.nostrdev.com/sigit/sigit.io/commit/0fab6b5cdc1420854abc81493b0a83e6993336c7))
|
||||
- **draw:** add resize cursor to resize handle ([0d1a7ba](https://git.nostrdev.com/sigit/sigit.io/commit/0d1a7ba17118996d91c57737cfac4b036d796e31))
|
||||
- **drawfield:** match label and select ([923a47b](https://git.nostrdev.com/sigit/sigit.io/commit/923a47b4d086563fc1f514b962cfdecb281d6b87))
|
||||
- **drawing:** clamp DrawField within img ([2f54184](https://git.nostrdev.com/sigit/sigit.io/commit/2f5418462584ac5426c717680590d9156801ec57)), closes [#154](https://git.nostrdev.com/sigit/sigit.io/issues/154)
|
||||
- enable verify button ([f4a837a](https://git.nostrdev.com/sigit/sigit.io/commit/f4a837ae098bf5b660499f0c005089d8f9f6b37a))
|
||||
- entering decryption key manually does not work because of encoded URI ([e498ecb](https://git.nostrdev.com/sigit/sigit.io/commit/e498ecb082ebc5c2022b225f7824a12932282d6e))
|
||||
- **errors:** add custom timeout error ([9c545a4](https://git.nostrdev.com/sigit/sigit.io/commit/9c545a477cf5e6e9ecf8f171af3857fd64b5a78d))
|
||||
- failed DM error handling ([608400d](https://git.nostrdev.com/sigit/sigit.io/commit/608400d010262d3e2dc59cd03508a608560b521b))
|
||||
- false positive case of navigator.online ([307f32b](https://git.nostrdev.com/sigit/sigit.io/commit/307f32bb7b15bf796a80ab464d4d6d844815c180))
|
||||
- fetch app data from after login ([fa7a6e8](https://git.nostrdev.com/sigit/sigit.io/commit/fa7a6e85f4f7df3adac8cfe884f0592dd6c11aca))
|
||||
- file path ([79f37a8](https://git.nostrdev.com/sigit/sigit.io/commit/79f37a842f919f052b08ca2afe341a296e55a18c))
|
||||
- **files:** show other file types in content for create, fix sign and verify error ([86095cb](https://git.nostrdev.com/sigit/sigit.io/commit/86095cba5c624943c837b6b997f9485411444b01))
|
||||
- first find metadata on purplepag relay and then try other relays ([6981bef](https://git.nostrdev.com/sigit/sigit.io/commit/6981bef65ad458db69874cfc782b4f85109f284b))
|
||||
- font url typo ([fcd00d9](https://git.nostrdev.com/sigit/sigit.io/commit/fcd00d9e9ce42ab7e3f8c4a9836db3d76adadb34))
|
||||
- fonts ([aa5aa60](https://git.nostrdev.com/sigit/sigit.io/commit/aa5aa60c6a749c8c4b37a9c2a7e0b15794653a73))
|
||||
- footer 'Home' button scroll to top when on home page, fixed logic ([afbe05b](https://git.nostrdev.com/sigit/sigit.io/commit/afbe05b4c88d5042c17f4a59c0739dc8942642a9))
|
||||
- footer buttons ([e280e87](https://git.nostrdev.com/sigit/sigit.io/commit/e280e873424d6e92839e64d274997e51c1c135ed))
|
||||
- footer padding and responsiveness ([45f0764](https://git.nostrdev.com/sigit/sigit.io/commit/45f0764fa802bccc75b320527f7a18708b7302f4))
|
||||
- footer portal on relays ([ebd5947](https://git.nostrdev.com/sigit/sigit.io/commit/ebd59471c79335555ddf43748b3dd3457b65eb42))
|
||||
- format fixed for iv in encryption key ([c4ef090](https://git.nostrdev.com/sigit/sigit.io/commit/c4ef090f3c7e1da126fb5f09d4918d1c25867c0c))
|
||||
- gap, spacing ([99856fd](https://git.nostrdev.com/sigit/sigit.io/commit/99856fd8f2255ae8d1a667c67b86cd48373a0fd5))
|
||||
- getRobohash function will do the conversion of pubkey ([9aa1066](https://git.nostrdev.com/sigit/sigit.io/commit/9aa10664a7e5b9af4bde3cb6f5cc55d0334eaa54))
|
||||
- **git-hooks:** add executable flag ([7b5a122](https://git.nostrdev.com/sigit/sigit.io/commit/7b5a12246d792672734747ca33ff77cfc05c0537))
|
||||
- handle navigation after create ([00db735](https://git.nostrdev.com/sigit/sigit.io/commit/00db735106767ccd3a934c9d4f9124b40ef2b7b3))
|
||||
- handle the case when zip entry is undefined ([e4675af](https://git.nostrdev.com/sigit/sigit.io/commit/e4675af4dd8267a88bed50bf3d3f1aa323d17987))
|
||||
- hanlde error in decryption of zip file ([660efb3](https://git.nostrdev.com/sigit/sigit.io/commit/660efb3b677130ecfe1248405acb40f16f5c4572))
|
||||
- home screen style fixed for mobile view ([6f8830a](https://git.nostrdev.com/sigit/sigit.io/commit/6f8830a77ccf40eed0c11ccc65ae5d736dfb981d))
|
||||
- **home-page:** sigit file type display now correctly shows multiple file types ([acc8c84](https://git.nostrdev.com/sigit/sigit.io/commit/acc8c84617a38443d301804f540f5d40b4a0d461))
|
||||
- **home:** focus outlines and decorations ([72d0e06](https://git.nostrdev.com/sigit/sigit.io/commit/72d0e065eae580611c5a9252c8521086495dd2c5))
|
||||
- homepage alpha warning ([867e1b8](https://git.nostrdev.com/sigit/sigit.io/commit/867e1b88c2bd60b1f7e3f566d940e4e48f9043c0))
|
||||
- IconButton conflict, username layout ([9dae3a4](https://git.nostrdev.com/sigit/sigit.io/commit/9dae3a48bef7f4d0d0ce273f6cf9ec78f47b1017))
|
||||
- icons, use FontAwesome package ([6f4737d](https://git.nostrdev.com/sigit/sigit.io/commit/6f4737d75cc15b0d72608775153c119d10265f0f))
|
||||
- If creator is not the first signer we should not redirect to /sign page ([ee3e0e1](https://git.nostrdev.com/sigit/sigit.io/commit/ee3e0e1bb1f338b912f0352acb61fdc7c1749e6e))
|
||||
- improve font support ([a63ea91](https://git.nostrdev.com/sigit/sigit.io/commit/a63ea913d9c87028e78b49d8ef0886173fea877a))
|
||||
- in pdf marking if counterpart does not have any of name, displayname, username then show pubkey ([42d74c6](https://git.nostrdev.com/sigit/sigit.io/commit/42d74c656a495a7600aa5e5232ea8ed1c231f524))
|
||||
- In sign page, when doc is fully signed, update search params with update file url and key ([05c3f49](https://git.nostrdev.com/sigit/sigit.io/commit/05c3f49a17bc78b6b57a59a9a6dc475ab57d5034))
|
||||
- include hidden folders in surfer upload ([970c5f5](https://git.nostrdev.com/sigit/sigit.io/commit/970c5f5e8bfc0129283fe14c7e6fa3c9a8a35ea4))
|
||||
- include purplepage and userkindpages relays when searching for user in create page ([8a9910d](https://git.nostrdev.com/sigit/sigit.io/commit/8a9910db87dcd27488ef1588a18e4480b16adde8))
|
||||
- including signatures in both export and encrypted export ([6716c3d](https://git.nostrdev.com/sigit/sigit.io/commit/6716c3da636f9c0a1b168cb2cb0a98da97a6c5c3))
|
||||
- increased timeout for extension user prompt ([2c2eeba](https://git.nostrdev.com/sigit/sigit.io/commit/2c2eeba83f2fb6cdf73228733448228151f1de0f))
|
||||
- inform user then search term provided no results ([24463a5](https://git.nostrdev.com/sigit/sigit.io/commit/24463a53c50f00313e3502438ae5f47254635253))
|
||||
- inlined svg background images ([c22b1e4](https://git.nostrdev.com/sigit/sigit.io/commit/c22b1e4b5a04943e61ae162911c28496da2b51fd))
|
||||
- input font-family inherit ([f21d158](https://git.nostrdev.com/sigit/sigit.io/commit/f21d158a8ec5fd204fd513f140cfa33b97cb5383))
|
||||
- label ([0163d51](https://git.nostrdev.com/sigit/sigit.io/commit/0163d51155ffff17b41d9e60871143b6be68e7d6))
|
||||
- landing page ([cc9fb50](https://git.nostrdev.com/sigit/sigit.io/commit/cc9fb50b079ff4f0d67ade1f30973f437f9e4ef6))
|
||||
- landing page wording ([4dd6b6d](https://git.nostrdev.com/sigit/sigit.io/commit/4dd6b6d7a449a0f41db995fb577c42124b234137))
|
||||
- last signer as default next ([39934f5](https://git.nostrdev.com/sigit/sigit.io/commit/39934f59c375d774f1fb4f7a97676304f5e9fd41))
|
||||
- leaky styling and warnings ([6f88f22](https://git.nostrdev.com/sigit/sigit.io/commit/6f88f22933ddd6bf787c69d0dcaf12032d5ea4f9)), closes [#147](https://git.nostrdev.com/sigit/sigit.io/issues/147)
|
||||
- **lint:** add deps, remove any, update warning limit ([61f39d1](https://git.nostrdev.com/sigit/sigit.io/commit/61f39d17ff4619c2b6beedf7d3189c03278aeede))
|
||||
- **lint:** update warning limit ([404f4aa](https://git.nostrdev.com/sigit/sigit.io/commit/404f4aa3a1e8db7ff90300b107496f59a28a539e))
|
||||
- list item key ([c7dfb28](https://git.nostrdev.com/sigit/sigit.io/commit/c7dfb2864acea7e20237b2f8da16f915f9544d43))
|
||||
- loading spinner states, timestamp the file, and lint fixes ([748cb16](https://git.nostrdev.com/sigit/sigit.io/commit/748cb16f9fe44f8fc06ac6142cdd01c348bc7c1c))
|
||||
- loading spinner, improve desc readability, use favicon instead of circle ([5a4da18](https://git.nostrdev.com/sigit/sigit.io/commit/5a4da1834b8628199d8577afda957fa359040b63))
|
||||
- **loading:** make sure the default spinner is absolute relative to root always ([4bc5882](https://git.nostrdev.com/sigit/sigit.io/commit/4bc5882ab60cd4b31f532d506433d24c67548082))
|
||||
- login with hex key does not work, missing proper error when nsec or private key is wrong ([213ae79](https://git.nostrdev.com/sigit/sigit.io/commit/213ae79bf52da893dccc4576dd690cddbb0e4bd8))
|
||||
- **login:** extension login infinite loading ([7c80643](https://git.nostrdev.com/sigit/sigit.io/commit/7c80643aba266fc0279c593f1951931f3fbb9ce2)), closes [#196](https://git.nostrdev.com/sigit/sigit.io/issues/196)
|
||||
- **Login:** fixed loginWithExtension func ([be4e7ab](https://git.nostrdev.com/sigit/sigit.io/commit/be4e7ab2bda98927be90c0150afc37e575fb1a8e))
|
||||
- **login:** redirect to landing instead of login popup page ([84062f2](https://git.nostrdev.com/sigit/sigit.io/commit/84062f2ed0e9953c5c3830d792a60577ddb3ebe4))
|
||||
- **login:** update login method before using nostrController instance ([1f98020](https://git.nostrdev.com/sigit/sigit.io/commit/1f980201dde2cf9b4e4ec8a0470e49944f797c5d))
|
||||
- **login:** use const and make sure to clear timeout always ([17c1700](https://git.nostrdev.com/sigit/sigit.io/commit/17c170055488ba793658a32745c10bf8f2c32981))
|
||||
- logout user if decryption fails due to diff pubkeys ([c96a7fa](https://git.nostrdev.com/sigit/sigit.io/commit/c96a7fac4fcf59eacf097be9c39fcc13cd6f04b9))
|
||||
- logout user if signEvent's and auth's pubkeys are diff ([8153ef0](https://git.nostrdev.com/sigit/sigit.io/commit/8153ef03fbf693f6ec1ecd1425dc03d76d29416f))
|
||||
- **LogOut:** used log out action instead of clearState utility ([803e242](https://git.nostrdev.com/sigit/sigit.io/commit/803e242b01fb3aa68c0d305b340f8515a58b1717))
|
||||
- looping trough robo sets, image not shown when visiting profile while not logged in ([6604ea2](https://git.nostrdev.com/sigit/sigit.io/commit/6604ea2046afea40fc3deeb0548016b3ec1fe53d))
|
||||
- main css background, avoid overscroll showing white edge ([7570123](https://git.nostrdev.com/sigit/sigit.io/commit/757012399ac2236b9643b5812f28b1477bc54738))
|
||||
- manage pending relay connection requests ([f9fcfb1](https://git.nostrdev.com/sigit/sigit.io/commit/f9fcfb1c9e70a73acfda90ce4d1c1215623972df))
|
||||
- **mark:** css position ([413da78](https://git.nostrdev.com/sigit/sigit.io/commit/413da78c5c06b5b35740692f6b7c00125a7c8969))
|
||||
- marking ([b22f577](https://git.nostrdev.com/sigit/sigit.io/commit/b22f577cc2de21bb1f8370c84a1d263f09fd7eb6))
|
||||
- **marks:** add default signer ([dfdcb84](https://git.nostrdev.com/sigit/sigit.io/commit/dfdcb8419d5b3c8ca34c6f9590107ce120a53174))
|
||||
- **marks:** add file grouping for marks, fix read pdf types ([b6479db](https://git.nostrdev.com/sigit/sigit.io/commit/b6479db2665ef500d20831dcd941d5ce728b79d3))
|
||||
- **marks:** assign selectedMarkValue to currentValue and mark.value ([78060fa](https://git.nostrdev.com/sigit/sigit.io/commit/78060fa15fb55c597918042559d544ff4528dc24))
|
||||
- **mark:** scroll into marks, add scroll margin and forwardRef ([82b7b9f](https://git.nostrdev.com/sigit/sigit.io/commit/82b7b9f7ce1e8e6edfc547e18b56090236b02bdf)), closes [#172](https://git.nostrdev.com/sigit/sigit.io/issues/172)
|
||||
- **MetadataController:** fixed getting popular relays ([026537c](https://git.nostrdev.com/sigit/sigit.io/commit/026537c75b26a74fb067c210d9aedd6105d7a23c))
|
||||
- missing id/name on custom select input ([d0e3704](https://git.nostrdev.com/sigit/sigit.io/commit/d0e3704ed6a2c08eede388e353bcf76880873411))
|
||||
- **mobile:** active tab default state and styling ([6f7d4c9](https://git.nostrdev.com/sigit/sigit.io/commit/6f7d4c9dcfb696264f67db11a3a83a3c52ac0103))
|
||||
- **mobile:** use dynamic vh and one-by-one horizontal scroll ([3628137](https://git.nostrdev.com/sigit/sigit.io/commit/36281376bc2be5592193d01c483916b6c8859912))
|
||||
- modal override removed ([64b6f83](https://git.nostrdev.com/sigit/sigit.io/commit/64b6f8309f361a6db6c6e91005b50969cdbfa549))
|
||||
- move nostr login to nostr route ([3c22429](https://git.nostrdev.com/sigit/sigit.io/commit/3c22429941f476b4c55f4f862580fe1520a665a8))
|
||||
- moves sample data to a separate json file ([1de8e89](https://git.nostrdev.com/sigit/sigit.io/commit/1de8e89beb555e881b822ed0f37e9a44b03f321c))
|
||||
- moves styling to SVG ([38cd88f](https://git.nostrdev.com/sigit/sigit.io/commit/38cd88fd866e19168b91745d5cf98543eebbc0f7))
|
||||
- navigation to profile page from username component ([d502474](https://git.nostrdev.com/sigit/sigit.io/commit/d5024745f163ef38a833c3253177ebc67f2e8642))
|
||||
- nested a links in card ([e4a7fa4](https://git.nostrdev.com/sigit/sigit.io/commit/e4a7fa4892b05f648dfb988b898fb0658d2f22d4))
|
||||
- next signer and spinner anim duration ([d8adb2c](https://git.nostrdev.com/sigit/sigit.io/commit/d8adb2c74471bf55351b3649c699f8b6d4360a47))
|
||||
- no need to listen for authUrl in createNsecBunkerSigner method of NostrController ([3626368](https://git.nostrdev.com/sigit/sigit.io/commit/3626368e95b228f30dc6855f10d190f92d833aa3))
|
||||
- node version bump from 18 to 20 ([354312b](https://git.nostrdev.com/sigit/sigit.io/commit/354312bd96d6092502812d591d41947182aa335b))
|
||||
- nostr-login custom outbox relays ([555504f](https://git.nostrdev.com/sigit/sigit.io/commit/555504f42f030028af6b280d664e1024d63e1e12))
|
||||
- nsec login, metadata overlapping, robohash image in metadata state ([e3e15b7](https://git.nostrdev.com/sigit/sigit.io/commit/e3e15b7af139028ec4a3f27d6f037f1465eb2a56))
|
||||
- **Offline:** fixed 0.0.0.0 host ([7be9897](https://git.nostrdev.com/sigit/sigit.io/commit/7be98978dd2b492b4aad4b38f9289e1b45939132))
|
||||
- **online-detection:** use relative url ([8b4f1a8](https://git.nostrdev.com/sigit/sigit.io/commit/8b4f1a8973abe0a395cacf9617aab80bb606bf61))
|
||||
- Opening a sigit asks you to sign when you are not the next signer ([ae3d461](https://git.nostrdev.com/sigit/sigit.io/commit/ae3d461661f41f7243828015d26c2431ebb91fda))
|
||||
- opening link to sign a file while not logged in is not redirecting correctly ([eff8827](https://git.nostrdev.com/sigit/sigit.io/commit/eff8827a86d97c88386798fe4e5449bad42b3539))
|
||||
- optional label for download button in filelist ([3c230e6](https://git.nostrdev.com/sigit/sigit.io/commit/3c230e6fb4b5971669a6df8e4eeb1f9f78339873))
|
||||
- outdated cache checks ([f0ba9da](https://git.nostrdev.com/sigit/sigit.io/commit/f0ba9da8af9abc24fdae0b6fe65b83326d904e44))
|
||||
- page scrolling ([97c8271](https://git.nostrdev.com/sigit/sigit.io/commit/97c82718cb2991309894d2fd823f25035504b9be))
|
||||
- pdf to png scaling is 1, bottom position is now included ([4556bd0](https://git.nostrdev.com/sigit/sigit.io/commit/4556bd0c66f275956fe850b77f1b5c2a392c7760))
|
||||
- **pdf:** add border to style ([ecc1707](https://git.nostrdev.com/sigit/sigit.io/commit/ecc1707212fdee75775d38154ffbddc22619fb88))
|
||||
- **pdf:** add proper default width value ([a442e71](https://git.nostrdev.com/sigit/sigit.io/commit/a442e71087c75f9e224794e4160b9f8d6dfc71d9))
|
||||
- **pdf:** dynamic mark scaling ([ea09daa](https://git.nostrdev.com/sigit/sigit.io/commit/ea09daa6692e905c703d3800b8a8adbdb391f6b5))
|
||||
- **pdf:** font style consistency ([31f3675](https://git.nostrdev.com/sigit/sigit.io/commit/31f36750cd5479fc05e2a86ade5153e6a65955f6))
|
||||
- pdfjs import ([d5e0769](https://git.nostrdev.com/sigit/sigit.io/commit/d5e07696926f554894bb316df2e6a49e00983229))
|
||||
- **pdf:** keep upscaling to match viewport ([43beac4](https://git.nostrdev.com/sigit/sigit.io/commit/43beac48e85c32b09e10dd611c259ce2c3783a4a))
|
||||
- **pdf:** mark embedding, position, multiline, & placeholder ([f35e271](https://git.nostrdev.com/sigit/sigit.io/commit/f35e2718abcdae0d5c9624444d5ad33c5e368f33)), closes [#176](https://git.nostrdev.com/sigit/sigit.io/issues/176) [#178](https://git.nostrdev.com/sigit/sigit.io/issues/178)
|
||||
- **pdf:** reuse content width function ([59c3fc6](https://git.nostrdev.com/sigit/sigit.io/commit/59c3fc69a255c54475daa6a2efad3ae8a4b3efd8))
|
||||
- **pdf:** scaling and font styles consistency ([ac3186a](https://git.nostrdev.com/sigit/sigit.io/commit/ac3186a02ed441c6efc31aaf462a5b8b229f5fa1)), closes [#146](https://git.nostrdev.com/sigit/sigit.io/issues/146)
|
||||
- **pdf:** scaling on resize, add avatars to counterpart select ([4712031](https://git.nostrdev.com/sigit/sigit.io/commit/47120316152a7a3157f7cd089cb2184053ae25ec))
|
||||
- **pdf:** use minified version of pdf ([a3effd8](https://git.nostrdev.com/sigit/sigit.io/commit/a3effd878b25da50f0575f10dd094efae0b03ec7))
|
||||
- placeholder avatar is incosistent across components ([d15943f](https://git.nostrdev.com/sigit/sigit.io/commit/d15943f61bdac9573d528795ff43903459c0da3b))
|
||||
- popup forms designs ([e3ca3ab](https://git.nostrdev.com/sigit/sigit.io/commit/e3ca3ab9088e9a45d6d01c35811450c8c3f762dc))
|
||||
- processing events ([25764c7](https://git.nostrdev.com/sigit/sigit.io/commit/25764c7ab41708f03e4c671857be519020bee46f))
|
||||
- processing gift wraps and notifications ([#193](https://git.nostrdev.com/sigit/sigit.io/issues/193)) ([235e76b](https://git.nostrdev.com/sigit/sigit.io/commit/235e76be4e3eada7668bf802ff063394d958ff17))
|
||||
- profile image scale ([58c457b](https://git.nostrdev.com/sigit/sigit.io/commit/58c457b62c67201fb83c845f9fa5a81b87dfdc65))
|
||||
- profile page styling ([67e5c19](https://git.nostrdev.com/sigit/sigit.io/commit/67e5c19870bdd66ac1fc2b4dd3231a2fb77831a7))
|
||||
- profile picture inconsistencies, login with enter ([5f8e8fd](https://git.nostrdev.com/sigit/sigit.io/commit/5f8e8fd6f4eb6bf74c04abb51c2af545eda2be45))
|
||||
- push all files take 2 ([24916c5](https://git.nostrdev.com/sigit/sigit.io/commit/24916c58068bbe9e5dfc76cbf00c955add6744e4))
|
||||
- reduce mui usage, implement design updates ([9189ff3](https://git.nostrdev.com/sigit/sigit.io/commit/9189ff33bc714c795f8acedd85995c0152882a35))
|
||||
- redundant updates ([2d0212f](https://git.nostrdev.com/sigit/sigit.io/commit/2d0212fd6c683fb984eee55e1f815c2c6bbecae2))
|
||||
- **relay-controller:** sigit relay immutability and relay list ([e0d6c03](https://git.nostrdev.com/sigit/sigit.io/commit/e0d6c0363951c66bdede17759ae712626a4a07a5))
|
||||
- **relays:** allow adding ws:// ([04f1d69](https://git.nostrdev.com/sigit/sigit.io/commit/04f1d692a44123331129ee92443c92f9254403f4)), closes [#297](https://git.nostrdev.com/sigit/sigit.io/issues/297)
|
||||
- **relays:** relay add button size height ([5f3d92d](https://git.nostrdev.com/sigit/sigit.io/commit/5f3d92d62f1f958f3e93ed4c9cd879c88a5c5d6c)), closes [#244](https://git.nostrdev.com/sigit/sigit.io/issues/244)
|
||||
- removal of create nostr auth token ([60a7140](https://git.nostrdev.com/sigit/sigit.io/commit/60a7140c6a662c225c63108707ac9dd67990f88a))
|
||||
- remove both from UserRole enum ([b527339](https://git.nostrdev.com/sigit/sigit.io/commit/b5273393e6edd56fa2e9c6b9a305e56e4555020c))
|
||||
- remove duplicate states and fix default signer ([e05d3e5](https://git.nostrdev.com/sigit/sigit.io/commit/e05d3e53a2b663973adf2e02296b3a5bbfa8ee78))
|
||||
- remove nostr image for placeholder avatar, use robohash instead ([4f4f7fb](https://git.nostrdev.com/sigit/sigit.io/commit/4f4f7fb5c1ed21747b4b3bea5771674cf8d159a5))
|
||||
- remove placeholder used for text ([d0a6297](https://git.nostrdev.com/sigit/sigit.io/commit/d0a6297ccec0b61066cc2ca80e44dc6017581116))
|
||||
- remove screen on nostr-login launch ([8689c7f](https://git.nostrdev.com/sigit/sigit.io/commit/8689c7f753fc0d5ab5e88bdf3d376da2c60148c0))
|
||||
- remove unstable fetch events loop ([5f0234a](https://git.nostrdev.com/sigit/sigit.io/commit/5f0234a358788226b6bb0e71f95de8c70ef4bc3f))
|
||||
- removed redundant variable ([2455856](https://git.nostrdev.com/sigit/sigit.io/commit/245585662a094da385702438bcdd72387cd5267f))
|
||||
- removed viewer/signer button ([2f9017b](https://git.nostrdev.com/sigit/sigit.io/commit/2f9017b8403f2d42e773e27928b259830d123ecf))
|
||||
- removes retrier and updates notification ([3d5006a](https://git.nostrdev.com/sigit/sigit.io/commit/3d5006a7154ee9be6bb165f8cafc1bcd59c20e26))
|
||||
- removes unneeded notification ([b7bd922](https://git.nostrdev.com/sigit/sigit.io/commit/b7bd922af35d95a2d78a1b168ab1ec4c4d66a9ee))
|
||||
- removing file upload, avatar by robohash ([8e76202](https://git.nostrdev.com/sigit/sigit.io/commit/8e7620201ea4252bc9b025f4d0b24930795c016a))
|
||||
- replace sign with upload in homepage ([021db56](https://git.nostrdev.com/sigit/sigit.io/commit/021db5679a54ec4b6f44fbe86bb00cfa3125be82))
|
||||
- return immediately from publish event when published to at least one relay and keep publishing to other in background ([7df6ab8](https://git.nostrdev.com/sigit/sigit.io/commit/7df6ab8c8495443ccc83dca937ee26cefb158441))
|
||||
- reverting signing of nostr auth token ([38913e7](https://git.nostrdev.com/sigit/sigit.io/commit/38913e770de8b1900a58d21354963dadf6180d57))
|
||||
- review suggestion ([15d4d0a](https://git.nostrdev.com/sigit/sigit.io/commit/15d4d0a75276ec20394d2ef5e68e737c8f412cee))
|
||||
- **review:** remove inline styles ([b8811d7](https://git.nostrdev.com/sigit/sigit.io/commit/b8811d730a781c285ee6fc83a5faa6230aa45c3a))
|
||||
- robohash image missing with NIP05 login ([9baf0ec](https://git.nostrdev.com/sigit/sigit.io/commit/9baf0ecabae1b32a74b29c7dd65bf6ffd67525e4))
|
||||
- routing, removed useEffect ([8e71592](https://git.nostrdev.com/sigit/sigit.io/commit/8e71592d8815471bde6fb74230ba9742308daad8))
|
||||
- search bar scaling ([272fcf9](https://git.nostrdev.com/sigit/sigit.io/commit/272fcf93c64005b06249690815bb320ad66b9798))
|
||||
- search counterparts nip05 does not need to include '@' ([7b29d70](https://git.nostrdev.com/sigit/sigit.io/commit/7b29d7055eeb6bf7f9bbcc06fb2ecf0962157046))
|
||||
- selected mark selection ([0d52cd7](https://git.nostrdev.com/sigit/sigit.io/commit/0d52cd71134c9b3eee41e1ea853dba65afc7c79b))
|
||||
- show error if decrypt fails ([cc382f0](https://git.nostrdev.com/sigit/sigit.io/commit/cc382f072643918e83c399374bfe5ff77af794e4))
|
||||
- show extension box for non-mark files, de-dupe css and code ([05a2dba](https://git.nostrdev.com/sigit/sigit.io/commit/05a2dba164f015098cafb29d143b308d8db7dc8a)), closes [#138](https://git.nostrdev.com/sigit/sigit.io/issues/138)
|
||||
- show import/export only for local ([67d545d](https://git.nostrdev.com/sigit/sigit.io/commit/67d545de2fec2898ec12a4433ec9d722248a4b83))
|
||||
- sigit links and outline ([21caaa7](https://git.nostrdev.com/sigit/sigit.io/commit/21caaa7009e49cd7cedc54104ab9438c330ed708))
|
||||
- sigit's wrapper zip should contain keys.json file ([ded8304](https://git.nostrdev.com/sigit/sigit.io/commit/ded8304c669c257b5b782829ffb37be101af9cdd))
|
||||
- **sigit:** add to submittedBy avatar badge for verified sigit creation ([b2c3cf2](https://git.nostrdev.com/sigit/sigit.io/commit/b2c3cf2aca05a8e232a53ac087929f3eb797e23d))
|
||||
- **sigit:** excel extension typo, more excel types ([6b5a8a7](https://git.nostrdev.com/sigit/sigit.io/commit/6b5a8a7375d528ce4f8e53dd595e1bbde27ea433))
|
||||
- sign buttons styles ([8c97476](https://git.nostrdev.com/sigit/sigit.io/commit/8c974768a81db75a0bd94e20db6a495126207f5b))
|
||||
- **sign:** allow signing without marks, hide loading and show toast for prevSig error ([20d1170](https://git.nostrdev.com/sigit/sigit.io/commit/20d1170f7dd41832b83b34656a9f95e239f074cf))
|
||||
- **sign:** allow signing without selectedMark - no currentUserMarks ([92f23ba](https://git.nostrdev.com/sigit/sigit.io/commit/92f23bab91225d888c101c3670868eae132114e9))
|
||||
- **sign:** allow sumit without selectedMark ([cb0d2dd](https://git.nostrdev.com/sigit/sigit.io/commit/cb0d2dd7bc98a7e16c3d2e53fba4bd86a0c8a89d))
|
||||
- **sign:** always show PdfView ([8df5084](https://git.nostrdev.com/sigit/sigit.io/commit/8df5084703baf2b7ae416af8d8d5064cec13ee19))
|
||||
- **signature:** force re-render on value change ([a1c3087](https://git.nostrdev.com/sigit/sigit.io/commit/a1c308727f2786b48cb083bf0544a358ab211c2c))
|
||||
- signing order ([ec305c4](https://git.nostrdev.com/sigit/sigit.io/commit/ec305c417bcca6d70a24cdae14c1b99be40b0064))
|
||||
- simplify events, more ts and clean up ([6641cf2](https://git.nostrdev.com/sigit/sigit.io/commit/6641cf2ee703c4c973c69ecde864030fb2e91596))
|
||||
- some linter warnings and an error ([f51afe3](https://git.nostrdev.com/sigit/sigit.io/commit/f51afe3b677d418cdf4c4d29132f63f9ff1bd56b))
|
||||
- **spinner:** remove dummy desc and use variants ([d1b9eb5](https://git.nostrdev.com/sigit/sigit.io/commit/d1b9eb55d8b41c43b600b1e0f3432a7030dbec91))
|
||||
- styles fixed in homepage ([6553ed8](https://git.nostrdev.com/sigit/sigit.io/commit/6553ed89e08b7d9279935b63db99d9571e5391d5))
|
||||
- styling ([2f29ea9](https://git.nostrdev.com/sigit/sigit.io/commit/2f29ea9f35ad1c3285a9c01e7e51dfc37942c02f))
|
||||
- styling ([d41d577](https://git.nostrdev.com/sigit/sigit.io/commit/d41d577c29af2135e4352186af1b4b434d22cc95))
|
||||
- styling ([e681513](https://git.nostrdev.com/sigit/sigit.io/commit/e681513785bd0df6d16c0b34405ed834ca39740c))
|
||||
- styling ([551a3f8](https://git.nostrdev.com/sigit/sigit.io/commit/551a3f8509ae78f921d66370bcd653dd3f6dc226))
|
||||
- styling ([12fe476](https://git.nostrdev.com/sigit/sigit.io/commit/12fe476e97e2d907fcb41baa87bd8e1ca74f1b80))
|
||||
- svg attributes ([3a93622](https://git.nostrdev.com/sigit/sigit.io/commit/3a9362296674374b6c4b79e1260b0c043a5ea52b))
|
||||
- **tabs:** add tab icons ([2be7f3d](https://git.nostrdev.com/sigit/sigit.io/commit/2be7f3d51bfac0d58984229b04f97b5df8dbebc6))
|
||||
- take 3 all files ([02f250c](https://git.nostrdev.com/sigit/sigit.io/commit/02f250c76eb6d1b7fb410394c88397e37dd527e4))
|
||||
- take 4 (all files) ([abf9c3e](https://git.nostrdev.com/sigit/sigit.io/commit/abf9c3e4fd7b61d5f8794714484cb8a0c542d6e7))
|
||||
- take 5 files ([ea3f618](https://git.nostrdev.com/sigit/sigit.io/commit/ea3f61897c7ab8601547e3b61a6bdd833a19ad12))
|
||||
- take 6 ([400d192](https://git.nostrdev.com/sigit/sigit.io/commit/400d192fb0441bbe772d44a457f4e96a4d42d11f))
|
||||
- take 7 ([3f944bd](https://git.nostrdev.com/sigit/sigit.io/commit/3f944bdf73103e6a0152c32bc788d363c323f42b))
|
||||
- title text align ([c5b1a9b](https://git.nostrdev.com/sigit/sigit.io/commit/c5b1a9b3804c1a6003ba3d22afdb1b76b3d9db48))
|
||||
- toggle ([3549b6e](https://git.nostrdev.com/sigit/sigit.io/commit/3549b6e54292b3d6fe456025cefc397ba0aa070d))
|
||||
- top level container wrapper for other pages ([53b7b05](https://git.nostrdev.com/sigit/sigit.io/commit/53b7b05ac5ed75be25d84e5bb0a0a851ac04112d))
|
||||
- typo ([6c5ed3a](https://git.nostrdev.com/sigit/sigit.io/commit/6c5ed3a69c7c025a507cf87f77bd408a3eee3de1))
|
||||
- unzip and use timeout util ([8b00ef5](https://git.nostrdev.com/sigit/sigit.io/commit/8b00ef538b164b1116095fd5ffee95a5791667e5))
|
||||
- update buttons and button icon design ([28184ab](https://git.nostrdev.com/sigit/sigit.io/commit/28184ab03864627138852b720e638ba56de5e1b5))
|
||||
- update design buttons ([5d59ffc](https://git.nostrdev.com/sigit/sigit.io/commit/5d59ffce28e1248c15d04730794606fbf4b2e1dd))
|
||||
- update DM wording ([de00b9b](https://git.nostrdev.com/sigit/sigit.io/commit/de00b9b5a70bdafa2c10c35ba8956fffef1802d3))
|
||||
- update footer design ([af689a0](https://git.nostrdev.com/sigit/sigit.io/commit/af689a00f7848ce1a61c6a19eaa0e76a8e417d5c))
|
||||
- update logo and favicon ([017d1ab](https://git.nostrdev.com/sigit/sigit.io/commit/017d1ab88b3aa8b99c96641a9f5b04745fa31259))
|
||||
- update nsecBunker delegated key after logout ([962b2bc](https://git.nostrdev.com/sigit/sigit.io/commit/962b2bcea676ff247218196e7649ed17141b64b5))
|
||||
- update online and offline flows ([e8da0dc](https://git.nostrdev.com/sigit/sigit.io/commit/e8da0dc76f37f9b8cc8033ce6480b9d806cec718))
|
||||
- update popup design ([55158fc](https://git.nostrdev.com/sigit/sigit.io/commit/55158fc313e9a31055210e061ca136c106cdf03a))
|
||||
- update the logic for login with nsecbunker ([7c3c061](https://git.nostrdev.com/sigit/sigit.io/commit/7c3c061b88029f7643f471f2cf2279cc115e0719))
|
||||
- update the url in DM to contain fileUrl and encryption key ([9fa3df3](https://git.nostrdev.com/sigit/sigit.io/commit/9fa3df3850935b4798489e9980de4520f00c2b20))
|
||||
- update user placeholder for create ([e7b0bbe](https://git.nostrdev.com/sigit/sigit.io/commit/e7b0bbe23c71421d9725b242cb62ed11e40ffdad))
|
||||
- update verify to use file signature check ([18637bb](https://git.nostrdev.com/sigit/sigit.io/commit/18637bbbc193f970c03c9b19d522fff29390273f))
|
||||
- updated latest version of nostr-login which includes outboxRelays option ([6f6ed3c](https://git.nostrdev.com/sigit/sigit.io/commit/6f6ed3c39f959d287f93ed1bd111d296b3e3fdf5))
|
||||
- updates blossom authorisation event ([dd53ded](https://git.nostrdev.com/sigit/sigit.io/commit/dd53ded5186abf692a4b554a39a21f445672a5d4))
|
||||
- updating title on homepage ([481ef6c](https://git.nostrdev.com/sigit/sigit.io/commit/481ef6cdc21ed89280e4ec748fbd0d8866180324))
|
||||
- url ([79ef9eb](https://git.nostrdev.com/sigit/sigit.io/commit/79ef9eb8d6ced4cbb0517def4b7864176c78b1f4))
|
||||
- url encode the DM link payload ([38def3b](https://git.nostrdev.com/sigit/sigit.io/commit/38def3bda5381259047f57065cad10b84a395d53))
|
||||
- use correct key for signer status, update signer badge icons ([3743a30](https://git.nostrdev.com/sigit/sigit.io/commit/3743a30ef62084c6c3a8cfdfcb63d1f08f0162ed))
|
||||
- use dedicated key from nip78 in auth event for uploading files.zip ([8eaf9cb](https://git.nostrdev.com/sigit/sigit.io/commit/8eaf9cb61cc6de9d60f40c110565f3d560f51229))
|
||||
- use default relayMap if its undefined in redux store ([d7b5ea9](https://git.nostrdev.com/sigit/sigit.io/commit/d7b5ea9b9ead53193204af99374ced2465a83e4e))
|
||||
- use hash router instead of browser router ([3d980ca](https://git.nostrdev.com/sigit/sigit.io/commit/3d980ca2e7a4afb2c37fce8f1ccef9e192af980d))
|
||||
- use iframe for nsecbunker auth ([c99a2a8](https://git.nostrdev.com/sigit/sigit.io/commit/c99a2a81c265f601e2af00890132818d905d6133))
|
||||
- use kind 0 event for nostr joining block ([9bb62cf](https://git.nostrdev.com/sigit/sigit.io/commit/9bb62cf96676aa5bca5882260f037ce00c5ee74f))
|
||||
- use kind 27235 in place of kind 1 wherever possible ([9073419](https://git.nostrdev.com/sigit/sigit.io/commit/90734196e5f14b4c988b3ab36c1ab2a968e2842a))
|
||||
- use old approach of using sha256 for generating d tag ([49c1714](https://git.nostrdev.com/sigit/sigit.io/commit/49c17149621670b7d44184762ded530fd66efbc1))
|
||||
- use relays from nip65 for broadcasting DMs ([349e26b](https://git.nostrdev.com/sigit/sigit.io/commit/349e26b62888e72d7987ee6c1baab761b998ed22))
|
||||
- userRobotImage reducer type fix ([ccc31c5](https://git.nostrdev.com/sigit/sigit.io/commit/ccc31c51c99945b5f0634bbe2ce11851d86ae367))
|
||||
- useSigitProfile dep ([329fd3d](https://git.nostrdev.com/sigit/sigit.io/commit/329fd3d27beeb4ae08558887b731b9657de90237))
|
||||
- verify page robohash ([5e114f7](https://git.nostrdev.com/sigit/sigit.io/commit/5e114f7fb86b4205aefd6125fe5fc2348d3cfb0b))
|
||||
- **verify-page:** add mark styling ([423b6b6](https://git.nostrdev.com/sigit/sigit.io/commit/423b6b6792feca3ff5891bfc1d9f2181d8a00195))
|
||||
- **verify-page:** export (download) files now includes files ([7278485](https://git.nostrdev.com/sigit/sigit.io/commit/7278485b76c6e4a6319d1f3a7941d4985dc93cad))
|
||||
- **verify-page:** map item keys ([58f70db](https://git.nostrdev.com/sigit/sigit.io/commit/58f70db7f61a8a963289831d25b7ea877798a593))
|
||||
- **verify-page:** parse and show mark values ([f88e2ad](https://git.nostrdev.com/sigit/sigit.io/commit/f88e2ad6804424755dacfc8c89da4fb8c2b90fcc))
|
||||
- **verify-page:** remove mark border in production, enable dev flag for css classes ([c3a3915](https://git.nostrdev.com/sigit/sigit.io/commit/c3a39157ffdb217dc9e7fa16ff600386a1f95307))
|
||||
- verify/sign link ([e48a396](https://git.nostrdev.com/sigit/sigit.io/commit/e48a3969904c1ec9759a60e9b21f998569ce6b13))
|
||||
- **verify:** offline flow ([759a40a](https://git.nostrdev.com/sigit/sigit.io/commit/759a40a4f910d81fa95bc4b7304bc6a1eb6b8eda))
|
||||
- when decrypting file, have better error messages ([5d6a358](https://git.nostrdev.com/sigit/sigit.io/commit/5d6a3580a6b3c97afc7a1f015458fb0a51101f52))
|
||||
- when opening a sigit after user signed it, asks user to sign again instead of redirecting to /verify ([ccb4036](https://git.nostrdev.com/sigit/sigit.io/commit/ccb40360292af4bf10f24fc935c9ca869729ec8f))
|
||||
- wording of adding counterparties ([33d58a2](https://git.nostrdev.com/sigit/sigit.io/commit/33d58a2166479f49e2596313a3359cd0204fadf5))
|
||||
- works offline card icon ([baa1a7b](https://git.nostrdev.com/sigit/sigit.io/commit/baa1a7b040c7bdd2af6c01f2b45178868095e5d3))
|
||||
|
||||
### Code Refactoring
|
||||
|
||||
- use signature pad, smoother signature line ([7c7a222](https://git.nostrdev.com/sigit/sigit.io/commit/7c7a222d4fac7d119270f3d6b79b75f6d60032ff))
|
||||
|
||||
### Features
|
||||
|
||||
- ability to change the order of signers in create screen ([8deaae8](https://git.nostrdev.com/sigit/sigit.io/commit/8deaae80de8afe62e65248e91a94ffb378cc3952))
|
||||
- add background images ([e9a1b98](https://git.nostrdev.com/sigit/sigit.io/commit/e9a1b9894c8c609289554ddb937ef0522a12bde3))
|
||||
- add banner and styling ([5f39b55](https://git.nostrdev.com/sigit/sigit.io/commit/5f39b55f6860f2ee73c1d72e384915fb85ed4336))
|
||||
- add cache setting page ([278d965](https://git.nostrdev.com/sigit/sigit.io/commit/278d9655f6ca587071451bdedc013fd1d2648395))
|
||||
- add children support to routes arrays ([0b35f11](https://git.nostrdev.com/sigit/sigit.io/commit/0b35f11abf251b5f45bc7f7926275692cde69048))
|
||||
- add color border to user's profile picture based on first 6 character of user's hexkey ([89850f8](https://git.nostrdev.com/sigit/sigit.io/commit/89850f881d6afbe9f67e1a07510f6978acfca0ac))
|
||||
- add custom Container component for layouts ([e54eced](https://git.nostrdev.com/sigit/sigit.io/commit/e54eced800305c1e724b846c9fbff4cf97f77414))
|
||||
- add dropzone and multiple files support ([83ddc1b](https://git.nostrdev.com/sigit/sigit.io/commit/83ddc1bbc810a9f0d20dbf381cca5404cb7eb4c5))
|
||||
- add exportedBy to useSigitMeta ([13254fb](https://git.nostrdev.com/sigit/sigit.io/commit/13254fbe0641796eb40425d0910db2d9fc43645d))
|
||||
- add MarkConfig and components ([dfa2832](https://git.nostrdev.com/sigit/sigit.io/commit/dfa2832e8d757842b848101323a4de03cc74f0a1))
|
||||
- add minimal styling secondary button ([9a1d3d9](https://git.nostrdev.com/sigit/sigit.io/commit/9a1d3d98bf866b97e9d9748cdad9e9159b4ef7d9))
|
||||
- add modal with login, register, nostr routes ([868ae6f](https://git.nostrdev.com/sigit/sigit.io/commit/868ae6f23e68bf3e0b4503caa74b822b68219438))
|
||||
- add nostrLoginAuthMethod to state ([110621a](https://git.nostrdev.com/sigit/sigit.io/commit/110621a125230f56e13e430b732dd67730b45fff))
|
||||
- add prev signer's signature in the content of next signer's signed event ([7947abf](https://git.nostrdev.com/sigit/sigit.io/commit/7947abf0f963fe2a1b926852527acc52e28eaacb))
|
||||
- Add Sigit ID as a path param ([75a715d](https://git.nostrdev.com/sigit/sigit.io/commit/75a715d002f005e327442015dc322b278f59bc8e))
|
||||
- Add Sigit ID as a Path Param to /verify ([0008e98](https://git.nostrdev.com/sigit/sigit.io/commit/0008e9814681de43068235f61c7bd88e7a1f3510))
|
||||
- add simple spinner wrapper ([01ca81b](https://git.nostrdev.com/sigit/sigit.io/commit/01ca81be2a431e8242cbae50f2e58115fc17a335))
|
||||
- add squiggle support ([de44370](https://git.nostrdev.com/sigit/sigit.io/commit/de44370a96e94846a2e0b47ca79599cdb127226a))
|
||||
- add sticky layout with slots ([dfe67b9](https://git.nostrdev.com/sigit/sigit.io/commit/dfe67b99ad7d80b1ab7c3d41bd5f5281d1fc1f5e))
|
||||
- add sticky layout with slots ([e16b8cf](https://git.nostrdev.com/sigit/sigit.io/commit/e16b8cfe3fe297983a3fd122ac25b89ca1568835))
|
||||
- add SVGO, enable signature ([9286e43](https://git.nostrdev.com/sigit/sigit.io/commit/9286e4304f52a3eaf2a87b6d2b9ebecc32d398ba))
|
||||
- add the ability to create and sign while user is offline ([c3c9bf7](https://git.nostrdev.com/sigit/sigit.io/commit/c3c9bf772d5e10ba6bf55d39e8f21ba261828b60))
|
||||
- add uploaded image file as preview ([ae08b07](https://git.nostrdev.com/sigit/sigit.io/commit/ae08b07d7404bb8a9988a700ebce72d777e2d725))
|
||||
- add UserAvatar, UserIconButton ([20bb05d](https://git.nostrdev.com/sigit/sigit.io/commit/20bb05ddc61e5126e46a1e4943619d67d7f4cc27)), closes [#68](https://git.nostrdev.com/sigit/sigit.io/issues/68)
|
||||
- add verify link in landing page ([8884389](https://git.nostrdev.com/sigit/sigit.io/commit/8884389c6ad59cf695d7f03e67cc37095abaee55))
|
||||
- add verify page ([5c14402](https://git.nostrdev.com/sigit/sigit.io/commit/5c1440244cbd3e6d9b80e557dc1a511c1a067871))
|
||||
- added a local cache based on browsers built in indexDB ([5b1147d](https://git.nostrdev.com/sigit/sigit.io/commit/5b1147da5db4f04eb622633ad5397d6a6c8056b0))
|
||||
- added a setting page ([e82023f](https://git.nostrdev.com/sigit/sigit.io/commit/e82023f105117ead6ab623cb4915c96edc7cbac7))
|
||||
- added hashes.json in zip ([d879c7d](https://git.nostrdev.com/sigit/sigit.io/commit/d879c7d45a0d4c6356008a6572277c3e443ce806))
|
||||
- added ndkContext and used it in relays page ([3c061d5](https://git.nostrdev.com/sigit/sigit.io/commit/3c061d5920e2d518b6a837a61e151cc1586b88b7))
|
||||
- added nsecbunker setting page ([b2a8cff](https://git.nostrdev.com/sigit/sigit.io/commit/b2a8cff907161511f944a02d829b4230007360fa))
|
||||
- added profile banner ([6eedfb8](https://git.nostrdev.com/sigit/sigit.io/commit/6eedfb8f3fe0785a98ed36408061c9ed7ab9645a))
|
||||
- added profile view ([5d0076d](https://git.nostrdev.com/sigit/sigit.io/commit/5d0076dd62f0055d0280186182fdb0d3a409b6af))
|
||||
- added the ability to login with nsecbunker connection string ([4973721](https://git.nostrdev.com/sigit/sigit.io/commit/497372160843f11d0b206fa490992d257004d773))
|
||||
- added the ability to re-broadcast sigit ([5db4d1b](https://git.nostrdev.com/sigit/sigit.io/commit/5db4d1b4291f37986d517f22b021cf80fffb10c7))
|
||||
- allow the user to login via nsecbunker using only domain part ([3efa557](https://git.nostrdev.com/sigit/sigit.io/commit/3efa557976f72e6b898876ce0c1c3736f620f71b))
|
||||
- **auth:** nsec login with url params ([995c7ce](https://git.nostrdev.com/sigit/sigit.io/commit/995c7ce293474ce098900a057d6ae442c90df71c))
|
||||
- changed MIME type of the uploaded file to sigit ([4e7f9d6](https://git.nostrdev.com/sigit/sigit.io/commit/4e7f9d650ed77db5c2ff7388a140fed790e2d784))
|
||||
- **ci:** add git hooks ([70f625f](https://git.nostrdev.com/sigit/sigit.io/commit/70f625ffd128f132cc3f92a4465b7e4d73a9ed97))
|
||||
- **ci:** add lint-staged in pre-commit ([84d1379](https://git.nostrdev.com/sigit/sigit.io/commit/84d13793ffd5fab5c2f0148fb7825c21f23431a0))
|
||||
- **ci:** add open pr workflow ([5290dda](https://git.nostrdev.com/sigit/sigit.io/commit/5290dda52a76093b0e99ecbfc340fa6fae99f728))
|
||||
- configured semantic releases ([c0b9039](https://git.nostrdev.com/sigit/sigit.io/commit/c0b903929d478ce3eb2c7636bf9ad0da5b32534d))
|
||||
- **content:** show other file types as gray box ([c9d7d0a](https://git.nostrdev.com/sigit/sigit.io/commit/c9d7d0a6f58708db866b9099c49800ce48930c65))
|
||||
- convert hexkeys to npub in meta.json ([ee2f0cb](https://git.nostrdev.com/sigit/sigit.io/commit/ee2f0cbc970cdcb6d491f0689735b59a31c825ec))
|
||||
- create page search users ([4af28ab](https://git.nostrdev.com/sigit/sigit.io/commit/4af28abcb666351a348f3375f4eb1d21d18fbf65))
|
||||
- create signing request and send a DM to first signer with zip file url and encryption key ([bd1e841](https://git.nostrdev.com/sigit/sigit.io/commit/bd1e8417c17ea559d1a3f09e85e5f0e96b5dd1f4))
|
||||
- **create-page:** intial layout and page styling ([86c8cc0](https://git.nostrdev.com/sigit/sigit.io/commit/86c8cc00fd9a019690c9f700c2496459ea1d3a54))
|
||||
- **create:** add counterpart component for drawing field ([4131eb5](https://git.nostrdev.com/sigit/sigit.io/commit/4131eb5de1e139a5c0db35fb0128c2562279dc50))
|
||||
- **create:** add Image and File items ([889d6a0](https://git.nostrdev.com/sigit/sigit.io/commit/889d6a0f440bbec8d9ad6362324693dbb4c5511e))
|
||||
- **create:** touch support for dnd ([3e07575](https://git.nostrdev.com/sigit/sigit.io/commit/3e075754e5ec8b858f2e5a658a6137d4be188380))
|
||||
- custom select component ([8d16831](https://git.nostrdev.com/sigit/sigit.io/commit/8d168314de807bfb7b5d96ddc0cf82109afdf343))
|
||||
- **dashboard:** add sigits filtering, sorting, searching ([becd021](https://git.nostrdev.com/sigit/sigit.io/commit/becd02153c9cecb45041ab7e0b05b8a8cfbcb08a))
|
||||
- **export:** add icons and make encrypted be first/top option ([99d562a](https://git.nostrdev.com/sigit/sigit.io/commit/99d562a3edb62b09664091946a59e88020460d39))
|
||||
- extension icon label util component ([c3f60b1](https://git.nostrdev.com/sigit/sigit.io/commit/c3f60b1e643ff2e9ccf8f483a971b1970cf7d786))
|
||||
- handle root \_@ users on add counterpart ([897daaa](https://git.nostrdev.com/sigit/sigit.io/commit/897daaa1fa57a587b5562fd9c94526dd22485b65))
|
||||
- **home:** add search param to address bar and sync the state with navigation ([93b2477](https://git.nostrdev.com/sigit/sigit.io/commit/93b2477839900598195bbb6ab28c82493a8abc98))
|
||||
- implemented profile page ([c0547b2](https://git.nostrdev.com/sigit/sigit.io/commit/c0547b2a1f05e02dea247822672700a5d15f79e7))
|
||||
- implemented relay controller and use that for fetching and publishing events ([a775d7b](https://git.nostrdev.com/sigit/sigit.io/commit/a775d7b265594d575f106898585b8f1dcebbce6f))
|
||||
- implemented the UI and logic for signing document ([a32abaf](https://git.nostrdev.com/sigit/sigit.io/commit/a32abaf9e703d481b3b8fc45739b312e907979a9))
|
||||
- improve design for homepage ([de4d927](https://git.nostrdev.com/sigit/sigit.io/commit/de4d927c73dc50d2b2ce85af232c9bcd7b98d091))
|
||||
- improve verification process ([6611a85](https://git.nostrdev.com/sigit/sigit.io/commit/6611a855d9342a028cbe5e4a88cac058ca18a62a))
|
||||
- in offline mode navigate creator to sign screen after creation when creator is first signer ([1f7980e](https://git.nostrdev.com/sigit/sigit.io/commit/1f7980e2ca285117a8971a4d5d94ea5b56d15ff7))
|
||||
- In sign page navigate to verify after export ([8f463b3](https://git.nostrdev.com/sigit/sigit.io/commit/8f463b36c08761a4a8e4ff9b67068be90eef8ea6))
|
||||
- include the original files always ([db9cf9d](https://git.nostrdev.com/sigit/sigit.io/commit/db9cf9d20cf78cae85ba431eafea2365337f1b1e))
|
||||
- landing page - larger cta button ([3149ba9](https://git.nostrdev.com/sigit/sigit.io/commit/3149ba975777c557bae46b86e77f20392b9ebaec))
|
||||
- landing page - responsive cards ([87e4536](https://git.nostrdev.com/sigit/sigit.io/commit/87e4536713795765e9300e72b3262395b07e76b3))
|
||||
- landing page implementation and styling ([0a61ae5](https://git.nostrdev.com/sigit/sigit.io/commit/0a61ae5f6455d76c1f7f925abce9dfeb94fbc1fa))
|
||||
- **loading-spinner:** add children support for default variant ([4d1e672](https://git.nostrdev.com/sigit/sigit.io/commit/4d1e6722681849c72d8ad5cfaebc543ab61dd907))
|
||||
- logo and favicon ([a36ed8e](https://git.nostrdev.com/sigit/sigit.io/commit/a36ed8eab0059876c15c10b7e60bd6103a3ddd4b))
|
||||
- maintain logged in sesssion ([2ed092b](https://git.nostrdev.com/sigit/sigit.io/commit/2ed092bcbd7ecffe38d1fa9704ed847b53a99b41))
|
||||
- make block number link that will refernce to the event ([37bc205](https://git.nostrdev.com/sigit/sigit.io/commit/37bc205ce4e8ea8eb1cbcd5f1a57703501bd7c52))
|
||||
- make verify page public and add verify option in user menu list ([12ca854](https://git.nostrdev.com/sigit/sigit.io/commit/12ca854c4852f28367a51cb35f9dec6e2e5ff025))
|
||||
- **meta:** add error handling for meta.json blossom operations ([7007492](https://git.nostrdev.com/sigit/sigit.io/commit/7007492a0d1e9d21f505a300aa6b2ca24cf0b585))
|
||||
- **meta:** send notifications with blossom instead of meta.json ([3d1bdec](https://git.nostrdev.com/sigit/sigit.io/commit/3d1bdece4d881f347e974506af9d01d9be01f4f7))
|
||||
- **mobile:** tabs and scrolling ([d9be051](https://git.nostrdev.com/sigit/sigit.io/commit/d9be05165fad1fe07f51dbccc47b0fe2e675ee86))
|
||||
- navigate to different pages based on uploaded file ([92b62a3](https://git.nostrdev.com/sigit/sigit.io/commit/92b62a3cbed8461cbbb25cb841bec9063f11e90d))
|
||||
- nostr.json ([bb37a27](https://git.nostrdev.com/sigit/sigit.io/commit/bb37a27321cd9b26537b8fbbe2b39902b6c85fc4))
|
||||
- **offline:** add decrypt as zip util ([8b5abe0](https://git.nostrdev.com/sigit/sigit.io/commit/8b5abe02e2b9d3f3101afa014c4fa4655ed4b099))
|
||||
- **offline:** add signer service util class ([bcd5713](https://git.nostrdev.com/sigit/sigit.io/commit/bcd57138caeb03b03f5b9a4df403534d076a4a15))
|
||||
- **offline:** split online and offline flow with dedicated buttons, remove export in sign, all counterparties can decrypt ([3f01ab8](https://git.nostrdev.com/sigit/sigit.io/commit/3f01ab8fcaf7aa94460215418315f56190e4f4b0))
|
||||
- **opentimestamps:** adds OTS library and retrier function ([edfe9a2](https://git.nostrdev.com/sigit/sigit.io/commit/edfe9a2954b1222716f9cd43516b6a041de8bb1b))
|
||||
- **opentimestamps:** adds timestamps to create flow ([85bcfac](https://git.nostrdev.com/sigit/sigit.io/commit/85bcfac2e0aa8bffaf258c89b5c73b35f108f38b))
|
||||
- **opentimestamps:** amends to flow to only upgrade users timestamps ([f12aaf1](https://git.nostrdev.com/sigit/sigit.io/commit/f12aaf1c2bfa4c8d3ee26e9c4c14ae5759551381))
|
||||
- **opentimestamps:** refactors to timestamp the nostr event id ([07f1a15](https://git.nostrdev.com/sigit/sigit.io/commit/07f1a15aa1775a857b526a8d343b8f1708535ed0))
|
||||
- **opentimestamps:** update the full flow ([21aa25a](https://git.nostrdev.com/sigit/sigit.io/commit/21aa25a42a2797d84f20be576d016f2075c09fa0))
|
||||
- **opentimestamps:** updates data model ([85bf907](https://git.nostrdev.com/sigit/sigit.io/commit/85bf907f54a9e81758e66e30bfd72f3aa79fd06a))
|
||||
- **opentimestamps:** updates data model and useSigitMeta hook ([edbe708](https://git.nostrdev.com/sigit/sigit.io/commit/edbe708b65e342033c2e66bce21ac3d1622088c3))
|
||||
- **opentimestamps:** updates opentimestamps type ([b92790c](https://git.nostrdev.com/sigit/sigit.io/commit/b92790ceede513f6aaa6c0d04bf31ab70550d507))
|
||||
- **opentimestamps:** updates signing flow ([7f00f9e](https://git.nostrdev.com/sigit/sigit.io/commit/7f00f9e8bf8b15e811361aad2a2d75941ba056eb))
|
||||
- **opentimestamps:** updates the flow and adds notifications ([2b630c9](https://git.nostrdev.com/sigit/sigit.io/commit/2b630c94b639368d5d4789f38c747c190dfec547))
|
||||
- **opentimestamps:** updates tooltip ([19b815e](https://git.nostrdev.com/sigit/sigit.io/commit/19b815e52819b3e79c41e6f8d5c076bb6d7fd6b6))
|
||||
- **opentimestamps:** updates utils and adds comments ([a2138f1](https://git.nostrdev.com/sigit/sigit.io/commit/a2138f1de18f7085349699a885576e00100989df))
|
||||
- **PDF Management:** added pdf pages preview with fields list ([e715f6a](https://git.nostrdev.com/sigit/sigit.io/commit/e715f6ae6f8da06027edad85eb806ab7b806d33a))
|
||||
- **pdf markings:** added drawing component, parsing pdfs and displaying in the UI ([8576034](https://git.nostrdev.com/sigit/sigit.io/commit/8576034829563d1116f14ca7f0928c55adbabf3c))
|
||||
- **pdf-fields:** add logic to hide signers on ESC ([e37f90d](https://git.nostrdev.com/sigit/sigit.io/commit/e37f90d6db713434912530988a80af3390ed8a92))
|
||||
- **pdf-marking:** add pdf-view components ([b58ba62](https://git.nostrdev.com/sigit/sigit.io/commit/b58ba625f9087c74e81217f3418201673654524f))
|
||||
- **pdf-marking:** adds file downloading functionality ([6d881cc](https://git.nostrdev.com/sigit/sigit.io/commit/6d881ccb45e440c343b768c6d26d6933b2a4b813))
|
||||
- **pdf-marking:** adds file validity check ([eca31ce](https://git.nostrdev.com/sigit/sigit.io/commit/eca31cea4f68730ab5d70428902a04514d268764))
|
||||
- **pdf-marking:** adds file validity check ([ed7acd6](https://git.nostrdev.com/sigit/sigit.io/commit/ed7acd6cb4c73ee2907fb5062a10dbb8d369f7c9))
|
||||
- **pdf-marking:** binds text to marks and saves with signatures ([4a932ff](https://git.nostrdev.com/sigit/sigit.io/commit/4a932ffe03cd4adad33abfdc7355335e4501038f))
|
||||
- **pdf-marking:** implements png to pdf conversion and ability to download full sigits after signing ([cb9a443](https://git.nostrdev.com/sigit/sigit.io/commit/cb9a443fb18d5c562fe73400bb7aeedb4abf3f7e))
|
||||
- **pdf-marking:** integrates layouts ([64dbd7d](https://git.nostrdev.com/sigit/sigit.io/commit/64dbd7d479bb4baebc43d72f04dbedf7a18d02a7))
|
||||
- **pdf-marking:** integrates UserDetails ([2becab9](https://git.nostrdev.com/sigit/sigit.io/commit/2becab9f79e1cb3aaf91178d67c70f9e98c4f98b))
|
||||
- **pdf-marking:** updates design and functionality of the pdf marking form ([ed0158e](https://git.nostrdev.com/sigit/sigit.io/commit/ed0158e8177b79a56124c57569f5cba81d57b40b))
|
||||
- **pdf-marking:** updates mark type and adds pdf-view components ([296b135](https://git.nostrdev.com/sigit/sigit.io/commit/296b135c064ef877faa951bce06e4d3b6928b4cb))
|
||||
- **profile:** picture upload, robohash, website, npub cash ([041bd0d](https://git.nostrdev.com/sigit/sigit.io/commit/041bd0daff4ad06b5ef54798f4c43642c05a2d25))
|
||||
- **Relay:** added methods to get info, most popular, connect and disconnect from relays ([ffb2379](https://git.nostrdev.com/sigit/sigit.io/commit/ffb237991cb669285ff9add7a3c610a1218dabcd))
|
||||
- **Relays:** added logic to manage relays ([64f8227](https://git.nostrdev.com/sigit/sigit.io/commit/64f822743f8fc323ee47f715555c9f9fc579bf5c))
|
||||
- **Relays:** improved relays page ([c37e8f3](https://git.nostrdev.com/sigit/sigit.io/commit/c37e8f36c26701a4743d38282f94801104becea7))
|
||||
- search users by nip05, npub and filter: serach, improved UX ([6c7cac2](https://git.nostrdev.com/sigit/sigit.io/commit/6c7cac23361103665e318f52097677f4d95887b1))
|
||||
- show block number on user profile ([1eed099](https://git.nostrdev.com/sigit/sigit.io/commit/1eed099059fe169e166c979e5900ceeb6da557b7))
|
||||
- Sign Directly From the Marking Screen fix: Marking inputs glitches, losing values ([0a0a9be](https://git.nostrdev.com/sigit/sigit.io/commit/0a0a9bef348e798d37d892b602e19e82e41d0fba))
|
||||
- **signature:** export signature files ([cdf26b6](https://git.nostrdev.com/sigit/sigit.io/commit/cdf26b6614fc33f840a20596a064b20cc503275a))
|
||||
- **signature:** signature pad encrypt, upload, fetch, decrypt, render, add to pdf ([9551750](https://git.nostrdev.com/sigit/sigit.io/commit/9551750cbe0d84abc983e8746dcf67aedf99c525))
|
||||
- **signature:** verify hash ([a371e98](https://git.nostrdev.com/sigit/sigit.io/commit/a371e98e9e402ba0ee4b674687f6dc71352eb78c))
|
||||
- **signers-dropdown:** improved hiding/displaying logic ([76b1fa7](https://git.nostrdev.com/sigit/sigit.io/commit/76b1fa792c8cd27f36b30eecd829e75d810d5e00))
|
||||
- **Store:** configured relays state ([106827b](https://git.nostrdev.com/sigit/sigit.io/commit/106827b6da2553acf7db27dfe0fe1b292837b654))
|
||||
- update findMetadata method of metadata controller ([2b96172](https://git.nostrdev.com/sigit/sigit.io/commit/2b9617232ed3cd283249a43a6eb78db1297500ca))
|
||||
- update signing flow ([1f9954b](https://git.nostrdev.com/sigit/sigit.io/commit/1f9954befd01c4e9f90330f3db89aa75f0039bbe))
|
||||
- use nip04 for encryption and decryption of userData to store on blossom server ([18270c5](https://git.nostrdev.com/sigit/sigit.io/commit/18270c5d8afc376a6cef3b7cc3ea66a272797637))
|
||||
- **verify-page:** add files view and content images ([2c586f3](https://git.nostrdev.com/sigit/sigit.io/commit/2c586f3c13f15010b08324557bbd89ba35fd00cb))
|
||||
|
||||
### Reverts
|
||||
|
||||
- "feat(pdf-marking): adds file validity check" ([268a4db](https://git.nostrdev.com/sigit/sigit.io/commit/268a4db3ff211566af3e8cf77838c54d3e9c861e))
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
- mark.value type changed
|
@ -4,6 +4,7 @@
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/png" href="/favicon.png" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="manifest" href="/app.webmanifest" />
|
||||
<title>SIGit</title>
|
||||
</head>
|
||||
<body>
|
||||
|
9008
package-lock.json
generated
9008
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
22
package.json
22
package.json
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "sigit",
|
||||
"private": true,
|
||||
"version": "0.0.0-beta",
|
||||
"version": "1.0.4",
|
||||
"type": "module",
|
||||
"homepage": "https://sigit.io/",
|
||||
"license": "AGPL-3.0-or-later ",
|
||||
@ -17,7 +17,8 @@
|
||||
"preview": "vite preview",
|
||||
"preinstall": "git config core.hooksPath .git-hooks",
|
||||
"license-checker": "node licenseChecker.cjs",
|
||||
"lint-staged": "lint-staged"
|
||||
"lint-staged": "lint-staged",
|
||||
"release": "commit-and-tag-version"
|
||||
},
|
||||
"dependencies": {
|
||||
"@emotion/react": "11.11.4",
|
||||
@ -30,11 +31,11 @@
|
||||
"@mui/lab": "5.0.0-alpha.166",
|
||||
"@mui/material": "5.15.11",
|
||||
"@noble/hashes": "^1.4.0",
|
||||
"@nostr-dev-kit/ndk": "2.10.0",
|
||||
"@nostr-dev-kit/ndk-cache-dexie": "2.5.1",
|
||||
"@nostr-dev-kit/ndk": "2.11.0",
|
||||
"@nostr-dev-kit/ndk-cache-dexie": "2.5.9",
|
||||
"@pdf-lib/fontkit": "^1.1.1",
|
||||
"@reduxjs/toolkit": "2.2.1",
|
||||
"axios": "^1.7.4",
|
||||
"axios": "^1.8.2",
|
||||
"crypto-hash": "3.0.0",
|
||||
"crypto-js": "^4.2.0",
|
||||
"dexie": "4.0.8",
|
||||
@ -61,10 +62,15 @@
|
||||
"react-toastify": "10.0.4",
|
||||
"redux": "5.0.1",
|
||||
"signature_pad": "^5.0.4",
|
||||
"tseep": "1.2.1",
|
||||
"use-immer": "^0.11.0"
|
||||
"tseep": "1.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@saithodev/semantic-release-gitea": "^2.1.0",
|
||||
"@semantic-release/changelog": "^6.0.3",
|
||||
"@semantic-release/commit-analyzer": "^10.0.1",
|
||||
"@semantic-release/git": "^10.0.1",
|
||||
"@semantic-release/npm": "11.0.0",
|
||||
"@semantic-release/release-notes-generator": "^11.0.4",
|
||||
"@types/crypto-js": "^4.2.2",
|
||||
"@types/file-saver": "2.0.7",
|
||||
"@types/lodash": "4.14.202",
|
||||
@ -75,6 +81,7 @@
|
||||
"@typescript-eslint/eslint-plugin": "^7.0.2",
|
||||
"@typescript-eslint/parser": "^7.0.2",
|
||||
"@vitejs/plugin-react": "^4.2.1",
|
||||
"commit-and-tag-version": "^11.2.2",
|
||||
"eslint": "^8.56.0",
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
"eslint-plugin-react-refresh": "^0.4.5",
|
||||
@ -85,6 +92,7 @@
|
||||
"typescript": "^5.2.2",
|
||||
"vite": "^5.1.4",
|
||||
"vite-plugin-node-polyfills": "^0.22.0",
|
||||
"vite-plugin-zip-pack": "^1.2.4",
|
||||
"vite-tsconfig-paths": "4.3.2"
|
||||
},
|
||||
"lint-staged": {
|
||||
|
58
public/app.webmanifest
Normal file
58
public/app.webmanifest
Normal file
@ -0,0 +1,58 @@
|
||||
{
|
||||
"short_name": "SIGit",
|
||||
"name": "SIGit",
|
||||
"description": "A decentralised document signing tool",
|
||||
"icons": [
|
||||
{
|
||||
"src": "favicon-512x512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "favicon-384x384.png",
|
||||
"sizes": "384x384",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "favicon-256x256.png",
|
||||
"sizes": "256x256",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "favicon-192x192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "favicon-144x144.png",
|
||||
"sizes": "144x144",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "favicon-128x128.png",
|
||||
"sizes": "128x128",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "favicon-96x96.png",
|
||||
"sizes": "96x96",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "favicon-72x72.png",
|
||||
"sizes": "72x72",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "favicon-64x64.png",
|
||||
"sizes": "64x64",
|
||||
"type": "image/png"
|
||||
}
|
||||
],
|
||||
"start_url": "/",
|
||||
"display_override": ["minimal-ui", "standalone"],
|
||||
"display": "minimal-ui",
|
||||
"orientation": "any",
|
||||
"theme_color": "#7d54a3",
|
||||
"background_color": "#ffffff"
|
||||
}
|
BIN
public/favicon-128x128.png
Normal file
BIN
public/favicon-128x128.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 3.3 KiB |
BIN
public/favicon-144x144.png
Normal file
BIN
public/favicon-144x144.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 3.7 KiB |
BIN
public/favicon-192x192.png
Normal file
BIN
public/favicon-192x192.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 5.2 KiB |
BIN
public/favicon-256x256.png
Normal file
BIN
public/favicon-256x256.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 8.0 KiB |
BIN
public/favicon-384x384.png
Normal file
BIN
public/favicon-384x384.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 13 KiB |
BIN
public/favicon-512x512.png
Normal file
BIN
public/favicon-512x512.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 15 KiB |
BIN
public/favicon-64x64.png
Normal file
BIN
public/favicon-64x64.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 1.5 KiB |
BIN
public/favicon-72x72.png
Normal file
BIN
public/favicon-72x72.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 1.7 KiB |
BIN
public/favicon-96x96.png
Normal file
BIN
public/favicon-96x96.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 2.3 KiB |
25
public/favicon.svg
Normal file
25
public/favicon.svg
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg id="Layer_2" data-name="Layer 2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 282.61 282.61">
|
||||
<defs>
|
||||
<style>
|
||||
.cls-1 {
|
||||
fill: #47b17d;
|
||||
}
|
||||
|
||||
.cls-2 {
|
||||
fill: #4c82a3;
|
||||
}
|
||||
|
||||
.cls-3 {
|
||||
fill: #7d54a3;
|
||||
}
|
||||
</style>
|
||||
</defs>
|
||||
<g id="Layer_1-2" data-name="Layer 1" transform="translate(0, 13.775)">
|
||||
<g>
|
||||
<path class="cls-2" d="M181.53,115.06h0c-9.4-36.67-56.77-24.79-121.09-12.57C-3.54,114.64-25.35,19.85,37.72,3.62,46.91,1.26,56.55,0,66.47,0c63.55,0,115.06,51.51,115.06,115.06Z"/>
|
||||
<path class="cls-1" d="M100,140h0c9.4,36.67,56.77,24.79,121.09,12.57,63.98-12.16,85.79,82.64,22.72,98.86-9.19,2.36-18.83,3.62-28.76,3.62-63.55,0-115.06-51.51-115.06-115.06Z"/>
|
||||
<circle class="cls-3" cx="140.77" cy="127.53" r="24.88"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After (image error) Size: 859 B |
20
src/App.tsx
20
src/App.tsx
@ -4,8 +4,6 @@ import { Navigate, Route, Routes } from 'react-router-dom'
|
||||
import { useAppSelector, useAuth } from './hooks'
|
||||
|
||||
import { MainLayout } from './layouts/Main'
|
||||
|
||||
import { appPrivateRoutes, appPublicRoutes } from './routes'
|
||||
import {
|
||||
privateRoutes,
|
||||
publicRoutes,
|
||||
@ -16,7 +14,7 @@ import './App.scss'
|
||||
|
||||
const App = () => {
|
||||
const { checkSession } = useAuth()
|
||||
const authState = useAppSelector((state) => state.auth)
|
||||
const isLoggedIn = useAppSelector((state) => state.auth?.loggedIn)
|
||||
|
||||
useEffect(() => {
|
||||
if (window.location.hostname === '0.0.0.0') {
|
||||
@ -29,19 +27,9 @@ const App = () => {
|
||||
checkSession()
|
||||
}, [checkSession])
|
||||
|
||||
const handleRootRedirect = () => {
|
||||
if (authState.loggedIn) return appPrivateRoutes.homePage
|
||||
|
||||
const callbackPathEncoded = btoa(
|
||||
window.location.href.split(`${window.location.origin}/#`)[1]
|
||||
)
|
||||
|
||||
return `${appPublicRoutes.landingPage}?callbackPath=${callbackPathEncoded}`
|
||||
}
|
||||
|
||||
// Hide route only if loggedIn and r.hiddenWhenLoggedIn are both true
|
||||
const publicRoutesList = recursiveRouteRenderer(publicRoutes, (r) => {
|
||||
return !authState.loggedIn || !r.hiddenWhenLoggedIn
|
||||
return !isLoggedIn || !r.hiddenWhenLoggedIn
|
||||
})
|
||||
|
||||
const privateRouteList = recursiveRouteRenderer(privateRoutes)
|
||||
@ -49,9 +37,9 @@ const App = () => {
|
||||
return (
|
||||
<Routes>
|
||||
<Route element={<MainLayout />}>
|
||||
{authState?.loggedIn && privateRouteList}
|
||||
{publicRoutesList}
|
||||
<Route path="*" element={<Navigate to={handleRootRedirect()} />} />
|
||||
{privateRouteList}
|
||||
<Route path="*" element={<Navigate to={'/'} />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
)
|
||||
|
@ -181,7 +181,7 @@ export const AppBar = () => {
|
||||
onClick={() => {
|
||||
setAnchorElUser(null)
|
||||
|
||||
navigate(appPrivateRoutes.settings)
|
||||
navigate(appPrivateRoutes.profileSettings)
|
||||
}}
|
||||
sx={{
|
||||
justifyContent: 'center'
|
||||
|
24
src/components/ButtonUnderline/index.tsx
Normal file
24
src/components/ButtonUnderline/index.tsx
Normal file
@ -0,0 +1,24 @@
|
||||
import { PropsWithChildren } from 'react'
|
||||
import styles from './style.module.scss'
|
||||
|
||||
interface ButtonUnderlineProps {
|
||||
onClick: (event: React.MouseEvent<HTMLButtonElement>) => void
|
||||
disabled?: boolean | undefined
|
||||
}
|
||||
|
||||
export const ButtonUnderline = ({
|
||||
onClick,
|
||||
disabled = false,
|
||||
children
|
||||
}: PropsWithChildren<ButtonUnderlineProps>) => {
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className={styles.button}
|
||||
disabled={disabled}
|
||||
onClick={onClick}
|
||||
>
|
||||
{children}
|
||||
</button>
|
||||
)
|
||||
}
|
25
src/components/ButtonUnderline/style.module.scss
Normal file
25
src/components/ButtonUnderline/style.module.scss
Normal file
@ -0,0 +1,25 @@
|
||||
@import '../../styles/colors.scss';
|
||||
|
||||
.button {
|
||||
color: $primary-main !important;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
|
||||
width: max-content;
|
||||
margin: 0 auto;
|
||||
|
||||
// Override default styling
|
||||
border: none !important;
|
||||
outline: none !important;
|
||||
|
||||
// Override leaky css in sign page
|
||||
background: transparent !important;
|
||||
|
||||
&:focus,
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
text-decoration-color: inherit;
|
||||
}
|
||||
}
|
117
src/components/DisplaySigit/LocalDraftSigit.tsx
Normal file
117
src/components/DisplaySigit/LocalDraftSigit.tsx
Normal file
@ -0,0 +1,117 @@
|
||||
import { useState } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { Tooltip, Button, Divider } from '@mui/material'
|
||||
import {
|
||||
faCalendar,
|
||||
faFile,
|
||||
faFileCircleExclamation,
|
||||
faPen,
|
||||
faTrash
|
||||
} from '@fortawesome/free-solid-svg-icons'
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
||||
import { SigitDraft, UserRole } from '../../types'
|
||||
import { appPrivateRoutes } from '../../routes'
|
||||
import {
|
||||
formatTimestamp,
|
||||
getSigitDraft,
|
||||
npubToHex,
|
||||
SigitStatus,
|
||||
SignStatus
|
||||
} from '../../utils'
|
||||
import { DisplaySigner } from '../DisplaySigner'
|
||||
import { UserAvatarGroup } from '../UserAvatarGroup'
|
||||
import { getExtensionIconLabel } from '../getExtensionIconLabel'
|
||||
import { useAppSelector, useDidMount } from '../../hooks'
|
||||
import styles from './style.module.scss'
|
||||
|
||||
interface LocalDraftSigitProps {
|
||||
handleDraftDelete: () => void
|
||||
}
|
||||
export const LocalDraftSigit = ({
|
||||
handleDraftDelete
|
||||
}: LocalDraftSigitProps) => {
|
||||
const [draft, setDraft] = useState<SigitDraft>()
|
||||
useDidMount(async () => {
|
||||
// Check if draft exists and add link to direct
|
||||
const draft = await getSigitDraft()
|
||||
if (draft) {
|
||||
setDraft(draft)
|
||||
}
|
||||
})
|
||||
const submittedBy = useAppSelector((state) => state.auth.usersPubkey)
|
||||
|
||||
if (!draft) return null
|
||||
|
||||
const extensions = draft.files.map((f) => f.extension)
|
||||
const isSame = extensions.every((e) => extensions[0] === e)
|
||||
|
||||
return (
|
||||
<div className={styles.itemWrapper}>
|
||||
<Link className={styles.insetLink} to={appPrivateRoutes.create}></Link>
|
||||
<p className={`line-clamp-2 ${styles.title}`}>{draft.title}</p>
|
||||
<div className={styles.users}>
|
||||
{submittedBy && (
|
||||
<DisplaySigner status={SignStatus.Pending} pubkey={submittedBy} />
|
||||
)}
|
||||
{submittedBy && draft.users.length ? (
|
||||
<Divider orientation="vertical" flexItem />
|
||||
) : null}
|
||||
<UserAvatarGroup max={7}>
|
||||
{draft.users.map((user) => {
|
||||
const pubkey = npubToHex(user.pubkey)!
|
||||
return (
|
||||
<DisplaySigner
|
||||
key={pubkey}
|
||||
status={
|
||||
user.role === UserRole.signer
|
||||
? SignStatus.Pending
|
||||
: SignStatus.Viewer
|
||||
}
|
||||
pubkey={pubkey}
|
||||
/>
|
||||
)
|
||||
})}
|
||||
</UserAvatarGroup>
|
||||
</div>
|
||||
<div className={`${styles.details} ${styles.iconLabel}`}>
|
||||
<FontAwesomeIcon icon={faCalendar} />
|
||||
{formatTimestamp(draft.lastUpdated)}
|
||||
</div>
|
||||
<div className={`${styles.details} ${styles.status}`}>
|
||||
<span className={styles.iconLabel}>
|
||||
<FontAwesomeIcon icon={faPen} /> {SigitStatus.LocalDraft}
|
||||
</span>
|
||||
{extensions.length > 0 ? (
|
||||
<span className={styles.iconLabel}>
|
||||
{!isSame ? (
|
||||
<>
|
||||
<FontAwesomeIcon icon={faFile} /> Multiple File Types
|
||||
</>
|
||||
) : (
|
||||
getExtensionIconLabel(extensions[0])
|
||||
)}
|
||||
</span>
|
||||
) : (
|
||||
<>
|
||||
<FontAwesomeIcon icon={faFileCircleExclamation} /> —
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<div className={styles.itemActions}>
|
||||
<Tooltip title="Delete" arrow placement="top" disableInteractive>
|
||||
<Button
|
||||
onClick={handleDraftDelete}
|
||||
sx={{
|
||||
color: 'var(--primary-main)',
|
||||
minWidth: '34px',
|
||||
padding: '10px'
|
||||
}}
|
||||
variant={'text'}
|
||||
>
|
||||
<FontAwesomeIcon icon={faTrash} />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
@ -112,32 +112,37 @@ export const DisplaySigit = ({
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<div className={styles.itemActions}>
|
||||
<Tooltip title="Duplicate" arrow placement="top" disableInteractive>
|
||||
<Button
|
||||
sx={{
|
||||
color: 'var(--primary-main)',
|
||||
minWidth: '34px',
|
||||
padding: '10px'
|
||||
}}
|
||||
variant={'text'}
|
||||
>
|
||||
<FontAwesomeIcon icon={faCopy} />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
<Tooltip title="Archive" arrow placement="top" disableInteractive>
|
||||
<Button
|
||||
sx={{
|
||||
color: 'var(--primary-main)',
|
||||
minWidth: '34px',
|
||||
padding: '10px'
|
||||
}}
|
||||
variant={'text'}
|
||||
>
|
||||
<FontAwesomeIcon icon={faArchive} />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
</div>
|
||||
{
|
||||
// TODO: enable buttons once feature is ready
|
||||
false && (
|
||||
<div className={styles.itemActions}>
|
||||
<Tooltip title="Duplicate" arrow placement="top" disableInteractive>
|
||||
<Button
|
||||
sx={{
|
||||
color: 'var(--primary-main)',
|
||||
minWidth: '34px',
|
||||
padding: '10px'
|
||||
}}
|
||||
variant={'text'}
|
||||
>
|
||||
<FontAwesomeIcon icon={faCopy} />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
<Tooltip title="Archive" arrow placement="top" disableInteractive>
|
||||
<Button
|
||||
sx={{
|
||||
color: 'var(--primary-main)',
|
||||
minWidth: '34px',
|
||||
padding: '10px'
|
||||
}}
|
||||
variant={'text'}
|
||||
>
|
||||
<FontAwesomeIcon icon={faArchive} />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ import { FONT_SIZE, FONT_TYPE, inPx } from '../../utils/pdf'
|
||||
import { useScale } from '../../hooks/useScale'
|
||||
import { AvatarIconButton } from '../UserAvatarIconButton'
|
||||
import { UserAvatar } from '../UserAvatar'
|
||||
import { Updater } from 'use-immer'
|
||||
import { FileItem } from './internal/FileItem'
|
||||
import { FileDivider } from '../FileDivider'
|
||||
import { Counterpart } from './internal/Counterpart'
|
||||
@ -28,6 +27,7 @@ const MINIMUM_RECT_SIZE = {
|
||||
height: 10
|
||||
} as const
|
||||
import { NDKUserProfile } from '@nostr-dev-kit/ndk'
|
||||
import _ from 'lodash'
|
||||
|
||||
const DEFAULT_START_SIZE = {
|
||||
width: 140,
|
||||
@ -45,7 +45,7 @@ interface DrawPdfFieldsProps {
|
||||
users: User[]
|
||||
userProfiles: { [key: string]: NDKUserProfile }
|
||||
sigitFiles: SigitFile[]
|
||||
updateSigitFiles: Updater<SigitFile[]>
|
||||
setSigitFiles: React.Dispatch<React.SetStateAction<SigitFile[]>>
|
||||
selectedTool?: DrawTool
|
||||
}
|
||||
|
||||
@ -53,11 +53,10 @@ export const DrawPDFFields = ({
|
||||
selectedTool,
|
||||
userProfiles,
|
||||
sigitFiles,
|
||||
updateSigitFiles,
|
||||
setSigitFiles,
|
||||
users
|
||||
}: DrawPdfFieldsProps) => {
|
||||
const { to, from } = useScale()
|
||||
|
||||
const signers = users.filter((u) => u.role === UserRole.signer)
|
||||
const defaultSignerNpub = signers.length ? hexToNpub(signers[0].pubkey) : ''
|
||||
const [lastSigner, setLastSigner] = useState(defaultSignerNpub)
|
||||
@ -354,8 +353,10 @@ export const DrawPDFFields = ({
|
||||
) => {
|
||||
event.stopPropagation()
|
||||
|
||||
updateSigitFiles((draft) => {
|
||||
draft[fileIndex]?.pages![pageIndex]?.drawnFields?.splice(fieldIndex, 1)
|
||||
setSigitFiles((prev) => {
|
||||
const clone = _.cloneDeep(prev)
|
||||
clone[fileIndex]?.pages![pageIndex]?.drawnFields?.splice(fieldIndex, 1)
|
||||
return clone
|
||||
})
|
||||
}
|
||||
|
||||
@ -416,22 +417,28 @@ export const DrawPDFFields = ({
|
||||
|
||||
// Add new drawn field to the files
|
||||
if (mouseState.clicked) {
|
||||
updateSigitFiles((draft) => {
|
||||
draft[fileIndex].pages![pageIndex].drawnFields.push(field)
|
||||
setSigitFiles((prev) => {
|
||||
const clone = _.cloneDeep(prev)
|
||||
clone[fileIndex].pages![pageIndex].drawnFields.push(field)
|
||||
return clone
|
||||
})
|
||||
}
|
||||
|
||||
// Move
|
||||
if (mouseState.dragging) {
|
||||
updateSigitFiles((draft) => {
|
||||
draft[fileIndex].pages![pageIndex].drawnFields[fieldIndex!] = field
|
||||
setSigitFiles((prev) => {
|
||||
const clone = _.cloneDeep(prev)
|
||||
clone[fileIndex].pages![pageIndex].drawnFields[fieldIndex!] = field
|
||||
return clone
|
||||
})
|
||||
}
|
||||
|
||||
// Resize
|
||||
if (mouseState.resizing) {
|
||||
updateSigitFiles((draft) => {
|
||||
draft[fileIndex].pages![pageIndex].drawnFields[fieldIndex!] = field
|
||||
setSigitFiles((prev) => {
|
||||
const clone = _.cloneDeep(prev)
|
||||
clone[fileIndex].pages![pageIndex].drawnFields[fieldIndex!] = field
|
||||
return clone
|
||||
})
|
||||
}
|
||||
|
||||
@ -446,7 +453,7 @@ export const DrawPDFFields = ({
|
||||
mouseState.clicked,
|
||||
mouseState.dragging,
|
||||
mouseState.resizing,
|
||||
updateSigitFiles
|
||||
setSigitFiles
|
||||
])
|
||||
|
||||
/**
|
||||
|
@ -1,17 +1,22 @@
|
||||
import React from 'react'
|
||||
import { Button, Menu, MenuItem } from '@mui/material'
|
||||
import PopupState, { bindTrigger, bindMenu } from 'material-ui-popup-state'
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
||||
import {
|
||||
faCheck,
|
||||
faLock,
|
||||
faTriangleExclamation
|
||||
} from '@fortawesome/free-solid-svg-icons'
|
||||
import { CurrentUserFile } from '../../types/file.ts'
|
||||
import styles from './style.module.scss'
|
||||
import { Button, Menu, MenuItem } from '@mui/material'
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
||||
import { faCheck } from '@fortawesome/free-solid-svg-icons'
|
||||
import PopupState, { bindTrigger, bindMenu } from 'material-ui-popup-state'
|
||||
import React from 'react'
|
||||
|
||||
interface FileListProps {
|
||||
files: CurrentUserFile[]
|
||||
currentFile: CurrentUserFile
|
||||
setCurrentFile: (file: CurrentUserFile) => void
|
||||
handleExport: () => void
|
||||
handleExport?: () => void
|
||||
handleEncryptedExport?: () => void
|
||||
reBroadcastSigit?: () => void
|
||||
}
|
||||
|
||||
const FileList = ({
|
||||
@ -19,7 +24,8 @@ const FileList = ({
|
||||
currentFile,
|
||||
setCurrentFile,
|
||||
handleExport,
|
||||
handleEncryptedExport
|
||||
handleEncryptedExport,
|
||||
reBroadcastSigit
|
||||
}: FileListProps) => {
|
||||
const isActive = (file: CurrentUserFile) => file.id === currentFile.id
|
||||
return (
|
||||
@ -45,34 +51,54 @@ const FileList = ({
|
||||
))}
|
||||
</ul>
|
||||
|
||||
<PopupState variant="popover" popupId="download-popup-menu">
|
||||
{(popupState) => (
|
||||
<React.Fragment>
|
||||
<Button variant="contained" {...bindTrigger(popupState)}>
|
||||
Export files
|
||||
</Button>
|
||||
<Menu {...bindMenu(popupState)}>
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
popupState.close
|
||||
handleExport()
|
||||
}}
|
||||
>
|
||||
Export Files
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
popupState.close
|
||||
typeof handleEncryptedExport === 'function' &&
|
||||
handleEncryptedExport()
|
||||
}}
|
||||
>
|
||||
Export Encrypted Files
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
</React.Fragment>
|
||||
)}
|
||||
</PopupState>
|
||||
{(typeof handleExport === 'function' ||
|
||||
typeof handleEncryptedExport === 'function') && (
|
||||
<PopupState variant="popover" popupId="download-popup-menu">
|
||||
{(popupState) => (
|
||||
<React.Fragment>
|
||||
<Button variant="contained" {...bindTrigger(popupState)}>
|
||||
Export files
|
||||
</Button>
|
||||
<Menu {...bindMenu(popupState)}>
|
||||
{typeof handleEncryptedExport === 'function' && (
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
popupState.close
|
||||
handleEncryptedExport()
|
||||
}}
|
||||
>
|
||||
<FontAwesomeIcon
|
||||
color={'var(--mui-palette-primary-main)'}
|
||||
icon={faLock}
|
||||
/>
|
||||
ENCRYPTED
|
||||
</MenuItem>
|
||||
)}
|
||||
{typeof handleExport === 'function' && (
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
popupState.close
|
||||
handleExport()
|
||||
}}
|
||||
>
|
||||
<FontAwesomeIcon
|
||||
color={'var(--mui-palette-primary-main)'}
|
||||
icon={faTriangleExclamation}
|
||||
/>
|
||||
UNENCRYPTED
|
||||
</MenuItem>
|
||||
)}
|
||||
</Menu>
|
||||
</React.Fragment>
|
||||
)}
|
||||
</PopupState>
|
||||
)}
|
||||
|
||||
{typeof reBroadcastSigit === 'function' && (
|
||||
<Button variant="contained" onClick={reBroadcastSigit}>
|
||||
Re-Broadcast
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
@ -8,15 +8,19 @@ import {
|
||||
import React, { useState } from 'react'
|
||||
import { MarkInput } from '../MarkTypeStrategy/MarkInput.tsx'
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
||||
import { faCheck } from '@fortawesome/free-solid-svg-icons'
|
||||
import { faCheck, faDownload } from '@fortawesome/free-solid-svg-icons'
|
||||
import { Button } from '@mui/material'
|
||||
import styles from './style.module.scss'
|
||||
import { ButtonUnderline } from '../ButtonUnderline/index.tsx'
|
||||
|
||||
interface MarkFormFieldProps {
|
||||
currentUserMarks: CurrentUserMark[]
|
||||
handleCurrentUserMarkChange: (mark: CurrentUserMark) => void
|
||||
handleSelectedMarkValueChange: (value: string) => void
|
||||
handleSubmit: (event: React.MouseEvent<HTMLButtonElement>) => void
|
||||
handleSubmit: (
|
||||
event: React.MouseEvent<HTMLButtonElement>,
|
||||
type: 'online' | 'offline'
|
||||
) => void
|
||||
selectedMark: CurrentUserMark | null
|
||||
selectedMarkValue: string
|
||||
}
|
||||
@ -73,11 +77,11 @@ const MarkFormField = ({
|
||||
setComplete(true)
|
||||
}
|
||||
|
||||
const handleSignAndComplete = (
|
||||
event: React.MouseEvent<HTMLButtonElement>
|
||||
) => {
|
||||
handleSubmit(event)
|
||||
}
|
||||
const handleSignAndComplete =
|
||||
(type: 'online' | 'offline') =>
|
||||
(event: React.MouseEvent<HTMLButtonElement>) => {
|
||||
handleSubmit(event, type)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
@ -129,18 +133,28 @@ const MarkFormField = ({
|
||||
</div>
|
||||
</form>
|
||||
) : (
|
||||
<div className={styles.actionsBottom}>
|
||||
<Button
|
||||
onClick={handleSignAndComplete}
|
||||
className={[styles.submitButton, styles.completeButton].join(
|
||||
' '
|
||||
)}
|
||||
<>
|
||||
<div className={styles.actionsBottom}>
|
||||
<Button
|
||||
onClick={handleSignAndComplete('online')}
|
||||
className={[
|
||||
styles.submitButton,
|
||||
styles.completeButton
|
||||
].join(' ')}
|
||||
disabled={!isReadyToSign()}
|
||||
autoFocus
|
||||
>
|
||||
SIGN AND BROADCAST
|
||||
</Button>
|
||||
</div>
|
||||
<ButtonUnderline
|
||||
onClick={handleSignAndComplete('offline')}
|
||||
disabled={!isReadyToSign()}
|
||||
autoFocus
|
||||
>
|
||||
SIGN AND COMPLETE
|
||||
</Button>
|
||||
</div>
|
||||
<FontAwesomeIcon icon={faDownload} />
|
||||
Sign and export locally instead
|
||||
</ButtonUnderline>
|
||||
</>
|
||||
)}
|
||||
|
||||
<div className={styles.footerContainer}>
|
||||
|
24
src/components/MarkTypeStrategy/DateTime/Input.tsx
Normal file
24
src/components/MarkTypeStrategy/DateTime/Input.tsx
Normal file
@ -0,0 +1,24 @@
|
||||
import { MarkInputProps } from '../MarkStrategy'
|
||||
import styles from '../../MarkFormField/style.module.scss'
|
||||
import { useEffect, useRef } from 'react'
|
||||
|
||||
export const MarkInputDateTime = ({ handler, placeholder }: MarkInputProps) => {
|
||||
const ref = useRef<HTMLInputElement>(null)
|
||||
useEffect(() => {
|
||||
if (ref.current) {
|
||||
const date = new Date()
|
||||
ref.current.value = date.toISOString().slice(0, 16)
|
||||
handler(date.toUTCString())
|
||||
}
|
||||
}, [handler])
|
||||
return (
|
||||
<input
|
||||
type="datetime-local"
|
||||
ref={ref}
|
||||
className={styles.input}
|
||||
placeholder={placeholder}
|
||||
readOnly={true}
|
||||
disabled={true}
|
||||
/>
|
||||
)
|
||||
}
|
7
src/components/MarkTypeStrategy/DateTime/index.tsx
Normal file
7
src/components/MarkTypeStrategy/DateTime/index.tsx
Normal file
@ -0,0 +1,7 @@
|
||||
import { MarkStrategy } from '../MarkStrategy'
|
||||
import { MarkInputDateTime } from './Input'
|
||||
|
||||
export const DateTimeStrategy: MarkStrategy = {
|
||||
input: MarkInputDateTime,
|
||||
render: ({ value }) => <>{value}</>
|
||||
}
|
20
src/components/MarkTypeStrategy/FullName/Input.tsx
Normal file
20
src/components/MarkTypeStrategy/FullName/Input.tsx
Normal file
@ -0,0 +1,20 @@
|
||||
import { useDidMount } from '../../../hooks'
|
||||
import { useLocalStorage } from '../../../hooks/useLocalStorage'
|
||||
import { MarkInputProps } from '../MarkStrategy'
|
||||
import { MarkInputText } from '../Text/Input'
|
||||
|
||||
export const MarkInputFullName = (props: MarkInputProps) => {
|
||||
const [fullName, setFullName] = useLocalStorage('mark-fullname', '')
|
||||
useDidMount(() => {
|
||||
props.handler(fullName)
|
||||
})
|
||||
return MarkInputText({
|
||||
...props,
|
||||
placeholder: 'Full Name',
|
||||
value: fullName,
|
||||
handler: (value) => {
|
||||
setFullName(value)
|
||||
props.handler(value)
|
||||
}
|
||||
})
|
||||
}
|
7
src/components/MarkTypeStrategy/FullName/index.tsx
Normal file
7
src/components/MarkTypeStrategy/FullName/index.tsx
Normal file
@ -0,0 +1,7 @@
|
||||
import { MarkStrategy } from '../MarkStrategy'
|
||||
import { MarkInputFullName } from './Input'
|
||||
|
||||
export const FullNameStrategy: MarkStrategy = {
|
||||
input: MarkInputFullName,
|
||||
render: ({ value }) => <>{value}</>
|
||||
}
|
20
src/components/MarkTypeStrategy/JobTitle/Input.tsx
Normal file
20
src/components/MarkTypeStrategy/JobTitle/Input.tsx
Normal file
@ -0,0 +1,20 @@
|
||||
import { useDidMount } from '../../../hooks'
|
||||
import { useLocalStorage } from '../../../hooks/useLocalStorage'
|
||||
import { MarkInputProps } from '../MarkStrategy'
|
||||
import { MarkInputText } from '../Text/Input'
|
||||
|
||||
export const MarkInputJobTitle = (props: MarkInputProps) => {
|
||||
const [jobTitle, setjobTitle] = useLocalStorage('mark-jobtitle', '')
|
||||
useDidMount(() => {
|
||||
props.handler(jobTitle)
|
||||
})
|
||||
return MarkInputText({
|
||||
...props,
|
||||
placeholder: 'Job Title',
|
||||
value: jobTitle,
|
||||
handler: (value) => {
|
||||
setjobTitle(value)
|
||||
props.handler(value)
|
||||
}
|
||||
})
|
||||
}
|
7
src/components/MarkTypeStrategy/JobTitle/index.tsx
Normal file
7
src/components/MarkTypeStrategy/JobTitle/index.tsx
Normal file
@ -0,0 +1,7 @@
|
||||
import { MarkStrategy } from '../MarkStrategy'
|
||||
import { MarkInputJobTitle } from './Input'
|
||||
|
||||
export const JobTitleStrategy: MarkStrategy = {
|
||||
input: MarkInputJobTitle,
|
||||
render: ({ value }) => <>{value}</>
|
||||
}
|
@ -2,6 +2,9 @@ import { MarkType } from '../../types/drawing'
|
||||
import { CurrentUserMark, Mark } from '../../types/mark'
|
||||
import { TextStrategy } from './Text'
|
||||
import { SignatureStrategy } from './Signature'
|
||||
import { FullNameStrategy } from './FullName'
|
||||
import { JobTitleStrategy } from './JobTitle'
|
||||
import { DateTimeStrategy } from './DateTime'
|
||||
|
||||
export interface MarkInputProps {
|
||||
value: string
|
||||
@ -28,5 +31,8 @@ export type MarkStrategies = {
|
||||
|
||||
export const MARK_TYPE_CONFIG: MarkStrategies = {
|
||||
[MarkType.TEXT]: TextStrategy,
|
||||
[MarkType.SIGNATURE]: SignatureStrategy
|
||||
[MarkType.SIGNATURE]: SignatureStrategy,
|
||||
[MarkType.FULLNAME]: FullNameStrategy,
|
||||
[MarkType.JOBTITLE]: JobTitleStrategy,
|
||||
[MarkType.DATETIME]: DateTimeStrategy
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ import {
|
||||
decryptArrayBuffer,
|
||||
encryptArrayBuffer,
|
||||
getHash,
|
||||
isOnline,
|
||||
uploadToFileStorage
|
||||
} from '../../../utils'
|
||||
import { MarkStrategy } from '../MarkStrategy'
|
||||
@ -37,21 +36,17 @@ export const SignatureStrategy: MarkStrategy = {
|
||||
// Create the encrypted json file from array buffer and hash
|
||||
const file = new File([encryptedArrayBuffer], `${hash}.json`)
|
||||
|
||||
if (await isOnline()) {
|
||||
try {
|
||||
const url = await uploadToFileStorage(file)
|
||||
console.info(`${file.name} uploaded to file storage`)
|
||||
return url
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
console.error(
|
||||
`Error occurred in uploading file ${file.name}`,
|
||||
error.message
|
||||
)
|
||||
}
|
||||
try {
|
||||
const url = await uploadToFileStorage(file)
|
||||
console.info(`${file.name} uploaded to file storage`)
|
||||
return url
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
console.error(
|
||||
`Error occurred in uploading file ${file.name}`,
|
||||
error.message
|
||||
)
|
||||
}
|
||||
} else {
|
||||
// TOOD: offline
|
||||
}
|
||||
|
||||
return value
|
||||
@ -89,7 +84,6 @@ export const SignatureStrategy: MarkStrategy = {
|
||||
return json
|
||||
}
|
||||
|
||||
// TOOD: offline
|
||||
return value
|
||||
}
|
||||
}
|
||||
|
@ -24,9 +24,8 @@ import {
|
||||
interface PdfMarkingProps {
|
||||
currentUserMarks: CurrentUserMark[]
|
||||
files: CurrentUserFile[]
|
||||
handleExport: () => void
|
||||
handleEncryptedExport: () => void
|
||||
handleSign: () => void
|
||||
handleSignOffline: () => void
|
||||
meta: Meta | null
|
||||
otherUserMarks: Mark[]
|
||||
setCurrentUserMarks: (currentUserMarks: CurrentUserMark[]) => void
|
||||
@ -39,18 +38,16 @@ interface PdfMarkingProps {
|
||||
* @param props
|
||||
* @constructor
|
||||
*/
|
||||
const PdfMarking = (props: PdfMarkingProps) => {
|
||||
const {
|
||||
files,
|
||||
currentUserMarks,
|
||||
setCurrentUserMarks,
|
||||
setUpdatedMarks,
|
||||
handleExport,
|
||||
handleEncryptedExport,
|
||||
handleSign,
|
||||
meta,
|
||||
otherUserMarks
|
||||
} = props
|
||||
const PdfMarking = ({
|
||||
files,
|
||||
currentUserMarks,
|
||||
setCurrentUserMarks,
|
||||
setUpdatedMarks,
|
||||
handleSign,
|
||||
handleSignOffline,
|
||||
meta,
|
||||
otherUserMarks
|
||||
}: PdfMarkingProps) => {
|
||||
const [selectedMark, setSelectedMark] = useState<CurrentUserMark | null>(null)
|
||||
const [selectedMarkValue, setSelectedMarkValue] = useState<string>('')
|
||||
const [currentFile, setCurrentFile] = useState<CurrentUserFile | null>(null)
|
||||
@ -99,7 +96,10 @@ const PdfMarking = (props: PdfMarkingProps) => {
|
||||
/**
|
||||
* Sign and Complete
|
||||
*/
|
||||
const handleSubmit = (event: React.MouseEvent<HTMLButtonElement>) => {
|
||||
const handleSubmit = (
|
||||
event: React.MouseEvent<HTMLButtonElement>,
|
||||
type: 'online' | 'offline'
|
||||
) => {
|
||||
event.preventDefault()
|
||||
if (selectedMarkValue && selectedMark) {
|
||||
const updatedMark: CurrentUserMark = getUpdatedMark(
|
||||
@ -117,16 +117,10 @@ const PdfMarking = (props: PdfMarkingProps) => {
|
||||
setUpdatedMarks(updatedMark.mark)
|
||||
}
|
||||
|
||||
handleSign()
|
||||
if (type === 'online') handleSign()
|
||||
else if (type === 'offline') handleSignOffline()
|
||||
}
|
||||
|
||||
// const updateCurrentUserMarkValues = () => {
|
||||
// const updatedMark: CurrentUserMark = getUpdatedMark(selectedMark!, selectedMarkValue)
|
||||
// const updatedCurrentUserMarks = updateCurrentUserMarks(currentUserMarks, updatedMark)
|
||||
// setSelectedMarkValue(EMPTY)
|
||||
// setCurrentUserMarks(updatedCurrentUserMarks)
|
||||
// }
|
||||
|
||||
const handleChange = (value: string) => {
|
||||
setSelectedMarkValue(value)
|
||||
}
|
||||
@ -142,8 +136,6 @@ const PdfMarking = (props: PdfMarkingProps) => {
|
||||
files={files}
|
||||
currentFile={currentFile}
|
||||
setCurrentFile={setCurrentFile}
|
||||
handleExport={handleExport}
|
||||
handleEncryptedExport={handleEncryptedExport}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
@ -8,6 +8,4 @@
|
||||
position: absolute;
|
||||
z-index: 40;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
@ -56,8 +56,7 @@ export const useAuth = () => {
|
||||
* method will be chosen (extension or keys)
|
||||
*
|
||||
* @param pubkey of the user trying to login
|
||||
* @returns url to redirect if authentication successfull
|
||||
* or error if otherwise
|
||||
* @returns url to redirect if user has no relays set
|
||||
*/
|
||||
const authAndGetMetadataAndRelaysMap = useCallback(
|
||||
async (pubkey: string) => {
|
||||
@ -108,7 +107,7 @@ export const useAuth = () => {
|
||||
dispatch(setRelayMapAction(relayMap))
|
||||
}
|
||||
|
||||
return appPrivateRoutes.homePage
|
||||
return
|
||||
},
|
||||
[
|
||||
dispatch,
|
||||
|
72
src/hooks/useLocalStorage.ts
Normal file
72
src/hooks/useLocalStorage.ts
Normal file
@ -0,0 +1,72 @@
|
||||
import React, { useMemo } from 'react'
|
||||
import {
|
||||
getLocalStorageItem,
|
||||
mergeWithInitialValue,
|
||||
removeLocalStorageItem,
|
||||
setLocalStorageItem
|
||||
} from '../utils'
|
||||
|
||||
/**
|
||||
* Subscribe to the Browser's storage event. Get the new value if any of the tabs changes it.
|
||||
* @param callback - function to be called when the storage event is triggered
|
||||
* @returns clean up function
|
||||
*/
|
||||
const useLocalStorageSubscribe = (callback: () => void) => {
|
||||
window.addEventListener('storage', callback)
|
||||
return () => window.removeEventListener('storage', callback)
|
||||
}
|
||||
|
||||
export function useLocalStorage<T>(
|
||||
key: string,
|
||||
initialValue: T
|
||||
): [T, React.Dispatch<React.SetStateAction<T>>] {
|
||||
const getSnapshot = () => {
|
||||
// Get the stored value
|
||||
const storedValue = getLocalStorageItem(key, initialValue)
|
||||
|
||||
// Parse the value
|
||||
const parsedStoredValue = JSON.parse(storedValue)
|
||||
|
||||
// Merge the default and the stored in case some of the required fields are missing
|
||||
return JSON.stringify(
|
||||
mergeWithInitialValue(parsedStoredValue, initialValue)
|
||||
)
|
||||
}
|
||||
|
||||
// https://react.dev/reference/react/useSyncExternalStore
|
||||
// Returns the snapshot of the data and subscribes to the storage event
|
||||
const data = React.useSyncExternalStore(useLocalStorageSubscribe, getSnapshot)
|
||||
|
||||
// Takes the value or a function that returns the value and updates the local storage
|
||||
const setState: React.Dispatch<React.SetStateAction<T>> = React.useCallback(
|
||||
(v: React.SetStateAction<T>) => {
|
||||
try {
|
||||
const nextState =
|
||||
typeof v === 'function'
|
||||
? (v as (prevState: T) => T)(JSON.parse(data))
|
||||
: v
|
||||
|
||||
if (nextState === undefined || nextState === null) {
|
||||
removeLocalStorageItem(key)
|
||||
} else {
|
||||
setLocalStorageItem(key, JSON.stringify(nextState))
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e)
|
||||
}
|
||||
},
|
||||
[data, key]
|
||||
)
|
||||
|
||||
React.useEffect(() => {
|
||||
// Set local storage only when it's empty
|
||||
const data = window.localStorage.getItem(key)
|
||||
if (data === null) {
|
||||
setLocalStorageItem(key, JSON.stringify(initialValue))
|
||||
}
|
||||
}, [key, initialValue])
|
||||
|
||||
const memoized = useMemo(() => JSON.parse(data) as T, [data])
|
||||
|
||||
return [memoized, setState]
|
||||
}
|
@ -12,7 +12,9 @@ import {
|
||||
import _ from 'lodash'
|
||||
import {
|
||||
Event,
|
||||
finalizeEvent,
|
||||
generateSecretKey,
|
||||
getEventHash,
|
||||
getPublicKey,
|
||||
kinds,
|
||||
UnsignedEvent
|
||||
@ -40,17 +42,21 @@ import {
|
||||
getDTagForUserAppData,
|
||||
getUserAppDataFromBlossom,
|
||||
hexToNpub,
|
||||
nip44Encrypt,
|
||||
parseJson,
|
||||
randomTimeUpTo2DaysInThePast,
|
||||
SIGIT_RELAY,
|
||||
unixNow,
|
||||
uploadUserAppDataToBlossom
|
||||
} from '../utils'
|
||||
import { SendDMError, SendDMErrorType } from '../types/errors/SendDMError'
|
||||
|
||||
export const useNDK = () => {
|
||||
const dispatch = useAppDispatch()
|
||||
const {
|
||||
ndk,
|
||||
fetchEvent,
|
||||
fetchEventFromUserRelays,
|
||||
fetchEventsFromUserRelays,
|
||||
publish,
|
||||
getNDKRelayList
|
||||
@ -503,10 +509,139 @@ export const useNDK = () => {
|
||||
[ndk, usersPubkey, getNDKRelayList]
|
||||
)
|
||||
|
||||
/**
|
||||
* Modified {@link UnsignedEvent Unsigned Event} that includes an id
|
||||
*
|
||||
* Fields id and created_at are required.
|
||||
* @see {@link UnsignedEvent}
|
||||
* @see {@link https://github.com/nostr-protocol/nips/blob/master/17.md#direct-message-kind}
|
||||
*/
|
||||
type UnsignedEventWithId = UnsignedEvent & {
|
||||
id?: string
|
||||
}
|
||||
const sendPrivateDirectMessage = useCallback(
|
||||
async (message: string, receiver: string, subject?: string) => {
|
||||
if (!receiver) throw new SendDMError(SendDMErrorType.MISSING_RECIEVER)
|
||||
|
||||
// Get the direct message preferred relays list
|
||||
// https://github.com/nostr-protocol/nips/blob/master/17.md#publishing
|
||||
const preferredRelaysListEvent = await fetchEventFromUserRelays(
|
||||
{
|
||||
kinds: [NDKKind.DirectMessageReceiveRelayList],
|
||||
authors: [receiver]
|
||||
},
|
||||
receiver,
|
||||
UserRelaysType.Read
|
||||
)
|
||||
|
||||
const isRelayTag = (tag: string[]): boolean => tag[0] === 'relay'
|
||||
const finalRelaysList: string[] = []
|
||||
if (preferredRelaysListEvent) {
|
||||
const preferredRelaysList = preferredRelaysListEvent.tags
|
||||
.filter((t) => isRelayTag(t))
|
||||
.map((t) => t[1])
|
||||
|
||||
finalRelaysList.push(...preferredRelaysList)
|
||||
}
|
||||
|
||||
if (!finalRelaysList.length) {
|
||||
// Get receiver's read relay list
|
||||
const ndkRelayList = await getNDKRelayList(receiver).catch((err) => {
|
||||
// Log an error if retrieving relay list metadata fails
|
||||
console.log(
|
||||
`An error occurred while finding relay list metadata for ${hexToNpub(receiver)}`,
|
||||
err
|
||||
)
|
||||
return null
|
||||
})
|
||||
if (ndkRelayList?.readRelayUrls) {
|
||||
finalRelaysList.push(...ndkRelayList.readRelayUrls)
|
||||
}
|
||||
}
|
||||
|
||||
if (!finalRelaysList.includes(SIGIT_RELAY)) {
|
||||
finalRelaysList.push(SIGIT_RELAY)
|
||||
}
|
||||
|
||||
// Generate "sender"
|
||||
const senderSecret = generateSecretKey()
|
||||
const senderPubkey = getPublicKey(senderSecret)
|
||||
|
||||
// Prepare tags for the message
|
||||
const tags: string[][] = [['p', receiver]]
|
||||
|
||||
// Conversation title
|
||||
if (subject) tags.push(['subject', subject])
|
||||
|
||||
// Create private DM event containing the message and relevant metadata
|
||||
// TODO: kinds.PrivateDirectMessage (unavailabe in nostr-tools 10/10/2024 at v2.7.0)
|
||||
const dm: UnsignedEventWithId = {
|
||||
pubkey: senderPubkey,
|
||||
created_at: unixNow(),
|
||||
kind: 14,
|
||||
tags,
|
||||
content: message
|
||||
}
|
||||
|
||||
// Calculate the hash based on the UnverifiedEvent
|
||||
dm.id = getEventHash(dm)
|
||||
|
||||
// Encrypt the private dm using the sender secret and the receiver's public key
|
||||
const encryptedDm = nip44Encrypt(dm, senderSecret, receiver)
|
||||
if (!encryptedDm) {
|
||||
throw new SendDMError(SendDMErrorType.ENCRYPTION_FAILED, {
|
||||
context: {
|
||||
receiver,
|
||||
message,
|
||||
kind: dm.kind
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Seal the message
|
||||
// TODO: kinds.Seal (unavailabe in nostr-tools 10/10/2024 at v2.7.0)
|
||||
const sealedMessage: UnsignedEvent = {
|
||||
kind: 13, // seal
|
||||
pubkey: senderPubkey,
|
||||
content: encryptedDm,
|
||||
created_at: randomTimeUpTo2DaysInThePast(),
|
||||
tags: [] // no tags
|
||||
}
|
||||
|
||||
// Finalize and sign the sealed event
|
||||
const finalizedSeal = finalizeEvent(sealedMessage, senderSecret)
|
||||
|
||||
// Encrypt the seal and gift wrap
|
||||
const finalizedGiftWrap = createWrap(finalizedSeal, receiver)
|
||||
|
||||
const ndkEvent = new NDKEvent(ndk, finalizedGiftWrap)
|
||||
|
||||
// Publish the finalized gift wrap event (the encrypted DM) to the relays
|
||||
const publishedOnRelays = await ndkEvent.publish(
|
||||
NDKRelaySet.fromRelayUrls(finalRelaysList, ndk, true)
|
||||
)
|
||||
|
||||
// Handle cases where publishing to the relays failed
|
||||
if (publishedOnRelays.size === 0) {
|
||||
throw new SendDMError(SendDMErrorType.ENCRYPTION_FAILED, {
|
||||
context: {
|
||||
receiver,
|
||||
count: publishedOnRelays.size
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Return true indicating that the DM was successfully sent
|
||||
return true
|
||||
},
|
||||
[fetchEventFromUserRelays, getNDKRelayList, ndk]
|
||||
)
|
||||
|
||||
return {
|
||||
getUsersAppData,
|
||||
subscribeForSigits,
|
||||
updateUsersAppData,
|
||||
sendNotification
|
||||
sendNotification,
|
||||
sendPrivateDirectMessage
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,5 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import {
|
||||
CreateSignatureEventContent,
|
||||
DocSignatureEvent,
|
||||
Meta,
|
||||
SignedEventContent,
|
||||
OpenTimestamp
|
||||
} from '../types'
|
||||
import { DocSignatureEvent, Meta, SignedEventContent, FlatMeta } from '../types'
|
||||
import { Mark } from '../types/mark'
|
||||
import {
|
||||
fromUnixTimestamp,
|
||||
@ -17,53 +11,11 @@ import {
|
||||
} from '../utils'
|
||||
import { toast } from 'react-toastify'
|
||||
import { verifyEvent } from 'nostr-tools'
|
||||
import { Event } from 'nostr-tools'
|
||||
import store from '../store/store'
|
||||
import { NostrController } from '../controllers'
|
||||
import { MetaParseError } from '../types/errors/MetaParseError'
|
||||
import { MARK_TYPE_CONFIG } from '../components/MarkTypeStrategy/MarkStrategy'
|
||||
|
||||
/**
|
||||
* Flattened interface that combines properties `Meta`, `CreateSignatureEventContent`,
|
||||
* and `Event` (event's fields are made optional and pubkey and created_at replaced with our versions)
|
||||
*/
|
||||
export interface FlatMeta
|
||||
extends Meta,
|
||||
CreateSignatureEventContent,
|
||||
Partial<Omit<Event, 'pubkey' | 'created_at'>> {
|
||||
// Remove pubkey and use submittedBy as `npub1${string}`
|
||||
submittedBy?: `npub1${string}`
|
||||
|
||||
// Optional field only present on exported sigits
|
||||
// Exporting adds user's pubkey
|
||||
exportedBy?: `npub1${string}`
|
||||
|
||||
// Remove created_at and replace with createdAt
|
||||
createdAt?: number
|
||||
|
||||
// Validated create signature event
|
||||
isValid: boolean
|
||||
|
||||
// Decryption
|
||||
encryptionKey: string | undefined
|
||||
|
||||
// Parsed Document Signatures
|
||||
parsedSignatureEvents: {
|
||||
[signer: `npub1${string}`]: DocSignatureEvent
|
||||
}
|
||||
|
||||
// Calculated completion time
|
||||
completedAt?: number
|
||||
|
||||
// Calculated status fields
|
||||
signedStatus: SigitStatus
|
||||
signersStatus: {
|
||||
[signer: `npub1${string}`]: SignStatus
|
||||
}
|
||||
|
||||
timestamps?: OpenTimestamp[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom use hook for parsing the Sigit Meta
|
||||
* @param meta Sigit Meta
|
||||
@ -74,8 +26,8 @@ export const useSigitMeta = (meta: Meta): FlatMeta => {
|
||||
const [kind, setKind] = useState<number>()
|
||||
const [tags, setTags] = useState<string[][]>()
|
||||
const [createdAt, setCreatedAt] = useState<number>()
|
||||
const [submittedBy, setSubmittedBy] = useState<`npub1${string}`>() // submittedBy, pubkey from nostr event
|
||||
const [exportedBy, setExportedBy] = useState<`npub1${string}`>() // pubkey from export signature nostr event
|
||||
const [submittedBy, setSubmittedBy] = useState<string>() // submittedBy, pubkey from nostr event (hex)
|
||||
const [exportedBy, setExportedBy] = useState<string>() // pubkey from export signature nostr event (hex)
|
||||
const [id, setId] = useState<string>()
|
||||
const [sig, setSig] = useState<string>()
|
||||
|
||||
@ -108,18 +60,16 @@ export const useSigitMeta = (meta: Meta): FlatMeta => {
|
||||
;(async function () {
|
||||
try {
|
||||
if (meta.exportSignature) {
|
||||
const exportSignatureEvent = await parseNostrEvent(
|
||||
meta.exportSignature
|
||||
)
|
||||
const exportSignatureEvent = parseNostrEvent(meta.exportSignature)
|
||||
if (
|
||||
verifyEvent(exportSignatureEvent) &&
|
||||
exportSignatureEvent.pubkey
|
||||
) {
|
||||
setExportedBy(exportSignatureEvent.pubkey as `npub1${string}`)
|
||||
setExportedBy(exportSignatureEvent.pubkey)
|
||||
}
|
||||
}
|
||||
|
||||
const createSignatureEvent = await parseNostrEvent(meta.createSignature)
|
||||
const createSignatureEvent = parseNostrEvent(meta.createSignature)
|
||||
|
||||
const { kind, tags, created_at, pubkey, id, sig, content } =
|
||||
createSignatureEvent
|
||||
@ -129,12 +79,12 @@ export const useSigitMeta = (meta: Meta): FlatMeta => {
|
||||
setTags(tags)
|
||||
// created_at in nostr events are stored in seconds
|
||||
setCreatedAt(fromUnixTimestamp(created_at))
|
||||
setSubmittedBy(pubkey as `npub1${string}`)
|
||||
setSubmittedBy(pubkey)
|
||||
setId(id)
|
||||
setSig(sig)
|
||||
|
||||
const { title, signers, viewers, fileHashes, markConfig, zipUrl } =
|
||||
await parseCreateSignatureEventContent(content)
|
||||
parseCreateSignatureEventContent(content)
|
||||
|
||||
setTitle(title)
|
||||
setSigners(signers)
|
||||
|
@ -1,16 +1,11 @@
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { Outlet, useNavigate, useSearchParams } from 'react-router-dom'
|
||||
|
||||
import { getPublicKey, nip19 } from 'nostr-tools'
|
||||
|
||||
import { init as initNostrLogin } from 'nostr-login'
|
||||
import { NostrLoginAuthOptions } from 'nostr-login/dist/types'
|
||||
|
||||
import { AppBar } from '../components/AppBar/AppBar'
|
||||
import { LoadingSpinner } from '../components/LoadingSpinner'
|
||||
|
||||
import { NostrController } from '../controllers'
|
||||
|
||||
import {
|
||||
useAppDispatch,
|
||||
useAppSelector,
|
||||
@ -19,7 +14,6 @@ import {
|
||||
useNDK,
|
||||
useNDKContext
|
||||
} from '../hooks'
|
||||
|
||||
import {
|
||||
restoreState,
|
||||
setUserProfile,
|
||||
@ -30,9 +24,7 @@ import {
|
||||
setUserRobotImage
|
||||
} from '../store/actions'
|
||||
import { LoginMethod } from '../store/auth/types'
|
||||
|
||||
import { getRoboHashPicture, loadState } from '../utils'
|
||||
|
||||
import styles from './style.module.scss'
|
||||
|
||||
export const MainLayout = () => {
|
||||
@ -53,29 +45,32 @@ export const MainLayout = () => {
|
||||
// Ref to track if `subscribeForSigits` has been called
|
||||
const hasSubscribed = useRef(false)
|
||||
|
||||
const navigateAfterLogin = (path: string) => {
|
||||
const callbackPath = searchParams.get('callbackPath')
|
||||
|
||||
if (callbackPath) {
|
||||
// base64 decoded path
|
||||
const path = atob(callbackPath)
|
||||
navigate(path)
|
||||
return
|
||||
}
|
||||
|
||||
navigate(path)
|
||||
}
|
||||
const navigateAfterLogin = useCallback(
|
||||
(path: string | undefined) => {
|
||||
const isCallback = window.location.hash.startsWith('#/?callbackPath=')
|
||||
if (isCallback) {
|
||||
const path = atob(window.location.hash.replace('#/?callbackPath=', ''))
|
||||
setSearchParams((prev) => {
|
||||
prev.delete('callbackPath')
|
||||
return prev
|
||||
})
|
||||
navigate(path)
|
||||
return
|
||||
}
|
||||
if (path) navigate(path)
|
||||
},
|
||||
[navigate, setSearchParams]
|
||||
)
|
||||
|
||||
const login = useCallback(async () => {
|
||||
dispatch(updateLoginMethod(LoginMethod.nostrLogin))
|
||||
|
||||
const nostrController = NostrController.getInstance()
|
||||
const pubkey = await nostrController.capturePublicKey()
|
||||
|
||||
const redirectPath = await authAndGetMetadataAndRelaysMap(pubkey)
|
||||
|
||||
if (redirectPath) {
|
||||
try {
|
||||
dispatch(updateLoginMethod(LoginMethod.nostrLogin))
|
||||
const nostrController = NostrController.getInstance()
|
||||
const pubkey = await nostrController.capturePublicKey()
|
||||
const redirectPath = await authAndGetMetadataAndRelaysMap(pubkey)
|
||||
navigateAfterLogin(redirectPath)
|
||||
} catch (error) {
|
||||
console.error(`Error occured during login`, error)
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [dispatch])
|
||||
|
@ -8,7 +8,6 @@ import {
|
||||
Tooltip
|
||||
} from '@mui/material'
|
||||
import type { Identifier, XYCoord } from 'dnd-core'
|
||||
import saveAs from 'file-saver'
|
||||
import JSZip from 'jszip'
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { DndProvider, useDrag, useDrop } from 'react-dnd'
|
||||
@ -39,7 +38,6 @@ import {
|
||||
generateKeysFile,
|
||||
getHash,
|
||||
hexToNpub,
|
||||
isOnline,
|
||||
unixNow,
|
||||
npubToHex,
|
||||
queryNip05,
|
||||
@ -47,7 +45,12 @@ import {
|
||||
uploadToFileStorage,
|
||||
DEFAULT_TOOLBOX,
|
||||
settleAllFullfilfedPromises,
|
||||
uploadMetaToFileStorage
|
||||
parseNostrEvent,
|
||||
uploadMetaToFileStorage,
|
||||
clearSigitDraft,
|
||||
saveSigitDraft,
|
||||
getSigitDraft,
|
||||
timeout
|
||||
} from '../../utils'
|
||||
import { Container } from '../../components/Container'
|
||||
import fileListStyles from '../../components/FileList/style.module.scss'
|
||||
@ -57,6 +60,7 @@ import { Mark } from '../../types/mark.ts'
|
||||
import { StickySideColumns } from '../../layouts/StickySideColumns.tsx'
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
||||
import {
|
||||
faDownload,
|
||||
faEllipsis,
|
||||
faEye,
|
||||
faFile,
|
||||
@ -73,12 +77,14 @@ import { getSigitFile, SigitFile } from '../../utils/file.ts'
|
||||
import { generateTimestamp } from '../../utils/opentimestamps.ts'
|
||||
import { Autocomplete } from '@mui/material'
|
||||
import _, { truncate } from 'lodash'
|
||||
import { SendDMError } from '../../types/errors/SendDMError.ts'
|
||||
import * as React from 'react'
|
||||
import { AvatarIconButton } from '../../components/UserAvatarIconButton'
|
||||
import { NDKUserProfile, NostrEvent } from '@nostr-dev-kit/ndk'
|
||||
import { useNDKContext } from '../../hooks/useNDKContext.ts'
|
||||
import { useNDK } from '../../hooks/useNDK.ts'
|
||||
import { useImmer } from 'use-immer'
|
||||
import { ButtonUnderline } from '../../components/ButtonUnderline/index.tsx'
|
||||
import { TimeoutError } from '../../types/errors/TimeoutError.ts'
|
||||
|
||||
type FoundUser = NostrEvent & { npub: string }
|
||||
|
||||
@ -86,7 +92,8 @@ export const CreatePage = () => {
|
||||
const navigate = useNavigate()
|
||||
const location = useLocation()
|
||||
const { findMetadata, fetchEventsFromUserRelays } = useNDKContext()
|
||||
const { updateUsersAppData, sendNotification } = useNDK()
|
||||
const { updateUsersAppData, sendNotification, sendPrivateDirectMessage } =
|
||||
useNDK()
|
||||
|
||||
const { uploadedFiles } = location.state || {}
|
||||
const [currentFile, setCurrentFile] = useState<File>()
|
||||
@ -97,7 +104,9 @@ export const CreatePage = () => {
|
||||
|
||||
const [title, setTitle] = useState(`sigit_${formatTimestamp(Date.now())}`)
|
||||
|
||||
const [selectedFiles, setSelectedFiles] = useState<File[]>([...uploadedFiles])
|
||||
const [selectedFiles, setSelectedFiles] = useState<File[]>([
|
||||
...(uploadedFiles || [])
|
||||
])
|
||||
const fileInputRef = useRef<HTMLInputElement>(null)
|
||||
const handleUploadButtonClick = () => {
|
||||
if (fileInputRef.current) {
|
||||
@ -123,7 +132,7 @@ export const CreatePage = () => {
|
||||
[key: string]: NDKUserProfile
|
||||
}>({})
|
||||
|
||||
const [drawnFiles, updateDrawnFiles] = useImmer<SigitFile[]>([])
|
||||
const [drawnFiles, setDrawnFiles] = useState<SigitFile[]>([])
|
||||
const [parsingPdf, setIsParsing] = useState<boolean>(false)
|
||||
|
||||
const searchFieldRef = useRef<HTMLInputElement>(null)
|
||||
@ -162,8 +171,8 @@ export const CreatePage = () => {
|
||||
return pubkey
|
||||
}
|
||||
|
||||
const handleSearchUsers = async (searchValue?: string) => {
|
||||
const searchString = searchValue || userSearchInput || undefined
|
||||
const handleSearchUsers = async () => {
|
||||
const searchString = userSearchInput || undefined
|
||||
|
||||
if (!searchString) return
|
||||
|
||||
@ -171,14 +180,17 @@ export const CreatePage = () => {
|
||||
|
||||
const searchTerm = searchString.trim()
|
||||
|
||||
fetchEventsFromUserRelays(
|
||||
{
|
||||
kinds: [0],
|
||||
search: searchTerm
|
||||
},
|
||||
usersPubkey,
|
||||
UserRelaysType.Write
|
||||
)
|
||||
Promise.race([
|
||||
fetchEventsFromUserRelays(
|
||||
{
|
||||
kinds: [0],
|
||||
search: searchTerm
|
||||
},
|
||||
usersPubkey,
|
||||
UserRelaysType.Write
|
||||
),
|
||||
timeout(30000)
|
||||
])
|
||||
.then((events) => {
|
||||
const nostrEvents = events.map((event) => event.rawEvent())
|
||||
|
||||
@ -216,6 +228,9 @@ export const CreatePage = () => {
|
||||
toast.info('No user found with the provided search term')
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error instanceof TimeoutError) {
|
||||
toast.error('Search timed out. Please try again.')
|
||||
}
|
||||
console.error(error)
|
||||
})
|
||||
.finally(() => {
|
||||
@ -245,22 +260,23 @@ export const CreatePage = () => {
|
||||
|
||||
// If pasted user npub of nip05 is present, we just add the user to the counterparts list
|
||||
if (pastedUserNpubOrNip05) {
|
||||
setUserInput(pastedUserNpubOrNip05)
|
||||
setUserInput(pastedUserNpubOrNip05.trim())
|
||||
setPastedUserNpubOrNip05(undefined)
|
||||
} else {
|
||||
// Otherwize if search already provided some results, user must manually click the search button
|
||||
// Otherwise if search already provided some results, user must manually click the search button
|
||||
if (!foundUsers.length) {
|
||||
const searchTerm = userSearchInput.trim()
|
||||
// If it's NIP05 (includes @ or is a valid domain) send request to .well-known
|
||||
const domainRegex = /^[a-zA-Z0-9@.-]+\.[a-zA-Z]{2,}$/
|
||||
if (domainRegex.test(userSearchInput)) {
|
||||
if (searchTerm.startsWith('_@') || domainRegex.test(searchTerm)) {
|
||||
setSearchUsersLoading(true)
|
||||
|
||||
const pubkey = await handleSearchUserNip05(userSearchInput)
|
||||
const pubkey = await handleSearchUserNip05(searchTerm)
|
||||
|
||||
setSearchUsersLoading(false)
|
||||
|
||||
if (pubkey) {
|
||||
setUserInput(userSearchInput)
|
||||
setUserInput(searchTerm)
|
||||
} else {
|
||||
toast.error(`No user found with the NIP05: ${userSearchInput}`)
|
||||
}
|
||||
@ -283,27 +299,29 @@ export const CreatePage = () => {
|
||||
selectedFiles,
|
||||
getSigitFile
|
||||
)
|
||||
updateDrawnFiles((draft) => {
|
||||
setDrawnFiles((prev) => {
|
||||
const clone = _.cloneDeep(prev)
|
||||
// Existing files are untouched
|
||||
|
||||
// Handle removed files
|
||||
// Remove in reverse to avoid index issues
|
||||
for (let i = draft.length - 1; i >= 0; i--) {
|
||||
for (let i = clone.length - 1; i >= 0; i--) {
|
||||
if (
|
||||
!files.some(
|
||||
(f) => f.name === draft[i].name && f.size === draft[i].size
|
||||
(f) => f.name === clone[i].name && f.size === clone[i].size
|
||||
)
|
||||
) {
|
||||
draft.splice(i, 1)
|
||||
clone.splice(i, 1)
|
||||
}
|
||||
}
|
||||
|
||||
// Add new files
|
||||
files.forEach((f) => {
|
||||
if (!draft.some((d) => d.name === f.name && d.size === f.size)) {
|
||||
draft.push(f)
|
||||
if (!clone.some((d) => d.name === f.name && d.size === f.size)) {
|
||||
clone.push(f)
|
||||
}
|
||||
})
|
||||
return clone
|
||||
})
|
||||
}
|
||||
|
||||
@ -313,7 +331,52 @@ export const CreatePage = () => {
|
||||
setIsParsing(false)
|
||||
})
|
||||
}
|
||||
}, [selectedFiles, updateDrawnFiles])
|
||||
}, [selectedFiles])
|
||||
|
||||
const [draftEnabled, setDraftEnabled] = useState(true)
|
||||
useEffect(() => {
|
||||
// Only proceed if we have no uploaded files
|
||||
if (uploadedFiles?.length ?? 0) return
|
||||
|
||||
getSigitDraft().then((draft) => {
|
||||
if (draft) {
|
||||
setSelectedFiles(draft.files)
|
||||
setDrawnFiles((prev) => {
|
||||
const clone = _.cloneDeep(prev)
|
||||
clone.splice(0, clone.length, ...draft.files)
|
||||
return clone
|
||||
})
|
||||
setUsers(draft.users)
|
||||
setTitle(draft.title)
|
||||
|
||||
// After loading draft clear it
|
||||
clearSigitDraft()
|
||||
}
|
||||
})
|
||||
}, [uploadedFiles])
|
||||
useEffect(() => {
|
||||
if (draftEnabled) {
|
||||
saveSigitDraft({
|
||||
title,
|
||||
users,
|
||||
lastUpdated: Date.now(),
|
||||
files: drawnFiles
|
||||
}).catch((error) => {
|
||||
if (
|
||||
error instanceof DOMException &&
|
||||
error.name === 'QuotaExceededError'
|
||||
) {
|
||||
// Disable draft if we hit size error
|
||||
setDraftEnabled(false)
|
||||
console.warn(
|
||||
'Draft functionality disabled temporarily. File size exceeds local storage limit.'
|
||||
)
|
||||
clearSigitDraft()
|
||||
}
|
||||
// Ignore other errors
|
||||
})
|
||||
}
|
||||
}, [draftEnabled, drawnFiles, title, users])
|
||||
|
||||
/**
|
||||
* Changes the drawing tool
|
||||
@ -411,7 +474,7 @@ export const CreatePage = () => {
|
||||
|
||||
setUserSearchInput('')
|
||||
|
||||
if (input.startsWith('npub')) {
|
||||
if (input.startsWith('npub1')) {
|
||||
return handleAddNpubUser(input)
|
||||
}
|
||||
|
||||
@ -504,7 +567,7 @@ export const CreatePage = () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
updateDrawnFiles(drawnFilesCopy)
|
||||
setDrawnFiles(drawnFilesCopy)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -692,10 +755,18 @@ export const CreatePage = () => {
|
||||
type: 'application/sigit'
|
||||
})
|
||||
|
||||
const firstSigner = users.filter((user) => user.role === UserRole.signer)[0]
|
||||
|
||||
const userSet = new Set<string>()
|
||||
const nostrController = NostrController.getInstance()
|
||||
const pubkey = await nostrController.capturePublicKey()
|
||||
userSet.add(pubkey)
|
||||
signers.forEach((signer) => {
|
||||
userSet.add(signer.pubkey)
|
||||
})
|
||||
viewers.forEach((viewer) => {
|
||||
userSet.add(viewer.pubkey)
|
||||
})
|
||||
const keysFileContent = await generateKeysFile(
|
||||
[firstSigner.pubkey],
|
||||
Array.from(userSet),
|
||||
encryptionKey
|
||||
)
|
||||
if (!keysFileContent) return null
|
||||
@ -747,30 +818,6 @@ export const CreatePage = () => {
|
||||
.catch(handleUploadError)
|
||||
}
|
||||
|
||||
// Manage offline scenarios for signing or viewing the file
|
||||
const handleOfflineFlow = async (
|
||||
encryptedArrayBuffer: ArrayBuffer,
|
||||
encryptionKey: string
|
||||
) => {
|
||||
const finalZipFile = await createFinalZipFile(
|
||||
encryptedArrayBuffer,
|
||||
encryptionKey
|
||||
)
|
||||
|
||||
if (!finalZipFile) {
|
||||
setIsLoading(false)
|
||||
return
|
||||
}
|
||||
|
||||
saveAs(finalZipFile, `request-${unixNow()}.sigit.zip`)
|
||||
|
||||
// If user is the next signer, we can navigate directly to sign page
|
||||
if (signers[0].pubkey === usersPubkey) {
|
||||
navigate(appPrivateRoutes.sign, { state: { uploadedZip: finalZipFile } })
|
||||
}
|
||||
setIsLoading(false)
|
||||
}
|
||||
|
||||
const generateFilesZip = async (): Promise<ArrayBuffer | null> => {
|
||||
const zip = new JSZip()
|
||||
selectedFiles.forEach((file) => {
|
||||
@ -836,7 +883,7 @@ export const CreatePage = () => {
|
||||
return e.id
|
||||
}
|
||||
|
||||
const handleCreate = async () => {
|
||||
const initCreation = async () => {
|
||||
try {
|
||||
if (!validateInputs()) return
|
||||
|
||||
@ -848,132 +895,128 @@ export const CreatePage = () => {
|
||||
setLoadingSpinnerDesc('Generating encryption key')
|
||||
const encryptionKey = await generateEncryptionKey()
|
||||
|
||||
if (await isOnline()) {
|
||||
setLoadingSpinnerDesc('generating files.zip')
|
||||
const arrayBuffer = await generateFilesZip()
|
||||
if (!arrayBuffer) return
|
||||
setLoadingSpinnerDesc('Creating marks')
|
||||
const markConfig = createMarks(fileHashes)
|
||||
|
||||
setLoadingSpinnerDesc('Encrypting files.zip')
|
||||
const encryptedArrayBuffer = await encryptZipFile(
|
||||
arrayBuffer,
|
||||
encryptionKey
|
||||
)
|
||||
return {
|
||||
encryptionKey,
|
||||
markConfig,
|
||||
fileHashes
|
||||
}
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
toast.error(error.message)
|
||||
}
|
||||
console.error(error)
|
||||
setIsLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
const markConfig = createMarks(fileHashes)
|
||||
const handleCreate = async () => {
|
||||
try {
|
||||
const result = await initCreation()
|
||||
if (!result) return
|
||||
|
||||
setLoadingSpinnerDesc('Uploading files.zip to file storage')
|
||||
const fileUrl = await uploadFile(encryptedArrayBuffer)
|
||||
if (!fileUrl) return
|
||||
const { encryptionKey, markConfig, fileHashes } = result
|
||||
|
||||
setLoadingSpinnerDesc('Generating create signature')
|
||||
const createSignature = await generateCreateSignature(
|
||||
markConfig,
|
||||
fileHashes,
|
||||
fileUrl
|
||||
)
|
||||
if (!createSignature) return
|
||||
setLoadingSpinnerDesc('generating files.zip')
|
||||
const arrayBuffer = await generateFilesZip()
|
||||
if (!arrayBuffer) return
|
||||
|
||||
setLoadingSpinnerDesc('Generating keys for decryption')
|
||||
setLoadingSpinnerDesc('Encrypting files.zip')
|
||||
const encryptedArrayBuffer = await encryptZipFile(
|
||||
arrayBuffer,
|
||||
encryptionKey
|
||||
)
|
||||
|
||||
// generate key pairs for decryption
|
||||
const pubkeys = users.map((user) => user.pubkey)
|
||||
// also add creator in the list
|
||||
if (pubkeys.includes(usersPubkey!)) {
|
||||
pubkeys.push(usersPubkey!)
|
||||
}
|
||||
setLoadingSpinnerDesc('Uploading files.zip to file storage')
|
||||
const fileUrl = await uploadFile(encryptedArrayBuffer)
|
||||
if (!fileUrl) return
|
||||
|
||||
const keys = await generateKeys(pubkeys, encryptionKey)
|
||||
if (!keys) return
|
||||
setLoadingSpinnerDesc('Generating create signature')
|
||||
const createSignature = await generateCreateSignature(
|
||||
markConfig,
|
||||
fileHashes,
|
||||
fileUrl
|
||||
)
|
||||
if (!createSignature) return
|
||||
|
||||
setLoadingSpinnerDesc('Generating an open timestamp.')
|
||||
setLoadingSpinnerDesc('Generating keys for decryption')
|
||||
|
||||
const timestamp = await generateTimestamp(
|
||||
extractNostrId(createSignature)
|
||||
)
|
||||
// generate key pairs for decryption
|
||||
const pubkeys = users.map((user) => user.pubkey)
|
||||
// also add creator in the list
|
||||
if (pubkeys.includes(usersPubkey!)) {
|
||||
pubkeys.push(usersPubkey!)
|
||||
}
|
||||
|
||||
const meta: Meta = {
|
||||
createSignature,
|
||||
keys,
|
||||
modifiedAt: unixNow(),
|
||||
docSignatures: {}
|
||||
}
|
||||
const keys = await generateKeys(pubkeys, encryptionKey)
|
||||
if (!keys) return
|
||||
|
||||
if (timestamp) {
|
||||
meta.timestamps = [timestamp]
|
||||
}
|
||||
setLoadingSpinnerDesc('Generating an open timestamp.')
|
||||
|
||||
setLoadingSpinnerDesc('Updating user app data')
|
||||
const timestamp = await generateTimestamp(extractNostrId(createSignature))
|
||||
|
||||
const event = await updateUsersAppData([meta])
|
||||
if (!event) return
|
||||
const meta: Meta = {
|
||||
createSignature,
|
||||
keys,
|
||||
modifiedAt: unixNow(),
|
||||
docSignatures: {}
|
||||
}
|
||||
|
||||
const metaUrl = await uploadMetaToFileStorage(meta, encryptionKey)
|
||||
if (timestamp) {
|
||||
meta.timestamps = [timestamp]
|
||||
}
|
||||
|
||||
setLoadingSpinnerDesc('Sending notifications to counterparties')
|
||||
const promises = sendNotifications({
|
||||
metaUrl,
|
||||
keys: meta.keys
|
||||
setLoadingSpinnerDesc('Updating user app data')
|
||||
|
||||
const event = await updateUsersAppData([meta])
|
||||
if (!event) return
|
||||
|
||||
const metaUrl = await uploadMetaToFileStorage(meta, encryptionKey)
|
||||
|
||||
setLoadingSpinnerDesc('Sending notifications to counterparties')
|
||||
const promises = sendNotifications({
|
||||
metaUrl,
|
||||
keys: meta.keys
|
||||
})
|
||||
|
||||
await Promise.all(promises)
|
||||
.then(() => {
|
||||
toast.success('Notifications sent successfully')
|
||||
})
|
||||
.catch(() => {
|
||||
toast.error('Failed to publish notifications')
|
||||
})
|
||||
|
||||
await Promise.all(promises)
|
||||
.then(() => {
|
||||
toast.success('Notifications sent successfully')
|
||||
})
|
||||
.catch(() => {
|
||||
toast.error('Failed to publish notifications')
|
||||
})
|
||||
const isFirstSigner =
|
||||
signers.length > 0 && signers[0].pubkey === usersPubkey
|
||||
|
||||
const isFirstSigner = signers[0].pubkey === usersPubkey
|
||||
|
||||
if (isFirstSigner) {
|
||||
navigate(appPrivateRoutes.sign, { state: { meta } })
|
||||
} else {
|
||||
const createSignatureJson = JSON.parse(createSignature)
|
||||
navigate(`${appPublicRoutes.verify}/${createSignatureJson.id}`)
|
||||
}
|
||||
} else {
|
||||
const zip = new JSZip()
|
||||
|
||||
selectedFiles.forEach((file) => {
|
||||
zip.file(`files/${file.name}`, file)
|
||||
})
|
||||
|
||||
const markConfig = createMarks(fileHashes)
|
||||
|
||||
setLoadingSpinnerDesc('Generating create signature')
|
||||
const createSignature = await generateCreateSignature(
|
||||
markConfig,
|
||||
fileHashes,
|
||||
''
|
||||
)
|
||||
if (!createSignature) return
|
||||
|
||||
const meta: Meta = {
|
||||
createSignature,
|
||||
modifiedAt: unixNow(),
|
||||
docSignatures: {}
|
||||
}
|
||||
|
||||
// add meta to zip
|
||||
// Don't send notification if creator is next signer
|
||||
if (signers.length > 0 && !isFirstSigner) {
|
||||
// Send DM to the next signer
|
||||
setLoadingSpinnerDesc('Sending DMs')
|
||||
const nextSigner = signers[0].pubkey
|
||||
const createSignatureEvent = parseNostrEvent(meta.createSignature)
|
||||
const { id } = createSignatureEvent
|
||||
try {
|
||||
const stringifiedMeta = JSON.stringify(meta, null, 2)
|
||||
zip.file('meta.json', stringifiedMeta)
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
toast.error('An error occurred in converting meta json to string')
|
||||
return null
|
||||
await sendPrivateDirectMessage(
|
||||
`Sigit created, visit ${window.location.origin}/#/sign/${id}`,
|
||||
npubToHex(nextSigner)!
|
||||
)
|
||||
} catch (error) {
|
||||
if (error instanceof SendDMError) {
|
||||
toast.error(error.message)
|
||||
}
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
|
||||
const arrayBuffer = await generateZipFile(zip)
|
||||
if (!arrayBuffer) return
|
||||
|
||||
setLoadingSpinnerDesc('Encrypting zip file')
|
||||
const encryptedArrayBuffer = await encryptZipFile(
|
||||
arrayBuffer,
|
||||
encryptionKey
|
||||
)
|
||||
|
||||
await handleOfflineFlow(encryptedArrayBuffer, encryptionKey)
|
||||
if (isFirstSigner) {
|
||||
navigate(appPrivateRoutes.sign, { state: { meta } })
|
||||
} else {
|
||||
const createSignatureJson = JSON.parse(createSignature)
|
||||
navigate(`${appPublicRoutes.verify}/${createSignatureJson.id}`)
|
||||
}
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
@ -982,6 +1025,85 @@ export const CreatePage = () => {
|
||||
console.error(error)
|
||||
} finally {
|
||||
setIsLoading(false)
|
||||
clearSigitDraft()
|
||||
}
|
||||
}
|
||||
|
||||
const handleCreateOffline = async () => {
|
||||
try {
|
||||
const result = await initCreation()
|
||||
if (!result) return
|
||||
|
||||
const { encryptionKey, markConfig, fileHashes } = result
|
||||
|
||||
const zip = new JSZip()
|
||||
|
||||
selectedFiles.forEach((file) => {
|
||||
zip.file(`files/${file.name}`, file)
|
||||
})
|
||||
|
||||
setLoadingSpinnerDesc('Generating create signature')
|
||||
const createSignature = await generateCreateSignature(
|
||||
markConfig,
|
||||
fileHashes,
|
||||
''
|
||||
)
|
||||
if (!createSignature) return
|
||||
|
||||
const meta: Meta = {
|
||||
createSignature,
|
||||
modifiedAt: unixNow(),
|
||||
docSignatures: {}
|
||||
}
|
||||
|
||||
// add meta to zip
|
||||
try {
|
||||
const stringifiedMeta = JSON.stringify(meta, null, 2)
|
||||
zip.file('meta.json', stringifiedMeta)
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
toast.error('An error occurred in converting meta json to string')
|
||||
return null
|
||||
}
|
||||
|
||||
const arrayBuffer = await generateZipFile(zip)
|
||||
if (!arrayBuffer) return
|
||||
|
||||
setLoadingSpinnerDesc('Encrypting zip file')
|
||||
const encryptedArrayBuffer = await encryptZipFile(
|
||||
arrayBuffer,
|
||||
encryptionKey
|
||||
)
|
||||
|
||||
const finalZipFile = await createFinalZipFile(
|
||||
encryptedArrayBuffer,
|
||||
encryptionKey
|
||||
)
|
||||
|
||||
if (!finalZipFile) {
|
||||
setIsLoading(false)
|
||||
return
|
||||
}
|
||||
|
||||
// If user is the next signer, we can navigate directly to sign page
|
||||
const isFirstSigner = signers[0].pubkey === usersPubkey
|
||||
if (isFirstSigner) {
|
||||
navigate(appPrivateRoutes.sign, {
|
||||
state: { arrayBuffer }
|
||||
})
|
||||
} else {
|
||||
navigate(appPublicRoutes.verify, {
|
||||
state: { uploadedZip: arrayBuffer }
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
toast.error(error.message)
|
||||
}
|
||||
console.error(error)
|
||||
} finally {
|
||||
setIsLoading(false)
|
||||
clearSigitDraft()
|
||||
}
|
||||
}
|
||||
|
||||
@ -999,17 +1121,13 @@ export const CreatePage = () => {
|
||||
}
|
||||
|
||||
// Seems like it's npub format
|
||||
if (value.startsWith('npub')) {
|
||||
// We will try to convert npub to hex and if it's successfull that means
|
||||
// npub is valid
|
||||
const validHexPubkey = npubToHex(value)
|
||||
|
||||
if (validHexPubkey) {
|
||||
// Arm the manual user npub add after enter is hit, we don't want to trigger search
|
||||
setPastedUserNpubOrNip05(value)
|
||||
} else {
|
||||
disarmAddOnEnter()
|
||||
}
|
||||
if (value.trim().startsWith('npub1')) {
|
||||
setPastedUserNpubOrNip05(value.trim())
|
||||
} else if (value.trim().startsWith('nsec1')) {
|
||||
toast.warn('Oops - never paste your nsec into a website! Key deleted.')
|
||||
if (searchFieldRef.current) searchFieldRef.current.value = ''
|
||||
setUserSearchInput('')
|
||||
return
|
||||
} else {
|
||||
// Disarm the add user on enter hit, and trigger search after 1 second
|
||||
disarmAddOnEnter()
|
||||
@ -1169,7 +1287,7 @@ export const CreatePage = () => {
|
||||
{!pastedUserNpubOrNip05 ? (
|
||||
<Button
|
||||
disabled={!userSearchInput || searchUsersLoading}
|
||||
onClick={() => handleSearchUsers()}
|
||||
onClick={handleSearchUsers}
|
||||
variant="contained"
|
||||
aria-label="Add"
|
||||
className={styles.counterpartToggleButton}
|
||||
@ -1183,7 +1301,7 @@ export const CreatePage = () => {
|
||||
) : (
|
||||
<Button
|
||||
onClick={() => {
|
||||
setUserInput(userSearchInput)
|
||||
setUserInput(userSearchInput.trim())
|
||||
}}
|
||||
variant="contained"
|
||||
aria-label="Add"
|
||||
@ -1231,6 +1349,11 @@ export const CreatePage = () => {
|
||||
Publish
|
||||
</Button>
|
||||
|
||||
<ButtonUnderline onClick={handleCreateOffline}>
|
||||
<FontAwesomeIcon icon={faDownload} />
|
||||
Create and export locally
|
||||
</ButtonUnderline>
|
||||
|
||||
{!!error && (
|
||||
<FormHelperText error={!!error}>{error}</FormHelperText>
|
||||
)}
|
||||
@ -1245,7 +1368,7 @@ export const CreatePage = () => {
|
||||
userProfiles={userProfiles}
|
||||
selectedTool={selectedTool}
|
||||
sigitFiles={drawnFiles}
|
||||
updateSigitFiles={updateDrawnFiles}
|
||||
setSigitFiles={setDrawnFiles}
|
||||
/>
|
||||
{parsingPdf && <LoadingSpinner variant="small" />}
|
||||
</StickySideColumns>
|
||||
|
@ -1,10 +1,9 @@
|
||||
import { Button, TextField } from '@mui/material'
|
||||
import JSZip from 'jszip'
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { useNavigate, useSearchParams } from 'react-router-dom'
|
||||
import { toast } from 'react-toastify'
|
||||
import { useAppSelector } from '../../hooks'
|
||||
import { appPrivateRoutes, appPublicRoutes } from '../../routes'
|
||||
import { useAppSelector, useDidMount } from '../../hooks'
|
||||
import { appPrivateRoutes } from '../../routes'
|
||||
import { Meta } from '../../types'
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
||||
import { faSearch } from '@fortawesome/free-solid-svg-icons'
|
||||
@ -14,11 +13,15 @@ import { useDropzone } from 'react-dropzone'
|
||||
import { Container } from '../../components/Container'
|
||||
import styles from './style.module.scss'
|
||||
import {
|
||||
clearSigitDraft,
|
||||
extractSigitCardDisplayInfo,
|
||||
hasSigitDraft,
|
||||
navigateFromZip,
|
||||
SigitCardDisplayInfo,
|
||||
SigitStatus
|
||||
} from '../../utils'
|
||||
import { Footer } from '../../components/Footer/Footer'
|
||||
import { LocalDraftSigit } from '../../components/DisplaySigit/LocalDraftSigit'
|
||||
|
||||
// Unsupported Filter options are commented
|
||||
const FILTERS = [
|
||||
@ -44,6 +47,12 @@ export const HomePage = () => {
|
||||
const [searchParams, setSearchParams] = useSearchParams()
|
||||
const q = searchParams.get('q') ?? ''
|
||||
|
||||
const [showDraft, setShowDraft] = useState<boolean>(false)
|
||||
useDidMount(async () => {
|
||||
// Check if draft exists and add link to direct
|
||||
setShowDraft(hasSigitDraft())
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
const searchInput = document.getElementById('q') as HTMLInputElement | null
|
||||
if (searchInput) {
|
||||
@ -56,6 +65,7 @@ export const HomePage = () => {
|
||||
[key: string]: SigitCardDisplayInfo
|
||||
}>({})
|
||||
const usersAppData = useAppSelector((state) => state.userAppData)
|
||||
const usersPubkey = useAppSelector((state) => state.auth.usersPubkey)
|
||||
|
||||
useEffect(() => {
|
||||
if (usersAppData?.sigits) {
|
||||
@ -63,7 +73,7 @@ export const HomePage = () => {
|
||||
const parsedSigits: { [key: string]: SigitCardDisplayInfo } = {}
|
||||
for (const key in usersAppData.sigits) {
|
||||
if (Object.prototype.hasOwnProperty.call(usersAppData.sigits, key)) {
|
||||
const sigitInfo = await extractSigitCardDisplayInfo(
|
||||
const sigitInfo = extractSigitCardDisplayInfo(
|
||||
usersAppData.sigits[key]
|
||||
)
|
||||
if (sigitInfo) {
|
||||
@ -92,27 +102,12 @@ export const HomePage = () => {
|
||||
const fileName = file.name
|
||||
const fileExtension = fileName.slice(-10) // ".sigit.zip" has 10 characters
|
||||
if (fileExtension === '.sigit.zip') {
|
||||
const zip = await JSZip.loadAsync(file).catch((err) => {
|
||||
console.log('err in loading zip file :>> ', err)
|
||||
toast.error(err.message || 'An error occurred in loading zip file.')
|
||||
return null
|
||||
})
|
||||
const nav = await navigateFromZip(
|
||||
file,
|
||||
usersPubkey as `npub1${string}`
|
||||
)
|
||||
|
||||
if (!zip) return
|
||||
|
||||
// navigate to sign page if zip contains keys.json
|
||||
if ('keys.json' in zip.files) {
|
||||
return navigate(appPrivateRoutes.sign, {
|
||||
state: { uploadedZip: file }
|
||||
})
|
||||
}
|
||||
|
||||
// navigate to verify page if zip contains meta.json
|
||||
if ('meta.json' in zip.files) {
|
||||
return navigate(appPublicRoutes.verify, {
|
||||
state: { uploadedZip: file }
|
||||
})
|
||||
}
|
||||
if (nav) return navigate(nav.to, nav.options)
|
||||
|
||||
toast.error('Invalid SiGit zip file')
|
||||
return
|
||||
@ -124,7 +119,7 @@ export const HomePage = () => {
|
||||
state: { uploadedFiles: acceptedFiles }
|
||||
})
|
||||
},
|
||||
[navigate]
|
||||
[navigate, usersPubkey]
|
||||
)
|
||||
|
||||
const { getRootProps, getInputProps, isDragActive, open } = useDropzone({
|
||||
@ -166,7 +161,7 @@ export const HomePage = () => {
|
||||
meta={sigits[key]}
|
||||
/>
|
||||
))
|
||||
} else {
|
||||
} else if (!showDraft) {
|
||||
return (
|
||||
<div className={styles.noResults}>
|
||||
<p>No results</p>
|
||||
@ -274,7 +269,17 @@ export const HomePage = () => {
|
||||
)}
|
||||
</button>
|
||||
|
||||
<div className={styles.submissions}>{renderSubmissions()}</div>
|
||||
<div className={styles.submissions}>
|
||||
{showDraft && (
|
||||
<LocalDraftSigit
|
||||
handleDraftDelete={() => {
|
||||
clearSigitDraft()
|
||||
setShowDraft(false)
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{renderSubmissions()}
|
||||
</div>
|
||||
</Container>
|
||||
<Footer />
|
||||
</div>
|
||||
|
@ -1,7 +1,5 @@
|
||||
import { Box, Button } from '@mui/material'
|
||||
import { useEffect } from 'react'
|
||||
import { Outlet, useLocation } from 'react-router-dom'
|
||||
import { saveVisitedLink } from '../../utils'
|
||||
import { Outlet } from 'react-router-dom'
|
||||
import { CardComponent } from '../../components/Landing/CardComponent/CardComponent'
|
||||
import { Container } from '../../components/Container'
|
||||
import styles from './style.module.scss'
|
||||
@ -20,13 +18,19 @@ import {
|
||||
import { FontAwesomeIconStack } from '../../components/FontAwesomeIconStack'
|
||||
import { Footer } from '../../components/Footer/Footer'
|
||||
import { launch as launchNostrLoginDialog } from 'nostr-login'
|
||||
import { useDidMount } from '../../hooks'
|
||||
|
||||
export const LandingPage = () => {
|
||||
const location = useLocation()
|
||||
|
||||
const onSignInClick = async () => {
|
||||
launchNostrLoginDialog()
|
||||
}
|
||||
useDidMount(() => {
|
||||
const isCallback = window.location.hash.startsWith('#/?callbackPath=')
|
||||
// Open nostr login if detect callback
|
||||
if (isCallback) {
|
||||
onSignInClick()
|
||||
}
|
||||
})
|
||||
|
||||
const cards = [
|
||||
{
|
||||
@ -101,10 +105,6 @@ export const LandingPage = () => {
|
||||
}
|
||||
]
|
||||
|
||||
useEffect(() => {
|
||||
saveVisitedLink(location.pathname, location.search)
|
||||
}, [location])
|
||||
|
||||
return (
|
||||
<div className={styles.background}>
|
||||
<div
|
||||
|
@ -13,7 +13,7 @@ import { Footer } from '../../components/Footer/Footer'
|
||||
import { LoadingSpinner } from '../../components/LoadingSpinner'
|
||||
import { useAppSelector } from '../../hooks/store'
|
||||
|
||||
import { getProfileSettingsRoute } from '../../routes'
|
||||
import { appPrivateRoutes } from '../../routes'
|
||||
|
||||
import {
|
||||
getProfileUsername,
|
||||
@ -168,7 +168,7 @@ export const ProfilePage = () => {
|
||||
<Box className={styles.right}>
|
||||
{isUsersOwnProfile && (
|
||||
<IconButton
|
||||
onClick={() => navigate(getProfileSettingsRoute(pubkey))}
|
||||
onClick={() => navigate(appPrivateRoutes.profileSettings)}
|
||||
>
|
||||
<EditIcon />
|
||||
</IconButton>
|
||||
|
@ -1,94 +1,82 @@
|
||||
import AccountCircleIcon from '@mui/icons-material/AccountCircle'
|
||||
import ArrowForwardIosIcon from '@mui/icons-material/ArrowForwardIos'
|
||||
import CachedIcon from '@mui/icons-material/Cached'
|
||||
import RouterIcon from '@mui/icons-material/Router'
|
||||
import { ListItem, useTheme } from '@mui/material'
|
||||
import List from '@mui/material/List'
|
||||
import ListItemIcon from '@mui/material/ListItemIcon'
|
||||
import ListItemText from '@mui/material/ListItemText'
|
||||
import ListSubheader from '@mui/material/ListSubheader'
|
||||
import { Button } from '@mui/material'
|
||||
import { useAppSelector } from '../../hooks/store'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { appPrivateRoutes, getProfileSettingsRoute } from '../../routes'
|
||||
import { NavLink, Outlet, To } from 'react-router-dom'
|
||||
import { appPrivateRoutes } from '../../routes'
|
||||
import { Container } from '../../components/Container'
|
||||
import { Footer } from '../../components/Footer/Footer'
|
||||
import ExtensionIcon from '@mui/icons-material/Extension'
|
||||
import { LoginMethod } from '../../store/auth/types'
|
||||
import styles from './style.module.scss'
|
||||
import { ReactNode } from 'react'
|
||||
|
||||
export const SettingsPage = () => {
|
||||
const theme = useTheme()
|
||||
const { usersPubkey, loginMethod } = useAppSelector((state) => state.auth)
|
||||
const listItem = (label: string, disabled = false) => {
|
||||
return (
|
||||
<>
|
||||
<ListItemText
|
||||
primary={label}
|
||||
const Item = (to: To, icon: ReactNode, label: string) => {
|
||||
return (
|
||||
<NavLink to={to}>
|
||||
{({ isActive }) => (
|
||||
<Button
|
||||
fullWidth
|
||||
sx={{
|
||||
color: theme.palette.text.primary
|
||||
transition: 'ease 0.3s',
|
||||
justifyContent: 'start',
|
||||
gap: '10px',
|
||||
background: 'rgba(76,130,163,0)',
|
||||
color: '#434343',
|
||||
fontWeight: 600,
|
||||
opacity: 0.75,
|
||||
textTransform: 'none',
|
||||
...(isActive
|
||||
? {
|
||||
background: '#447592',
|
||||
color: 'white'
|
||||
}
|
||||
: {}),
|
||||
'&:hover': {
|
||||
opacity: 0.85,
|
||||
gap: '15px',
|
||||
background: '#5e8eab',
|
||||
color: 'white'
|
||||
}
|
||||
}}
|
||||
/>
|
||||
variant={'text'}
|
||||
>
|
||||
{icon}
|
||||
{label}
|
||||
</Button>
|
||||
)}
|
||||
</NavLink>
|
||||
)
|
||||
}
|
||||
|
||||
{!disabled && (
|
||||
<ArrowForwardIosIcon
|
||||
style={{
|
||||
color: theme.palette.action.active,
|
||||
marginRight: -10
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
export const SettingsLayout = () => {
|
||||
const { loginMethod } = useAppSelector((state) => state.auth)
|
||||
|
||||
return (
|
||||
<>
|
||||
<Container>
|
||||
<List
|
||||
sx={{
|
||||
width: '100%',
|
||||
bgcolor: 'background.paper'
|
||||
}}
|
||||
subheader={
|
||||
<ListSubheader
|
||||
sx={{
|
||||
fontSize: '1.5rem',
|
||||
borderBottom: '0.5px solid',
|
||||
paddingBottom: 2,
|
||||
paddingTop: 2,
|
||||
zIndex: 2
|
||||
}}
|
||||
>
|
||||
Settings
|
||||
</ListSubheader>
|
||||
}
|
||||
>
|
||||
<ListItem component={Link} to={getProfileSettingsRoute(usersPubkey!)}>
|
||||
<ListItemIcon>
|
||||
<AccountCircleIcon />
|
||||
</ListItemIcon>
|
||||
{listItem('Profile')}
|
||||
</ListItem>
|
||||
<ListItem component={Link} to={appPrivateRoutes.relays}>
|
||||
<ListItemIcon>
|
||||
<RouterIcon />
|
||||
</ListItemIcon>
|
||||
{listItem('Relays')}
|
||||
</ListItem>
|
||||
<ListItem component={Link} to={appPrivateRoutes.cacheSettings}>
|
||||
<ListItemIcon>
|
||||
<CachedIcon />
|
||||
</ListItemIcon>
|
||||
{listItem('Local Cache')}
|
||||
</ListItem>
|
||||
{loginMethod === LoginMethod.nostrLogin && (
|
||||
<ListItem component={Link} to={appPrivateRoutes.nostrLogin}>
|
||||
<ListItemIcon>
|
||||
<ExtensionIcon />
|
||||
</ListItemIcon>
|
||||
{listItem('Nostr Login')}
|
||||
</ListItem>
|
||||
)}
|
||||
</List>
|
||||
<h2 className={styles.title}>Settings</h2>
|
||||
<div className={styles.main}>
|
||||
<div>
|
||||
<aside className={styles.aside}>
|
||||
{Item(
|
||||
appPrivateRoutes.profileSettings,
|
||||
<AccountCircleIcon />,
|
||||
'Profile'
|
||||
)}
|
||||
{Item(appPrivateRoutes.relays, <RouterIcon />, 'Relays')}
|
||||
{loginMethod === LoginMethod.nostrLogin &&
|
||||
Item(
|
||||
appPrivateRoutes.nostrLogin,
|
||||
<ExtensionIcon />,
|
||||
'Nostr Login'
|
||||
)}
|
||||
</aside>
|
||||
</div>
|
||||
<div className={styles.content}>
|
||||
<Outlet />
|
||||
</div>
|
||||
</div>
|
||||
</Container>
|
||||
<Footer />
|
||||
</>
|
||||
|
102
src/pages/settings/cache/index.tsx
vendored
102
src/pages/settings/cache/index.tsx
vendored
@ -1,102 +0,0 @@
|
||||
import ClearIcon from '@mui/icons-material/Clear'
|
||||
import InputIcon from '@mui/icons-material/Input'
|
||||
import IosShareIcon from '@mui/icons-material/IosShare'
|
||||
import {
|
||||
List,
|
||||
ListItemButton,
|
||||
ListItemIcon,
|
||||
ListItemText,
|
||||
ListSubheader,
|
||||
useTheme
|
||||
} from '@mui/material'
|
||||
import { useState } from 'react'
|
||||
import { toast } from 'react-toastify'
|
||||
import { localCache } from '../../../services'
|
||||
import { LoadingSpinner } from '../../../components/LoadingSpinner'
|
||||
import { Container } from '../../../components/Container'
|
||||
import { Footer } from '../../../components/Footer/Footer'
|
||||
|
||||
export const CacheSettingsPage = () => {
|
||||
const theme = useTheme()
|
||||
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
const [loadingSpinnerDesc, setLoadingSpinnerDesc] = useState('')
|
||||
|
||||
const handleClearData = async () => {
|
||||
setIsLoading(true)
|
||||
setLoadingSpinnerDesc('Clearing cache data')
|
||||
localCache
|
||||
.clearCacheData()
|
||||
.then(() => {
|
||||
toast.success('cleared cached data')
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log('An error occurred in clearing cache data', err)
|
||||
toast.error(err.message || 'An error occurred in clearing cache data')
|
||||
})
|
||||
.finally(() => {
|
||||
setIsLoading(false)
|
||||
})
|
||||
}
|
||||
|
||||
const listItem = (label: string) => {
|
||||
return (
|
||||
<ListItemText
|
||||
primary={label}
|
||||
sx={{
|
||||
color: theme.palette.text.primary
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Container>
|
||||
{isLoading && <LoadingSpinner desc={loadingSpinnerDesc} />}
|
||||
<List
|
||||
sx={{
|
||||
width: '100%',
|
||||
bgcolor: 'background.paper',
|
||||
marginTop: 2
|
||||
}}
|
||||
subheader={
|
||||
<ListSubheader
|
||||
sx={{
|
||||
fontSize: '1.5rem',
|
||||
borderBottom: '0.5px solid',
|
||||
paddingBottom: 2,
|
||||
paddingTop: 2,
|
||||
zIndex: 2
|
||||
}}
|
||||
>
|
||||
Cache Setting
|
||||
</ListSubheader>
|
||||
}
|
||||
>
|
||||
<ListItemButton disabled>
|
||||
<ListItemIcon>
|
||||
<IosShareIcon />
|
||||
</ListItemIcon>
|
||||
{listItem('Export (coming soon)')}
|
||||
</ListItemButton>
|
||||
|
||||
<ListItemButton disabled>
|
||||
<ListItemIcon>
|
||||
<InputIcon />
|
||||
</ListItemIcon>
|
||||
{listItem('Import (coming soon)')}
|
||||
</ListItemButton>
|
||||
|
||||
<ListItemButton onClick={handleClearData}>
|
||||
<ListItemIcon>
|
||||
<ClearIcon sx={{ color: theme.palette.error.main }} />
|
||||
</ListItemIcon>
|
||||
{listItem('Clear Cache')}
|
||||
</ListItemButton>
|
||||
</List>
|
||||
</Container>
|
||||
<Footer />
|
||||
</>
|
||||
)
|
||||
}
|
@ -3,11 +3,9 @@ import {
|
||||
ListItemButton,
|
||||
ListItemIcon,
|
||||
ListItemText,
|
||||
ListSubheader,
|
||||
useTheme
|
||||
} from '@mui/material'
|
||||
import { launch as launchNostrLoginDialog } from 'nostr-login'
|
||||
import { Container } from '../../../components/Container'
|
||||
import PeopleIcon from '@mui/icons-material/People'
|
||||
import ImportExportIcon from '@mui/icons-material/ImportExport'
|
||||
import { useAppSelector } from '../../../hooks/store'
|
||||
@ -20,59 +18,39 @@ export const NostrLoginPage = () => {
|
||||
)
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<List
|
||||
sx={{
|
||||
width: '100%',
|
||||
bgcolor: 'background.paper'
|
||||
<List>
|
||||
<ListItemButton
|
||||
onClick={() => {
|
||||
launchNostrLoginDialog('switch-account')
|
||||
}}
|
||||
subheader={
|
||||
<ListSubheader
|
||||
sx={{
|
||||
fontSize: '1.5rem',
|
||||
borderBottom: '0.5px solid',
|
||||
paddingBottom: 2,
|
||||
paddingTop: 2,
|
||||
zIndex: 2
|
||||
}}
|
||||
>
|
||||
Nostr Settings
|
||||
</ListSubheader>
|
||||
}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<PeopleIcon />
|
||||
</ListItemIcon>
|
||||
<ListItemText
|
||||
primary={'Nostr Login Accounts'}
|
||||
sx={{
|
||||
color: theme.palette.text.primary
|
||||
}}
|
||||
/>
|
||||
</ListItemButton>
|
||||
{nostrLoginAuthMethod === NostrLoginAuthMethod.Local && (
|
||||
<ListItemButton
|
||||
onClick={() => {
|
||||
launchNostrLoginDialog('switch-account')
|
||||
launchNostrLoginDialog('import')
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<PeopleIcon />
|
||||
<ImportExportIcon />
|
||||
</ListItemIcon>
|
||||
<ListItemText
|
||||
primary={'Nostr Login Accounts'}
|
||||
primary={'Import / Export Keys'}
|
||||
sx={{
|
||||
color: theme.palette.text.primary
|
||||
}}
|
||||
/>
|
||||
</ListItemButton>
|
||||
{nostrLoginAuthMethod === NostrLoginAuthMethod.Local && (
|
||||
<ListItemButton
|
||||
onClick={() => {
|
||||
launchNostrLoginDialog('import')
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<ImportExportIcon />
|
||||
</ListItemIcon>
|
||||
<ListItemText
|
||||
primary={'Import / Export Keys'}
|
||||
sx={{
|
||||
color: theme.palette.text.primary
|
||||
}}
|
||||
/>
|
||||
</ListItemButton>
|
||||
)}
|
||||
</List>
|
||||
</Container>
|
||||
)}
|
||||
</List>
|
||||
)
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import React, { useEffect, useRef, useState } from 'react'
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { toast } from 'react-toastify'
|
||||
|
||||
import { SmartToy } from '@mui/icons-material'
|
||||
@ -12,7 +11,6 @@ import {
|
||||
InputProps,
|
||||
List,
|
||||
ListItem,
|
||||
ListSubheader,
|
||||
TextField,
|
||||
Tooltip
|
||||
} from '@mui/material'
|
||||
@ -28,8 +26,6 @@ import { useAppDispatch, useAppSelector } from '../../../hooks/store'
|
||||
|
||||
import { getRoboHashPicture, unixNow } from '../../../utils'
|
||||
|
||||
import { Container } from '../../../components/Container'
|
||||
import { Footer } from '../../../components/Footer/Footer'
|
||||
import { LoadingSpinner } from '../../../components/LoadingSpinner'
|
||||
|
||||
import { setUserProfile as updateUserProfile } from '../../../store/actions'
|
||||
@ -41,10 +37,8 @@ import styles from './style.module.scss'
|
||||
export const ProfileSettingsPage = () => {
|
||||
const dispatch: Dispatch = useAppDispatch()
|
||||
|
||||
const { npub } = useParams()
|
||||
const { ndk, findMetadata, publish } = useNDKContext()
|
||||
|
||||
const [pubkey, setPubkey] = useState<string>()
|
||||
const [userProfile, setUserProfile] = useState<NDKUserProfile | null>(null)
|
||||
|
||||
const userRobotImage = useAppSelector((state) => state.user.robotImage)
|
||||
@ -55,27 +49,13 @@ export const ProfileSettingsPage = () => {
|
||||
)
|
||||
|
||||
const [savingProfileMetadata, setSavingProfileMetadata] = useState(false)
|
||||
const [isUsersOwnProfile, setIsUsersOwnProfile] = useState(false)
|
||||
const [isLoading, setIsLoading] = useState(true)
|
||||
const [loadingSpinnerDesc] = useState('Fetching metadata')
|
||||
|
||||
const robotSet = useRef(1)
|
||||
|
||||
useEffect(() => {
|
||||
if (npub) {
|
||||
try {
|
||||
const hexPubkey = nip19.decode(npub).data as string
|
||||
setPubkey(hexPubkey)
|
||||
|
||||
if (hexPubkey === usersPubkey) setIsUsersOwnProfile(true)
|
||||
} catch (error) {
|
||||
toast.error('Error occurred in decoding npub' + error)
|
||||
}
|
||||
}
|
||||
}, [npub, usersPubkey])
|
||||
|
||||
useEffect(() => {
|
||||
if (isUsersOwnProfile && currentUserProfile) {
|
||||
if (usersPubkey && currentUserProfile) {
|
||||
setUserProfile(currentUserProfile)
|
||||
|
||||
setIsLoading(false)
|
||||
@ -83,8 +63,8 @@ export const ProfileSettingsPage = () => {
|
||||
return
|
||||
}
|
||||
|
||||
if (pubkey) {
|
||||
findMetadata(pubkey)
|
||||
if (usersPubkey) {
|
||||
findMetadata(usersPubkey)
|
||||
.then((profile) => {
|
||||
setUserProfile(profile)
|
||||
})
|
||||
@ -95,7 +75,7 @@ export const ProfileSettingsPage = () => {
|
||||
setIsLoading(false)
|
||||
})
|
||||
}
|
||||
}, [ndk, isUsersOwnProfile, currentUserProfile, pubkey, findMetadata])
|
||||
}, [ndk, currentUserProfile, findMetadata, usersPubkey])
|
||||
|
||||
const editItem = (
|
||||
key: keyof NDKUserProfile,
|
||||
@ -113,7 +93,6 @@ export const ProfileSettingsPage = () => {
|
||||
multiline={multiline}
|
||||
rows={rows}
|
||||
className={styles.textField}
|
||||
disabled={!isUsersOwnProfile}
|
||||
InputProps={inputProps}
|
||||
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const { value } = event.target
|
||||
@ -170,7 +149,7 @@ export const ProfileSettingsPage = () => {
|
||||
content: serializedProfile,
|
||||
created_at: unixNow(),
|
||||
kind: kinds.Metadata,
|
||||
pubkey: pubkey!,
|
||||
pubkey: usersPubkey!,
|
||||
tags: []
|
||||
}
|
||||
|
||||
@ -215,7 +194,7 @@ export const ProfileSettingsPage = () => {
|
||||
robotSet.current++
|
||||
if (robotSet.current > 5) robotSet.current = 1
|
||||
|
||||
const robotAvatarLink = getRoboHashPicture(npub!, robotSet.current)
|
||||
const robotAvatarLink = getRoboHashPicture(usersPubkey!, robotSet.current)
|
||||
|
||||
setUserProfile((prev) => ({
|
||||
...prev,
|
||||
@ -244,143 +223,106 @@ export const ProfileSettingsPage = () => {
|
||||
* @returns robohash image url
|
||||
*/
|
||||
const getProfileImage = (profile: NDKUserProfile) => {
|
||||
if (!isUsersOwnProfile) {
|
||||
return profile.image || getRoboHashPicture(npub!)
|
||||
}
|
||||
|
||||
// userRobotImage is used only when visiting own profile
|
||||
// while kind 0 picture is not set
|
||||
return profile.image || userRobotImage || getRoboHashPicture(npub!)
|
||||
return profile.image || userRobotImage || getRoboHashPicture(usersPubkey!)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{isLoading && <LoadingSpinner desc={loadingSpinnerDesc} />}
|
||||
<Container className={styles.container}>
|
||||
<List
|
||||
sx={{
|
||||
bgcolor: 'background.paper',
|
||||
marginTop: 2
|
||||
}}
|
||||
subheader={
|
||||
<ListSubheader
|
||||
<List>
|
||||
{userProfile && (
|
||||
<div>
|
||||
<ListItem
|
||||
sx={{
|
||||
paddingBottom: 1,
|
||||
paddingTop: 1,
|
||||
fontSize: '1.5rem',
|
||||
zIndex: 2
|
||||
marginTop: 1,
|
||||
display: 'flex',
|
||||
flexDirection: 'column'
|
||||
}}
|
||||
className={styles.subHeader}
|
||||
>
|
||||
Profile Settings
|
||||
</ListSubheader>
|
||||
}
|
||||
>
|
||||
{userProfile && (
|
||||
<div>
|
||||
<ListItem
|
||||
sx={{
|
||||
marginTop: 1,
|
||||
display: 'flex',
|
||||
flexDirection: 'column'
|
||||
}}
|
||||
>
|
||||
{userProfile.banner ? (
|
||||
<img
|
||||
className={styles.bannerImg}
|
||||
src={userProfile.banner}
|
||||
alt="Banner Image"
|
||||
/>
|
||||
) : (
|
||||
<Box className={styles.noBanner}> No banner found </Box>
|
||||
)}
|
||||
</ListItem>
|
||||
|
||||
{editItem('banner', 'Banner URL', undefined, undefined)}
|
||||
|
||||
<ListItem
|
||||
sx={{
|
||||
marginTop: 1,
|
||||
display: 'flex',
|
||||
flexDirection: 'column'
|
||||
}}
|
||||
>
|
||||
{userProfile.banner ? (
|
||||
<img
|
||||
onError={(event: React.SyntheticEvent<HTMLImageElement>) => {
|
||||
event.currentTarget.src = getRoboHashPicture(npub!)
|
||||
}}
|
||||
className={styles.img}
|
||||
src={getProfileImage(userProfile)}
|
||||
alt="Profile Image"
|
||||
className={styles.bannerImg}
|
||||
src={userProfile.banner}
|
||||
alt="Banner Image"
|
||||
/>
|
||||
</ListItem>
|
||||
|
||||
{editItem('image', 'Picture URL', undefined, undefined, {
|
||||
endAdornment: isUsersOwnProfile ? robohashButton() : undefined
|
||||
})}
|
||||
|
||||
{editItem('name', 'Username')}
|
||||
{editItem('displayName', 'Display Name')}
|
||||
{editItem('nip05', 'Nostr Address (nip05)')}
|
||||
{editItem('lud16', 'Lightning Address (lud16)')}
|
||||
{editItem('about', 'About', true, 4)}
|
||||
{editItem('website', 'Website')}
|
||||
{isUsersOwnProfile && (
|
||||
<>
|
||||
{usersPubkey &&
|
||||
copyItem(nip19.npubEncode(usersPubkey), 'Public Key')}
|
||||
|
||||
{loginMethod === LoginMethod.privateKey &&
|
||||
keys &&
|
||||
keys.private &&
|
||||
copyItem(
|
||||
'••••••••••••••••••••••••••••••••••••••••••••••••••',
|
||||
'Private Key',
|
||||
keys.private
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<Box className={styles.noBanner}> No banner found </Box>
|
||||
)}
|
||||
{isUsersOwnProfile && (
|
||||
<>
|
||||
{loginMethod === LoginMethod.nostrLogin &&
|
||||
nostrLoginAuthMethod === NostrLoginAuthMethod.Local && (
|
||||
<ListItem
|
||||
sx={{ marginTop: 1 }}
|
||||
onClick={() => {
|
||||
launchNostrLoginDialog('import')
|
||||
}}
|
||||
>
|
||||
<TextField
|
||||
label="Private Key (nostr-login)"
|
||||
defaultValue="••••••••••••••••••••••••••••••••••••••••••••••••••"
|
||||
size="small"
|
||||
className={styles.textField}
|
||||
disabled
|
||||
type={'password'}
|
||||
InputProps={{
|
||||
endAdornment: (
|
||||
<LaunchIcon className={styles.copyItem} />
|
||||
)
|
||||
}}
|
||||
/>
|
||||
</ListItem>
|
||||
)}
|
||||
</>
|
||||
</ListItem>
|
||||
|
||||
{editItem('banner', 'Banner URL', undefined, undefined)}
|
||||
|
||||
<ListItem
|
||||
sx={{
|
||||
marginTop: 1,
|
||||
display: 'flex',
|
||||
flexDirection: 'column'
|
||||
}}
|
||||
>
|
||||
<img
|
||||
onError={(event: React.SyntheticEvent<HTMLImageElement>) => {
|
||||
event.currentTarget.src = getRoboHashPicture(usersPubkey!)
|
||||
}}
|
||||
className={styles.img}
|
||||
src={getProfileImage(userProfile)}
|
||||
alt="Profile Image"
|
||||
/>
|
||||
</ListItem>
|
||||
|
||||
{editItem('image', 'Picture URL', undefined, undefined, {
|
||||
endAdornment: robohashButton()
|
||||
})}
|
||||
|
||||
{editItem('name', 'Username')}
|
||||
{editItem('displayName', 'Display Name')}
|
||||
{editItem('nip05', 'Nostr Address (nip05)')}
|
||||
{editItem('lud16', 'Lightning Address (lud16)')}
|
||||
{editItem('about', 'About', true, 4)}
|
||||
{editItem('website', 'Website')}
|
||||
{usersPubkey &&
|
||||
copyItem(nip19.npubEncode(usersPubkey), 'Public Key')}
|
||||
{loginMethod === LoginMethod.privateKey &&
|
||||
keys &&
|
||||
keys.private &&
|
||||
copyItem(
|
||||
'••••••••••••••••••••••••••••••••••••••••••••••••••',
|
||||
'Private Key',
|
||||
keys.private
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</List>
|
||||
{isUsersOwnProfile && (
|
||||
<LoadingButton
|
||||
loading={savingProfileMetadata}
|
||||
variant="contained"
|
||||
onClick={handleSaveMetadata}
|
||||
>
|
||||
SAVE
|
||||
</LoadingButton>
|
||||
{loginMethod === LoginMethod.nostrLogin &&
|
||||
nostrLoginAuthMethod === NostrLoginAuthMethod.Local && (
|
||||
<ListItem
|
||||
sx={{ marginTop: 1 }}
|
||||
onClick={() => {
|
||||
launchNostrLoginDialog('import')
|
||||
}}
|
||||
>
|
||||
<TextField
|
||||
label="Private Key (nostr-login)"
|
||||
defaultValue="••••••••••••••••••••••••••••••••••••••••••••••••••"
|
||||
size="small"
|
||||
className={styles.textField}
|
||||
disabled
|
||||
type={'password'}
|
||||
InputProps={{
|
||||
endAdornment: <LaunchIcon className={styles.copyItem} />
|
||||
}}
|
||||
/>
|
||||
</ListItem>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</Container>
|
||||
<Footer />
|
||||
</List>
|
||||
<LoadingButton
|
||||
sx={{ maxWidth: '300px', alignSelf: 'center', width: '100%' }}
|
||||
loading={savingProfileMetadata}
|
||||
variant="contained"
|
||||
onClick={handleSaveMetadata}
|
||||
>
|
||||
PUBLISH CHANGES
|
||||
</LoadingButton>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
@ -1,9 +1,3 @@
|
||||
.container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 25px;
|
||||
}
|
||||
|
||||
.textField {
|
||||
width: 100%;
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ import ListItemText from '@mui/material/ListItemText'
|
||||
import Switch from '@mui/material/Switch'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { toast } from 'react-toastify'
|
||||
import { Container } from '../../../components/Container'
|
||||
import {
|
||||
useAppDispatch,
|
||||
useAppSelector,
|
||||
@ -32,7 +31,6 @@ import {
|
||||
timeout
|
||||
} from '../../../utils'
|
||||
import styles from './style.module.scss'
|
||||
import { Footer } from '../../../components/Footer/Footer'
|
||||
import {
|
||||
getRelayListForUser,
|
||||
NDKRelayList,
|
||||
@ -54,7 +52,10 @@ export const RelaysPage = () => {
|
||||
const relayMap = useAppSelector((state) => state.relays?.map)
|
||||
const relaysInfo = useAppSelector((state) => state.relays?.info)
|
||||
|
||||
const webSocketPrefix = 'wss://'
|
||||
const webSocketPrefix =
|
||||
newRelayURI?.startsWith('wss://') || newRelayURI?.startsWith('ws://')
|
||||
? ''
|
||||
: 'wss://'
|
||||
|
||||
// fetch relay list from relays
|
||||
useEffect(() => {
|
||||
@ -197,7 +198,7 @@ export const RelaysPage = () => {
|
||||
// Check if new relay URI is a valid string
|
||||
if (
|
||||
relayURI &&
|
||||
!/^wss:\/\/[-a-zA-Z0-9@:%._\\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}/.test(
|
||||
!/^wss?:\/\/[-a-zA-Z0-9@:%._\\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}/.test(
|
||||
relayURI
|
||||
)
|
||||
) {
|
||||
@ -243,7 +244,7 @@ export const RelaysPage = () => {
|
||||
}
|
||||
|
||||
return (
|
||||
<Container className={styles.container}>
|
||||
<>
|
||||
<Box className={styles.relayAddContainer}>
|
||||
<TextField
|
||||
label="Add new relay"
|
||||
@ -260,7 +261,13 @@ export const RelaysPage = () => {
|
||||
}}
|
||||
className={styles.relayURItextfield}
|
||||
/>
|
||||
<Button variant="contained" onClick={() => handleAddNewRelay()}>
|
||||
<Button
|
||||
sx={{
|
||||
height: '56px'
|
||||
}}
|
||||
variant="contained"
|
||||
onClick={() => handleAddNewRelay()}
|
||||
>
|
||||
Add
|
||||
</Button>
|
||||
</Box>
|
||||
@ -282,8 +289,7 @@ export const RelaysPage = () => {
|
||||
))}
|
||||
</Box>
|
||||
)}
|
||||
<Footer />
|
||||
</Container>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -1,106 +1,103 @@
|
||||
@import '../../../styles/colors.scss';
|
||||
|
||||
.container {
|
||||
color: $text-color;
|
||||
.relayURItextfield {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.relayURItextfield {
|
||||
width: 100%;
|
||||
.relayAddContainer {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 10px;
|
||||
width: 100%;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.sectionIcon {
|
||||
font-size: 30px;
|
||||
}
|
||||
|
||||
.sectionTitle {
|
||||
margin-top: 35px;
|
||||
margin-bottom: 10px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 5px;
|
||||
font-size: 1.5rem;
|
||||
line-height: 2rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.relaysContainer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.relay {
|
||||
border: 1px solid rgba(0, 0, 0, 0.12);
|
||||
border-radius: 4px;
|
||||
|
||||
.relayDivider {
|
||||
margin-left: 10px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.relayAddContainer {
|
||||
.leaveRelayContainer {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 10px;
|
||||
width: 100%;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.sectionIcon {
|
||||
font-size: 30px;
|
||||
.showInfo {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.sectionTitle {
|
||||
margin-top: 35px;
|
||||
margin-bottom: 10px;
|
||||
.showInfoIcon {
|
||||
margin-right: 3px;
|
||||
margin-bottom: auto;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.relayInfoContainer {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-direction: column;
|
||||
gap: 5px;
|
||||
font-size: 1.5rem;
|
||||
line-height: 2rem;
|
||||
text-wrap: wrap;
|
||||
}
|
||||
|
||||
.relayInfoTitle {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.relaysContainer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 15px;
|
||||
.relayInfoSubTitle {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.relay {
|
||||
border: 1px solid rgba(0, 0, 0, 0.12);
|
||||
border-radius: 4px;
|
||||
|
||||
.relayDivider {
|
||||
margin-left: 10px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.leaveRelayContainer {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 10px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.showInfo {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.showInfoIcon {
|
||||
margin-right: 3px;
|
||||
margin-bottom: auto;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.relayInfoContainer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 5px;
|
||||
text-wrap: wrap;
|
||||
}
|
||||
|
||||
.relayInfoTitle {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.relayInfoSubTitle {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.copyItem {
|
||||
margin-left: 10px;
|
||||
color: #34495e;
|
||||
vertical-align: bottom;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.connectionStatus {
|
||||
border-radius: 9999px;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
margin-right: 5px;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.connectionStatusConnected {
|
||||
background-color: $relay-status-connected;
|
||||
}
|
||||
|
||||
.connectionStatusNotConnected {
|
||||
background-color: $relay-status-notconnected;
|
||||
}
|
||||
|
||||
.connectionStatusUnknown {
|
||||
background-color: $input-text-color;
|
||||
}
|
||||
.copyItem {
|
||||
margin-left: 10px;
|
||||
color: #34495e;
|
||||
vertical-align: bottom;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.connectionStatus {
|
||||
border-radius: 9999px;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
margin-right: 5px;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.connectionStatusConnected {
|
||||
background-color: $relay-status-connected;
|
||||
}
|
||||
|
||||
.connectionStatusNotConnected {
|
||||
background-color: $relay-status-notconnected;
|
||||
}
|
||||
|
||||
.connectionStatusUnknown {
|
||||
background-color: $input-text-color;
|
||||
}
|
||||
}
|
43
src/pages/settings/style.module.scss
Normal file
43
src/pages/settings/style.module.scss
Normal file
@ -0,0 +1,43 @@
|
||||
.title {
|
||||
margin: 0 0 15px 0;
|
||||
}
|
||||
|
||||
.main {
|
||||
width: 100%;
|
||||
display: grid;
|
||||
grid-template-columns: 0.4fr 1.6fr;
|
||||
position: relative;
|
||||
grid-gap: 25px;
|
||||
|
||||
>* {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
grid-gap: 25px;
|
||||
}
|
||||
}
|
||||
|
||||
.aside {
|
||||
width: 100%;
|
||||
background: white;
|
||||
padding: 15px;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 0 4px 0 rgb(0, 0, 0, 0.1);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
grid-gap: 15px;
|
||||
|
||||
position: sticky;
|
||||
top: 15px;
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 100%;
|
||||
background: white;
|
||||
padding: 15px;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 0 4px 0 rgb(0, 0, 0, 0.1);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
grid-gap: 15px;
|
||||
}
|
@ -1,60 +1,50 @@
|
||||
import axios from 'axios'
|
||||
import saveAs from 'file-saver'
|
||||
import JSZip from 'jszip'
|
||||
import _ from 'lodash'
|
||||
import { Event, verifyEvent } from 'nostr-tools'
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { useAppSelector } from '../../hooks'
|
||||
import { useLocation, useNavigate, useParams } from 'react-router-dom'
|
||||
import { toast } from 'react-toastify'
|
||||
import { LoadingSpinner } from '../../components/LoadingSpinner'
|
||||
import { NostrController } from '../../controllers'
|
||||
import { appPrivateRoutes, appPublicRoutes } from '../../routes'
|
||||
import { appPublicRoutes } from '../../routes'
|
||||
import { CreateSignatureEventContent, Meta, SignedEvent } from '../../types'
|
||||
import {
|
||||
ARRAY_BUFFER,
|
||||
decryptArrayBuffer,
|
||||
DEFLATE,
|
||||
encryptArrayBuffer,
|
||||
extractMarksFromSignedMeta,
|
||||
extractZipUrlAndEncryptionKey,
|
||||
filterMarksByPubkey,
|
||||
findOtherUserMarks,
|
||||
generateEncryptionKey,
|
||||
generateKeysFile,
|
||||
getCurrentUserFiles,
|
||||
getCurrentUserMarks,
|
||||
getHash,
|
||||
hexToNpub,
|
||||
isOnline,
|
||||
loadZip,
|
||||
npubToHex,
|
||||
parseJson,
|
||||
processMarks,
|
||||
encryptAndUploadMarks,
|
||||
readContentOfZipEntry,
|
||||
signEventForMetaFile,
|
||||
timeout,
|
||||
unixNow,
|
||||
updateMarks,
|
||||
uploadMetaToFileStorage
|
||||
uploadMetaToFileStorage,
|
||||
parseNostrEvent
|
||||
} from '../../utils'
|
||||
import { CurrentUserMark, Mark } from '../../types/mark.ts'
|
||||
import PdfMarking from '../../components/PDFView/PdfMarking.tsx'
|
||||
import {
|
||||
convertToSigitFile,
|
||||
getZipWithFiles,
|
||||
SigitFile
|
||||
} from '../../utils/file.ts'
|
||||
import { convertToSigitFile, SigitFile } from '../../utils/file.ts'
|
||||
import { generateTimestamp } from '../../utils/opentimestamps.ts'
|
||||
import { MARK_TYPE_CONFIG } from '../../components/MarkTypeStrategy/MarkStrategy.tsx'
|
||||
import { useNDK } from '../../hooks/useNDK.ts'
|
||||
import { getLastSignersSig } from '../../utils/sign.ts'
|
||||
import { SendDMError } from '../../types/errors/SendDMError.ts'
|
||||
|
||||
export const SignPage = () => {
|
||||
const navigate = useNavigate()
|
||||
const location = useLocation()
|
||||
const params = useParams()
|
||||
const { updateUsersAppData, sendNotification } = useNDK()
|
||||
const { updateUsersAppData, sendNotification, sendPrivateDirectMessage } =
|
||||
useNDK()
|
||||
|
||||
const usersAppData = useAppSelector((state) => state.userAppData)
|
||||
|
||||
@ -81,12 +71,10 @@ export const SignPage = () => {
|
||||
/**
|
||||
* Received from `location.state`
|
||||
*
|
||||
* uploadedZip will be received from home page when a user uploads a sigit zip wrapper that contains keys.json
|
||||
* arrayBuffer (decryptedArrayBuffer) will be received in navigation from create page in offline mode
|
||||
*/
|
||||
const { arrayBuffer: decryptedArrayBuffer, uploadedZip } = location.state || {
|
||||
decryptedArrayBuffer: undefined,
|
||||
uploadedZip: undefined
|
||||
decryptedArrayBuffer: undefined
|
||||
}
|
||||
|
||||
const [files, setFiles] = useState<{ [filename: string]: SigitFile }>({})
|
||||
@ -218,63 +206,6 @@ export const SignPage = () => {
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [meta, usersPubkey])
|
||||
|
||||
const decrypt = useCallback(
|
||||
async (file: File) => {
|
||||
setLoadingSpinnerDesc('Decrypting file')
|
||||
|
||||
const zip = await loadZip(file)
|
||||
if (!zip) return
|
||||
|
||||
const parsedKeysJson = await parseKeysJson(zip)
|
||||
if (!parsedKeysJson) return
|
||||
|
||||
const encryptedArrayBuffer = await readContentOfZipEntry(
|
||||
zip,
|
||||
'compressed.sigit',
|
||||
'arraybuffer'
|
||||
)
|
||||
|
||||
if (!encryptedArrayBuffer) return
|
||||
|
||||
const { keys, sender } = parsedKeysJson
|
||||
|
||||
for (const key of keys) {
|
||||
// decrypt the encryptionKey, with timeout (duration = 60 seconds)
|
||||
const encryptionKey = await Promise.race([
|
||||
nostrController.nip04Decrypt(sender, key),
|
||||
timeout(60000)
|
||||
])
|
||||
.then((res) => {
|
||||
return res
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log('err :>> ', err)
|
||||
return null
|
||||
})
|
||||
|
||||
// Return if encryption failed
|
||||
if (!encryptionKey) continue
|
||||
|
||||
const arrayBuffer = await decryptArrayBuffer(
|
||||
encryptedArrayBuffer,
|
||||
encryptionKey
|
||||
)
|
||||
.catch((err) => {
|
||||
console.log('err in decryption:>> ', err)
|
||||
return null
|
||||
})
|
||||
.finally(() => {
|
||||
setIsLoading(false)
|
||||
})
|
||||
|
||||
if (arrayBuffer) return arrayBuffer
|
||||
}
|
||||
|
||||
return null
|
||||
},
|
||||
[nostrController]
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (metaInNavState) {
|
||||
const processSigit = async () => {
|
||||
@ -316,28 +247,14 @@ export const SignPage = () => {
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
// online mode - from create and home page views
|
||||
|
||||
if (decryptedArrayBuffer) {
|
||||
handleDecryptedArrayBuffer(decryptedArrayBuffer).finally(() =>
|
||||
setIsLoading(false)
|
||||
if (decryptedArrayBuffer || uploadedZip) {
|
||||
handleDecryptedArrayBuffer(decryptedArrayBuffer || uploadedZip).finally(
|
||||
() => setIsLoading(false)
|
||||
)
|
||||
} else if (uploadedZip) {
|
||||
decrypt(uploadedZip)
|
||||
.then((arrayBuffer) => {
|
||||
if (arrayBuffer) handleDecryptedArrayBuffer(arrayBuffer)
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(`error occurred in decryption`, err)
|
||||
toast.error(err.message || `error occurred in decryption`)
|
||||
})
|
||||
.finally(() => {
|
||||
setIsLoading(false)
|
||||
})
|
||||
} else {
|
||||
setIsLoading(false)
|
||||
}
|
||||
}, [decryptedArrayBuffer, uploadedZip, decrypt])
|
||||
}, [decryptedArrayBuffer, uploadedZip])
|
||||
|
||||
const handleArrayBufferFromBlossom = async (
|
||||
arrayBuffer: ArrayBuffer,
|
||||
@ -396,30 +313,12 @@ export const SignPage = () => {
|
||||
setMarks(updatedMarks)
|
||||
}
|
||||
|
||||
const parseKeysJson = async (zip: JSZip) => {
|
||||
const keysFileContent = await readContentOfZipEntry(
|
||||
zip,
|
||||
'keys.json',
|
||||
'string'
|
||||
)
|
||||
|
||||
if (!keysFileContent) return null
|
||||
|
||||
return await parseJson<{ sender: string; keys: string[] }>(
|
||||
keysFileContent
|
||||
).catch((err) => {
|
||||
console.log(`Error parsing content of keys.json:`, err)
|
||||
toast.error(err.message || `Error parsing content of keys.json`)
|
||||
return null
|
||||
})
|
||||
}
|
||||
|
||||
const handleDecryptedArrayBuffer = async (arrayBuffer: ArrayBuffer) => {
|
||||
const decryptedZipFile = new File([arrayBuffer], 'decrypted.zip')
|
||||
|
||||
const handleDecryptedArrayBuffer = async (
|
||||
decryptedArrayBuffer: ArrayBuffer
|
||||
) => {
|
||||
setLoadingSpinnerDesc('Parsing zip file')
|
||||
|
||||
const zip = await loadZip(decryptedZipFile)
|
||||
const zip = await loadZip(decryptedArrayBuffer)
|
||||
if (!zip) return
|
||||
|
||||
const files: { [filename: string]: SigitFile } = {}
|
||||
@ -479,16 +378,15 @@ export const SignPage = () => {
|
||||
setMeta(parsedMetaJson)
|
||||
}
|
||||
|
||||
const handleSign = async () => {
|
||||
const initializeSigning = async (type: 'online' | 'offline') => {
|
||||
if (Object.entries(files).length === 0 || !meta) return
|
||||
|
||||
setIsLoading(true)
|
||||
|
||||
setLoadingSpinnerDesc('Signing nostr event')
|
||||
|
||||
const usersNpub = hexToNpub(usersPubkey!)
|
||||
const prevSig = getPrevSignersSig(usersNpub)
|
||||
if (!prevSig) {
|
||||
setIsLoading(false)
|
||||
toast.error('Previous signature is invalid')
|
||||
return
|
||||
}
|
||||
@ -508,7 +406,10 @@ export const SignPage = () => {
|
||||
})
|
||||
}
|
||||
|
||||
const processedMarks = await processMarks(marks, encryptionKey)
|
||||
const processedMarks =
|
||||
type === 'online'
|
||||
? await encryptAndUploadMarks(marks, encryptionKey)
|
||||
: marks
|
||||
|
||||
const signedEvent = await signEventForMeta({
|
||||
prevSig,
|
||||
@ -519,6 +420,22 @@ export const SignPage = () => {
|
||||
|
||||
const updatedMeta = updateMetaSignatures(meta, signedEvent)
|
||||
|
||||
return {
|
||||
encryptionKey,
|
||||
updatedMeta,
|
||||
signedEvent
|
||||
}
|
||||
}
|
||||
|
||||
const handleSign = async () => {
|
||||
const result = await initializeSigning('online')
|
||||
if (!result) {
|
||||
setIsLoading(false)
|
||||
return
|
||||
}
|
||||
|
||||
const { encryptionKey, updatedMeta, signedEvent } = result
|
||||
|
||||
setLoadingSpinnerDesc('Generating an open timestamp.')
|
||||
|
||||
const timestamp = await generateTimestamp(signedEvent.id)
|
||||
@ -527,19 +444,62 @@ export const SignPage = () => {
|
||||
updatedMeta.modifiedAt = unixNow()
|
||||
}
|
||||
|
||||
if (await isOnline()) {
|
||||
await handleOnlineFlow(updatedMeta, encryptionKey)
|
||||
} else {
|
||||
setMeta(updatedMeta)
|
||||
await handleOnlineFlow(updatedMeta, encryptionKey)
|
||||
|
||||
const createSignature = JSON.parse(updatedMeta.createSignature)
|
||||
navigate(`${appPublicRoutes.verify}/${createSignature.id}`)
|
||||
}
|
||||
|
||||
const handleSignOffline = async () => {
|
||||
const result = await initializeSigning('offline')
|
||||
if (!result) {
|
||||
setIsLoading(false)
|
||||
return
|
||||
}
|
||||
|
||||
if (metaInNavState) {
|
||||
const createSignature = JSON.parse(metaInNavState.createSignature)
|
||||
navigate(`${appPublicRoutes.verify}/${createSignature.id}`)
|
||||
} else {
|
||||
navigate(appPrivateRoutes.homePage)
|
||||
const { updatedMeta } = result
|
||||
|
||||
const zip = new JSZip()
|
||||
for (const [filename, value] of Object.entries(files)) {
|
||||
zip.file(`files/${filename}`, await value.arrayBuffer())
|
||||
}
|
||||
const stringifiedMeta = JSON.stringify(updatedMeta, null, 2)
|
||||
zip.file('meta.json', stringifiedMeta)
|
||||
|
||||
// Handle errors during zip file generation
|
||||
const handleZipError = (err: unknown) => {
|
||||
console.log('Error in zip:>> ', err)
|
||||
setIsLoading(false)
|
||||
if (err instanceof Error) {
|
||||
toast.error(err.message || 'Error occurred in generating zip file')
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
setLoadingSpinnerDesc('Generating zip file')
|
||||
|
||||
const arrayBuffer = await zip
|
||||
.generateAsync({
|
||||
type: 'arraybuffer',
|
||||
compression: 'DEFLATE',
|
||||
compressionOptions: { level: 6 }
|
||||
})
|
||||
.catch(handleZipError)
|
||||
|
||||
if (!arrayBuffer) {
|
||||
setIsLoading(false)
|
||||
return
|
||||
}
|
||||
|
||||
// Create a File object with the Blob data
|
||||
const blob = new Blob([arrayBuffer])
|
||||
const file = new File([blob], `request-${unixNow()}.sigit.zip`, {
|
||||
type: 'application/zip'
|
||||
})
|
||||
|
||||
setIsLoading(false)
|
||||
|
||||
navigate(`${appPublicRoutes.verify}`, { state: { uploadedZip: file } })
|
||||
}
|
||||
|
||||
// Sign the event for the meta file
|
||||
@ -570,66 +530,6 @@ export const SignPage = () => {
|
||||
return metaCopy
|
||||
}
|
||||
|
||||
// create final zip file
|
||||
const createFinalZipFile = async (
|
||||
encryptedArrayBuffer: ArrayBuffer,
|
||||
encryptionKey: string
|
||||
): Promise<File | null> => {
|
||||
// Get the current timestamp in seconds
|
||||
const blob = new Blob([encryptedArrayBuffer])
|
||||
// Create a File object with the Blob data
|
||||
const file = new File([blob], `compressed.sigit`, {
|
||||
type: 'application/sigit'
|
||||
})
|
||||
|
||||
const isLastSigner = checkIsLastSigner(signers)
|
||||
|
||||
const userSet = new Set<string>()
|
||||
|
||||
if (isLastSigner) {
|
||||
if (submittedBy) {
|
||||
userSet.add(submittedBy)
|
||||
}
|
||||
|
||||
signers.forEach((signer) => {
|
||||
userSet.add(npubToHex(signer)!)
|
||||
})
|
||||
|
||||
viewers.forEach((viewer) => {
|
||||
userSet.add(npubToHex(viewer)!)
|
||||
})
|
||||
} else {
|
||||
const usersNpub = hexToNpub(usersPubkey!)
|
||||
const signerIndex = signers.indexOf(usersNpub)
|
||||
const nextSigner = signers[signerIndex + 1]
|
||||
userSet.add(npubToHex(nextSigner)!)
|
||||
}
|
||||
|
||||
const keysFileContent = await generateKeysFile(
|
||||
Array.from(userSet),
|
||||
encryptionKey
|
||||
)
|
||||
if (!keysFileContent) return null
|
||||
|
||||
const zip = new JSZip()
|
||||
zip.file(`compressed.sigit`, file)
|
||||
zip.file('keys.json', keysFileContent)
|
||||
|
||||
const arraybuffer = await zip
|
||||
.generateAsync({
|
||||
type: 'arraybuffer',
|
||||
compression: 'DEFLATE',
|
||||
compressionOptions: { level: 6 }
|
||||
})
|
||||
.catch(handleZipError)
|
||||
|
||||
if (!arraybuffer) return null
|
||||
|
||||
return new File([new Blob([arraybuffer])], `${unixNow()}.sigit.zip`, {
|
||||
type: 'application/zip'
|
||||
})
|
||||
}
|
||||
|
||||
// Check if the current user is the last signer
|
||||
const checkIsLastSigner = (signers: string[]): boolean => {
|
||||
const usersNpub = hexToNpub(usersPubkey!)
|
||||
@ -638,16 +538,6 @@ export const SignPage = () => {
|
||||
return signerIndex === lastSignerIndex
|
||||
}
|
||||
|
||||
// Handle errors during zip file generation
|
||||
const handleZipError = (err: unknown) => {
|
||||
console.log('Error in zip:>> ', err)
|
||||
setIsLoading(false)
|
||||
if (err instanceof Error) {
|
||||
toast.error(err.message || 'Error occurred in generating zip file')
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
// Handle the online flow: update users app data and send notifications
|
||||
const handleOnlineFlow = async (
|
||||
meta: Meta,
|
||||
@ -715,100 +605,67 @@ export const SignPage = () => {
|
||||
toast.error('Failed to publish notifications')
|
||||
})
|
||||
|
||||
setIsLoading(false)
|
||||
}
|
||||
// Send DMs
|
||||
setLoadingSpinnerDesc('Sending DMs')
|
||||
const createSignatureEvent = parseNostrEvent(meta.createSignature)
|
||||
const { id } = createSignatureEvent
|
||||
|
||||
const handleExport = async () => {
|
||||
const arrayBuffer = await prepareZipExport()
|
||||
if (!arrayBuffer) return
|
||||
|
||||
const blob = new Blob([arrayBuffer])
|
||||
saveAs(blob, `exported-${unixNow()}.sigit.zip`)
|
||||
|
||||
setIsLoading(false)
|
||||
|
||||
navigate(appPublicRoutes.verify)
|
||||
}
|
||||
|
||||
const handleEncryptedExport = async () => {
|
||||
const arrayBuffer = await prepareZipExport()
|
||||
if (!arrayBuffer) return
|
||||
|
||||
const key = await generateEncryptionKey()
|
||||
|
||||
setLoadingSpinnerDesc('Encrypting zip file')
|
||||
const encryptedArrayBuffer = await encryptArrayBuffer(arrayBuffer, key)
|
||||
|
||||
const finalZipFile = await createFinalZipFile(encryptedArrayBuffer, key)
|
||||
|
||||
if (!finalZipFile) return
|
||||
saveAs(finalZipFile, `exported-${unixNow()}.sigit.zip`)
|
||||
|
||||
setIsLoading(false)
|
||||
}
|
||||
|
||||
const prepareZipExport = async (): Promise<ArrayBuffer | null> => {
|
||||
if (Object.entries(files).length === 0 || !meta || !usersPubkey)
|
||||
return Promise.resolve(null)
|
||||
|
||||
const usersNpub = hexToNpub(usersPubkey)
|
||||
if (
|
||||
!signers.includes(usersNpub) &&
|
||||
!viewers.includes(usersNpub) &&
|
||||
submittedBy !== usersNpub
|
||||
)
|
||||
return Promise.resolve(null)
|
||||
|
||||
setIsLoading(true)
|
||||
setLoadingSpinnerDesc('Signing nostr event')
|
||||
|
||||
if (!meta) return Promise.resolve(null)
|
||||
|
||||
const prevSig = getLastSignersSig(meta, signers)
|
||||
if (!prevSig) return Promise.resolve(null)
|
||||
|
||||
const signedEvent = await signEventForMetaFile(
|
||||
JSON.stringify({
|
||||
prevSig
|
||||
}),
|
||||
nostrController,
|
||||
setIsLoading
|
||||
)
|
||||
|
||||
if (!signedEvent) return Promise.resolve(null)
|
||||
|
||||
const exportSignature = JSON.stringify(signedEvent, null, 2)
|
||||
|
||||
const stringifiedMeta = JSON.stringify(
|
||||
{
|
||||
...meta,
|
||||
exportSignature
|
||||
},
|
||||
null,
|
||||
2
|
||||
)
|
||||
|
||||
const zip = await getZipWithFiles(meta, files)
|
||||
zip.file('meta.json', stringifiedMeta)
|
||||
|
||||
const arrayBuffer = await zip
|
||||
.generateAsync({
|
||||
type: ARRAY_BUFFER,
|
||||
compression: DEFLATE,
|
||||
compressionOptions: {
|
||||
level: 6
|
||||
if (isLastSigner) {
|
||||
// Final sign sends to everyone (creator, signers, viewers - /verify)
|
||||
const areSent: boolean[] = Array(users.length).fill(false)
|
||||
for (let i = 0; i < users.length; i++) {
|
||||
try {
|
||||
areSent[i] = await sendPrivateDirectMessage(
|
||||
`Sigit completed, visit ${window.location.origin}/#/verify/${id}`,
|
||||
npubToHex(users[i])!
|
||||
)
|
||||
} catch (error) {
|
||||
if (error instanceof SendDMError) {
|
||||
toast.error(error.message)
|
||||
}
|
||||
console.error(error)
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log('err in zip:>> ', err)
|
||||
setIsLoading(false)
|
||||
toast.error(err.message || 'Error occurred in generating zip file')
|
||||
return null
|
||||
})
|
||||
}
|
||||
|
||||
if (!arrayBuffer) return Promise.resolve(null)
|
||||
if (areSent.some((r) => r)) {
|
||||
toast.success(
|
||||
`DMs sent ${areSent.filter((r) => r).length}/${users.length}`
|
||||
)
|
||||
}
|
||||
} else {
|
||||
// Notify the creator and
|
||||
// the next signer (/sign).
|
||||
try {
|
||||
await sendPrivateDirectMessage(
|
||||
`Sigit signed by ${usersNpub}, visit ${window.location.origin}/#/sign/${id}`,
|
||||
npubToHex(submittedBy!)!
|
||||
)
|
||||
} catch (error) {
|
||||
if (error instanceof SendDMError) {
|
||||
toast.error(error.message)
|
||||
}
|
||||
console.error(error)
|
||||
}
|
||||
|
||||
return Promise.resolve(arrayBuffer)
|
||||
// No need to notify creator twice, skipping
|
||||
const currentSignerIndex = signers.indexOf(usersNpub)
|
||||
const nextSigner = npubToHex(signers[currentSignerIndex + 1])
|
||||
if (nextSigner !== submittedBy) {
|
||||
try {
|
||||
await sendPrivateDirectMessage(
|
||||
`You're the next signer, visit ${window.location.origin}/#/sign/${id}`,
|
||||
nextSigner!
|
||||
)
|
||||
} catch (error) {
|
||||
if (error instanceof SendDMError) {
|
||||
toast.error(error.message)
|
||||
}
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setIsLoading(false)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -855,8 +712,7 @@ export const SignPage = () => {
|
||||
setCurrentUserMarks={setCurrentUserMarks}
|
||||
setUpdatedMarks={setUpdatedMarks}
|
||||
handleSign={handleSign}
|
||||
handleExport={handleExport}
|
||||
handleEncryptedExport={handleEncryptedExport}
|
||||
handleSignOffline={handleSignOffline}
|
||||
otherUserMarks={otherUserMarks}
|
||||
meta={meta}
|
||||
/>
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Box, Button, Typography } from '@mui/material'
|
||||
import JSZip from 'jszip'
|
||||
import { MuiFileInput } from 'mui-file-input'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { toast } from 'react-toastify'
|
||||
import { LoadingSpinner } from '../../components/LoadingSpinner'
|
||||
import { NostrController } from '../../controllers'
|
||||
@ -27,14 +27,15 @@ import {
|
||||
generateKeysFile,
|
||||
ARRAY_BUFFER,
|
||||
DEFLATE,
|
||||
uploadMetaToFileStorage
|
||||
uploadMetaToFileStorage,
|
||||
decrypt,
|
||||
SignStatus
|
||||
} from '../../utils'
|
||||
import styles from './style.module.scss'
|
||||
import { useLocation, useParams } from 'react-router-dom'
|
||||
import axios from 'axios'
|
||||
import { FONT_SIZE, FONT_TYPE, inPx } from '../../utils/pdf.ts'
|
||||
import { useAppSelector, useNDK } from '../../hooks'
|
||||
import { getLastSignersSig } from '../../utils/sign.ts'
|
||||
import { saveAs } from 'file-saver'
|
||||
import { Container } from '../../components/Container'
|
||||
import { useSigitMeta } from '../../hooks/useSigitMeta.tsx'
|
||||
@ -60,6 +61,7 @@ import {
|
||||
import { upgradeAndVerifyTimestamp } from '../../utils/opentimestamps.ts'
|
||||
import _ from 'lodash'
|
||||
import { MarkRender } from '../../components/MarkTypeStrategy/MarkRender.tsx'
|
||||
import { SignerService } from '../../services/index.ts'
|
||||
|
||||
interface PdfViewProps {
|
||||
files: CurrentUserFile[]
|
||||
@ -188,7 +190,7 @@ export const VerifyPage = () => {
|
||||
* meta will be received in navigation from create & home page in online mode
|
||||
*/
|
||||
let metaInNavState = location?.state?.meta || undefined
|
||||
const { uploadedZip } = location.state || {}
|
||||
const uploadedZip = location?.state?.uploadedZip || undefined
|
||||
const [selectedFile, setSelectedFile] = useState<File | null>(null)
|
||||
|
||||
/**
|
||||
@ -208,12 +210,6 @@ export const VerifyPage = () => {
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (uploadedZip) {
|
||||
setSelectedFile(uploadedZip)
|
||||
}
|
||||
}, [uploadedZip])
|
||||
|
||||
const [meta, setMeta] = useState<Meta>(metaInNavState)
|
||||
|
||||
const {
|
||||
@ -222,6 +218,7 @@ export const VerifyPage = () => {
|
||||
encryptionKey,
|
||||
signers,
|
||||
viewers,
|
||||
signersStatus,
|
||||
fileHashes,
|
||||
parsedSignatureEvents,
|
||||
timestamps
|
||||
@ -483,17 +480,35 @@ export const VerifyPage = () => {
|
||||
}
|
||||
}, [encryptionKey, metaInNavState, zipUrl])
|
||||
|
||||
const handleVerify = async () => {
|
||||
if (!selectedFile) return
|
||||
const handleVerify = useCallback(async (selectedFile: File) => {
|
||||
setIsLoading(true)
|
||||
setLoadingSpinnerDesc('Loading zip file')
|
||||
|
||||
const zip = await JSZip.loadAsync(selectedFile).catch((err) => {
|
||||
let zip = await JSZip.loadAsync(selectedFile).catch((err) => {
|
||||
console.log('err in loading zip file :>> ', err)
|
||||
toast.error(err.message || 'An error occurred in loading zip file.')
|
||||
return null
|
||||
})
|
||||
|
||||
if (!zip) return
|
||||
if (!zip) {
|
||||
return setIsLoading(false)
|
||||
}
|
||||
|
||||
if ('keys.json' in zip.files) {
|
||||
// Decrypt
|
||||
setLoadingSpinnerDesc('Decrypting zip file content')
|
||||
const arrayBuffer = await decrypt(selectedFile).catch((err) => {
|
||||
console.error(`error occurred in decryption`, err)
|
||||
toast.error(err.message || `error occurred in decryption`)
|
||||
})
|
||||
|
||||
if (arrayBuffer) {
|
||||
// Replace the zip and continue processing
|
||||
zip = await JSZip.loadAsync(arrayBuffer)
|
||||
}
|
||||
}
|
||||
|
||||
setLoadingSpinnerDesc('Opening zip file content')
|
||||
|
||||
const files: { [filename: string]: SigitFile } = {}
|
||||
const fileHashes: { [key: string]: string | null } = {}
|
||||
@ -550,12 +565,21 @@ export const VerifyPage = () => {
|
||||
}
|
||||
)
|
||||
|
||||
if (!parsedMetaJson) return
|
||||
if (!parsedMetaJson) {
|
||||
setIsLoading(false)
|
||||
return
|
||||
}
|
||||
|
||||
setMeta(parsedMetaJson)
|
||||
|
||||
setIsLoading(false)
|
||||
}
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (uploadedZip) {
|
||||
handleVerify(uploadedZip)
|
||||
}
|
||||
}, [handleVerify, uploadedZip])
|
||||
|
||||
// Handle errors during zip file generation
|
||||
const handleZipError = (err: unknown) => {
|
||||
@ -567,14 +591,6 @@ export const VerifyPage = () => {
|
||||
return null
|
||||
}
|
||||
|
||||
// Check if the current user is the last signer
|
||||
const checkIsLastSigner = (signers: string[]): boolean => {
|
||||
const usersNpub = hexToNpub(usersPubkey!)
|
||||
const lastSignerIndex = signers.length - 1
|
||||
const signerIndex = signers.indexOf(usersNpub)
|
||||
return signerIndex === lastSignerIndex
|
||||
}
|
||||
|
||||
// create final zip file
|
||||
const createFinalZipFile = async (
|
||||
encryptedArrayBuffer: ArrayBuffer,
|
||||
@ -587,28 +603,16 @@ export const VerifyPage = () => {
|
||||
type: 'application/sigit'
|
||||
})
|
||||
|
||||
const isLastSigner = checkIsLastSigner(signers)
|
||||
|
||||
const userSet = new Set<string>()
|
||||
|
||||
if (isLastSigner) {
|
||||
if (submittedBy) {
|
||||
userSet.add(submittedBy)
|
||||
}
|
||||
|
||||
signers.forEach((signer) => {
|
||||
userSet.add(npubToHex(signer)!)
|
||||
})
|
||||
|
||||
viewers.forEach((viewer) => {
|
||||
userSet.add(npubToHex(viewer)!)
|
||||
})
|
||||
} else {
|
||||
const usersNpub = hexToNpub(usersPubkey!)
|
||||
const signerIndex = signers.indexOf(usersNpub)
|
||||
const nextSigner = signers[signerIndex + 1]
|
||||
userSet.add(npubToHex(nextSigner)!)
|
||||
if (submittedBy) {
|
||||
userSet.add(submittedBy)
|
||||
}
|
||||
signers.forEach((signer) => {
|
||||
userSet.add(npubToHex(signer)!)
|
||||
})
|
||||
viewers.forEach((viewer) => {
|
||||
userSet.add(npubToHex(viewer)!)
|
||||
})
|
||||
|
||||
const keysFileContent = await generateKeysFile(
|
||||
Array.from(userSet),
|
||||
@ -637,7 +641,10 @@ export const VerifyPage = () => {
|
||||
|
||||
const handleExport = async () => {
|
||||
const arrayBuffer = await prepareZipExport()
|
||||
if (!arrayBuffer) return
|
||||
if (!arrayBuffer) {
|
||||
setIsLoading(false)
|
||||
return
|
||||
}
|
||||
|
||||
const blob = new Blob([arrayBuffer])
|
||||
saveAs(blob, `exported-${unixNow()}.sigit.zip`)
|
||||
@ -647,7 +654,10 @@ export const VerifyPage = () => {
|
||||
|
||||
const handleEncryptedExport = async () => {
|
||||
const arrayBuffer = await prepareZipExport()
|
||||
if (!arrayBuffer) return
|
||||
if (!arrayBuffer) {
|
||||
setIsLoading(false)
|
||||
return
|
||||
}
|
||||
|
||||
const key = await generateEncryptionKey()
|
||||
|
||||
@ -656,7 +666,11 @@ export const VerifyPage = () => {
|
||||
|
||||
const finalZipFile = await createFinalZipFile(encryptedArrayBuffer, key)
|
||||
|
||||
if (!finalZipFile) return
|
||||
if (!finalZipFile) {
|
||||
setIsLoading(false)
|
||||
return
|
||||
}
|
||||
|
||||
saveAs(finalZipFile, `exported-${unixNow()}.sigit.zip`)
|
||||
|
||||
setIsLoading(false)
|
||||
@ -678,7 +692,11 @@ export const VerifyPage = () => {
|
||||
setIsLoading(true)
|
||||
setLoadingSpinnerDesc('Signing nostr event')
|
||||
|
||||
const prevSig = getLastSignersSig(meta, signers)
|
||||
if (!meta) return Promise.resolve(null)
|
||||
|
||||
const signerService = new SignerService(meta)
|
||||
const prevSig = signerService.getLastSignerSig()
|
||||
|
||||
if (!prevSig) return Promise.resolve(null)
|
||||
|
||||
const signedEvent = await signEventForMetaFile(
|
||||
@ -716,6 +734,76 @@ export const VerifyPage = () => {
|
||||
return Promise.resolve(arrayBuffer)
|
||||
}
|
||||
|
||||
const reBroadcastSigit = async () => {
|
||||
const usersNpub = hexToNpub(usersPubkey!)
|
||||
|
||||
if (!encryptionKey) {
|
||||
toast.error('Encryption key is missing')
|
||||
return
|
||||
}
|
||||
|
||||
setIsLoading(true)
|
||||
setLoadingSpinnerDesc('storing meta on blossom server')
|
||||
|
||||
let metaUrl: string
|
||||
try {
|
||||
metaUrl = await uploadMetaToFileStorage(meta, encryptionKey)
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
toast.error(error.message)
|
||||
}
|
||||
console.error(error)
|
||||
setIsLoading(false)
|
||||
return
|
||||
}
|
||||
|
||||
const userSet = new Set<`npub1${string}`>()
|
||||
if (submittedBy && submittedBy !== usersPubkey) {
|
||||
userSet.add(hexToNpub(submittedBy))
|
||||
}
|
||||
|
||||
// add all the signers who have signed and next signer to userSet
|
||||
signers.forEach((signer) => {
|
||||
// skip current user
|
||||
if (signer === usersNpub) return
|
||||
|
||||
if (signersStatus[signer] === SignStatus.Signed) {
|
||||
userSet.add(signer)
|
||||
} else if (signersStatus[signer] === SignStatus.Awaiting) {
|
||||
userSet.add(signer)
|
||||
}
|
||||
})
|
||||
|
||||
// If all signers have signed then include viewers too
|
||||
if (
|
||||
signers.every((signer) => signersStatus[signer] === SignStatus.Signed)
|
||||
) {
|
||||
viewers.forEach((viewer) => {
|
||||
// skip current user
|
||||
if (viewer === usersNpub) return
|
||||
|
||||
userSet.add(viewer)
|
||||
})
|
||||
}
|
||||
|
||||
setLoadingSpinnerDesc('Sending notifications')
|
||||
const users = Array.from(userSet)
|
||||
const promises = users.map((user) =>
|
||||
sendNotification(npubToHex(user)!, { metaUrl, keys: meta.keys })
|
||||
)
|
||||
|
||||
await Promise.all(promises)
|
||||
.then(() => {
|
||||
toast.success('Notifications sent successfully')
|
||||
setMeta(meta)
|
||||
})
|
||||
.catch(() => {
|
||||
toast.error('Failed to publish notifications')
|
||||
})
|
||||
|
||||
setIsLoading(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{isLoading && <LoadingSpinner desc={loadingSpinnerDesc} />}
|
||||
@ -739,7 +827,10 @@ export const VerifyPage = () => {
|
||||
|
||||
{selectedFile && (
|
||||
<Box sx={{ mt: 2, display: 'flex', justifyContent: 'center' }}>
|
||||
<Button onClick={handleVerify} variant="contained">
|
||||
<Button
|
||||
onClick={() => handleVerify(selectedFile)}
|
||||
variant="contained"
|
||||
>
|
||||
Verify
|
||||
</Button>
|
||||
</Box>
|
||||
@ -761,6 +852,7 @@ export const VerifyPage = () => {
|
||||
setCurrentFile={setCurrentFile}
|
||||
handleExport={handleExport}
|
||||
handleEncryptedExport={handleEncryptedExport}
|
||||
reBroadcastSigit={reBroadcastSigit}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
21
src/routes/PrivateRoute.tsx
Normal file
21
src/routes/PrivateRoute.tsx
Normal file
@ -0,0 +1,21 @@
|
||||
import { Navigate, useLocation } from 'react-router-dom'
|
||||
import { useAppSelector } from '../hooks'
|
||||
import { appPublicRoutes } from '.'
|
||||
|
||||
export function PrivateRoute({ children }: { children: JSX.Element }) {
|
||||
const location = useLocation()
|
||||
const isLoggedIn = useAppSelector((state) => state.auth?.loggedIn)
|
||||
if (!isLoggedIn) {
|
||||
return (
|
||||
<Navigate
|
||||
to={{
|
||||
pathname: appPublicRoutes.landingPage,
|
||||
search: `?callbackPath=${btoa(location.pathname)}`
|
||||
}}
|
||||
replace
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
return children
|
||||
}
|
@ -4,9 +4,7 @@ export const appPrivateRoutes = {
|
||||
homePage: '/',
|
||||
create: '/create',
|
||||
sign: '/sign',
|
||||
settings: '/settings',
|
||||
profileSettings: '/settings/profile/:npub',
|
||||
cacheSettings: '/settings/cache',
|
||||
profileSettings: '/settings/profile',
|
||||
relays: '/settings/relays',
|
||||
nostrLogin: '/settings/nostrLogin'
|
||||
}
|
||||
@ -24,6 +22,3 @@ export const appPublicRoutes = {
|
||||
|
||||
export const getProfileRoute = (hexKey: string) =>
|
||||
appPublicRoutes.profile.replace(':npub', hexToNpub(hexKey))
|
||||
|
||||
export const getProfileSettingsRoute = (hexKey: string) =>
|
||||
appPrivateRoutes.profileSettings.replace(':npub', hexToNpub(hexKey))
|
||||
|
@ -4,13 +4,13 @@ import { CreatePage } from '../pages/create'
|
||||
import { HomePage } from '../pages/home'
|
||||
import { LandingPage } from '../pages/landing'
|
||||
import { ProfilePage } from '../pages/profile'
|
||||
import { CacheSettingsPage } from '../pages/settings/cache'
|
||||
import { NostrLoginPage } from '../pages/settings/nostrLogin'
|
||||
import { ProfileSettingsPage } from '../pages/settings/profile'
|
||||
import { RelaysPage } from '../pages/settings/relays'
|
||||
import { SettingsPage } from '../pages/settings/Settings'
|
||||
import { SettingsLayout } from '../pages/settings/Settings'
|
||||
import { SignPage } from '../pages/sign'
|
||||
import { VerifyPage } from '../pages/verify'
|
||||
import { PrivateRoute } from './PrivateRoute'
|
||||
|
||||
/**
|
||||
* Helper type allows for extending react-router-dom's **RouteProps** with generic type
|
||||
@ -37,7 +37,7 @@ export function recursiveRouteRenderer<T>(
|
||||
return routes.map((route, index) =>
|
||||
renderConditionCallbackFn(route) ? (
|
||||
<Route
|
||||
key={`${route.path}${index}`}
|
||||
key={route.path ? `${route.path}${index}` : index}
|
||||
path={route.path}
|
||||
element={route.element}
|
||||
>
|
||||
@ -67,37 +67,50 @@ export const publicRoutes: PublicRouteProps[] = [
|
||||
}
|
||||
]
|
||||
|
||||
export const privateRoutes = [
|
||||
export const privateRoutes: CustomRouteProps<unknown>[] = [
|
||||
{
|
||||
path: appPrivateRoutes.homePage,
|
||||
element: <HomePage />
|
||||
element: (
|
||||
<PrivateRoute>
|
||||
<HomePage />
|
||||
</PrivateRoute>
|
||||
)
|
||||
},
|
||||
{
|
||||
path: appPrivateRoutes.create,
|
||||
element: <CreatePage />
|
||||
element: (
|
||||
<PrivateRoute>
|
||||
<CreatePage />
|
||||
</PrivateRoute>
|
||||
)
|
||||
},
|
||||
{
|
||||
path: `${appPrivateRoutes.sign}/:id?`,
|
||||
element: <SignPage />
|
||||
element: (
|
||||
<PrivateRoute>
|
||||
<SignPage />
|
||||
</PrivateRoute>
|
||||
)
|
||||
},
|
||||
{
|
||||
path: appPrivateRoutes.settings,
|
||||
element: <SettingsPage />
|
||||
},
|
||||
{
|
||||
path: appPrivateRoutes.profileSettings,
|
||||
element: <ProfileSettingsPage />
|
||||
},
|
||||
{
|
||||
path: appPrivateRoutes.cacheSettings,
|
||||
element: <CacheSettingsPage />
|
||||
},
|
||||
{
|
||||
path: appPrivateRoutes.relays,
|
||||
element: <RelaysPage />
|
||||
},
|
||||
{
|
||||
path: appPrivateRoutes.nostrLogin,
|
||||
element: <NostrLoginPage />
|
||||
element: (
|
||||
<PrivateRoute>
|
||||
<SettingsLayout />
|
||||
</PrivateRoute>
|
||||
),
|
||||
children: [
|
||||
{
|
||||
path: appPrivateRoutes.profileSettings,
|
||||
element: <ProfileSettingsPage />
|
||||
},
|
||||
{
|
||||
path: appPrivateRoutes.relays,
|
||||
element: <RelaysPage />
|
||||
},
|
||||
{
|
||||
path: appPrivateRoutes.nostrLogin,
|
||||
element: <NostrLoginPage />
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
86
src/services/cache/index.ts
vendored
86
src/services/cache/index.ts
vendored
@ -1,86 +0,0 @@
|
||||
import { IDBPDatabase, openDB } from 'idb'
|
||||
import { Event } from 'nostr-tools'
|
||||
import { CachedEvent } from '../../types'
|
||||
import { SchemaV2 } from './schema'
|
||||
|
||||
class LocalCache {
|
||||
// Static property to hold the single instance of LocalCache
|
||||
private static instance: LocalCache | null = null
|
||||
private db!: IDBPDatabase<SchemaV2>
|
||||
|
||||
// Private constructor to prevent direct instantiation
|
||||
private constructor() {}
|
||||
|
||||
// Method to initialize the database
|
||||
private async init() {
|
||||
this.db = await openDB<SchemaV2>('sigit-cache', 2, {
|
||||
upgrade(db, oldVersion) {
|
||||
if (oldVersion < 1) {
|
||||
db.createObjectStore('userMetadata', { keyPath: 'event.pubkey' })
|
||||
}
|
||||
|
||||
if (oldVersion < 2) {
|
||||
const v6 = db as unknown as IDBPDatabase<SchemaV2>
|
||||
|
||||
v6.createObjectStore('userRelayListMetadata', {
|
||||
keyPath: 'event.pubkey'
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Static method to get the single instance of LocalCache
|
||||
public static async getInstance(): Promise<LocalCache> {
|
||||
// If the instance doesn't exist, create it
|
||||
if (!LocalCache.instance) {
|
||||
LocalCache.instance = new LocalCache()
|
||||
await LocalCache.instance.init()
|
||||
}
|
||||
// Return the single instance of LocalCache
|
||||
return LocalCache.instance
|
||||
}
|
||||
|
||||
// Method to add user metadata
|
||||
public async addUserMetadata(event: Event) {
|
||||
await this.db.put('userMetadata', { event, cachedAt: Date.now() })
|
||||
}
|
||||
|
||||
// Method to get user metadata by key
|
||||
public async getUserMetadata(key: string): Promise<CachedEvent | null> {
|
||||
const data = await this.db.get('userMetadata', key)
|
||||
return data || null
|
||||
}
|
||||
|
||||
// Method to delete user metadata by key
|
||||
public async deleteUserMetadata(key: string) {
|
||||
await this.db.delete('userMetadata', key)
|
||||
}
|
||||
|
||||
public async addUserRelayListMetadata(event: Event) {
|
||||
await this.db.put('userRelayListMetadata', { event, cachedAt: Date.now() })
|
||||
}
|
||||
|
||||
public async getUserRelayListMetadata(
|
||||
key: string
|
||||
): Promise<CachedEvent | null> {
|
||||
const data = await this.db.get('userRelayListMetadata', key)
|
||||
return data || null
|
||||
}
|
||||
|
||||
public async deleteUserRelayListMetadata(key: string) {
|
||||
await this.db.delete('userRelayListMetadata', key)
|
||||
}
|
||||
|
||||
// Method to clear cache data
|
||||
public async clearCacheData() {
|
||||
// Clear the 'userMetadata' store in the IndexedDB database
|
||||
await this.db.clear('userMetadata')
|
||||
|
||||
// Reload the current page to ensure any cached data is reset
|
||||
window.location.reload()
|
||||
}
|
||||
}
|
||||
|
||||
// Export the single instance of LocalCache
|
||||
export const localCache = await LocalCache.getInstance()
|
16
src/services/cache/schema.ts
vendored
16
src/services/cache/schema.ts
vendored
@ -1,16 +0,0 @@
|
||||
import { DBSchema } from 'idb'
|
||||
import { CachedEvent } from '../../types'
|
||||
|
||||
export interface SchemaV1 extends DBSchema {
|
||||
userMetadata: {
|
||||
key: string
|
||||
value: CachedEvent
|
||||
}
|
||||
}
|
||||
|
||||
export interface SchemaV2 extends SchemaV1 {
|
||||
userRelayListMetadata: {
|
||||
key: string
|
||||
value: CachedEvent
|
||||
}
|
||||
}
|
@ -1 +1 @@
|
||||
export * from './cache'
|
||||
export * from './signer'
|
||||
|
143
src/services/signer/index.ts
Normal file
143
src/services/signer/index.ts
Normal file
@ -0,0 +1,143 @@
|
||||
import { toast } from 'react-toastify'
|
||||
import { Meta, SignedEventContent } from '../../types'
|
||||
import {
|
||||
parseCreateSignatureEventContent,
|
||||
parseNostrEvent,
|
||||
SigitStatus,
|
||||
SignStatus
|
||||
} from '../../utils'
|
||||
import { MetaParseError } from '../../types/errors/MetaParseError'
|
||||
import { verifyEvent } from 'nostr-tools'
|
||||
import { appPrivateRoutes, appPublicRoutes } from '../../routes'
|
||||
|
||||
export class SignerService {
|
||||
#signers: `npub1${string}`[] = []
|
||||
#nextSigner: `npub1${string}` | undefined
|
||||
#signatures = new Map<`npub1${string}`, string>()
|
||||
#signersStatus = new Map<`npub1${string}`, SignStatus>()
|
||||
#lastSignerSig: string | undefined
|
||||
constructor(source: Meta) {
|
||||
this.#process(source.createSignature, source.docSignatures)
|
||||
}
|
||||
|
||||
getNextSigner = () => {
|
||||
return this.#nextSigner
|
||||
}
|
||||
|
||||
isNextSigner = (npub: `npub1${string}`) => {
|
||||
return this.#nextSigner === npub
|
||||
}
|
||||
|
||||
isLastSigner = (npub: `npub1${string}`) => {
|
||||
const lastIndex = this.#signers.length - 1
|
||||
const npubIndex = this.#signers.indexOf(npub)
|
||||
return npubIndex === lastIndex
|
||||
}
|
||||
|
||||
#isFullySigned = () => {
|
||||
const signedBy = Object.keys(this.#signatures) as `npub1${string}`[]
|
||||
const isCompletelySigned = this.#signers.every((signer) =>
|
||||
signedBy.includes(signer)
|
||||
)
|
||||
return isCompletelySigned
|
||||
}
|
||||
|
||||
getSignedStatus = () => {
|
||||
return this.#isFullySigned() ? SigitStatus.Complete : SigitStatus.Partial
|
||||
}
|
||||
|
||||
getSignerStatus = (npub: `npub1${string}`) => {
|
||||
return this.#signersStatus.get(npub)
|
||||
}
|
||||
|
||||
getNavigate = (npub: `npub1${string}`) => {
|
||||
return this.isNextSigner(npub)
|
||||
? appPrivateRoutes.sign
|
||||
: appPublicRoutes.verify
|
||||
}
|
||||
|
||||
getLastSignerSig = () => {
|
||||
return this.#lastSignerSig
|
||||
}
|
||||
|
||||
#process = (
|
||||
createSignature: string,
|
||||
docSignatures: { [key: `npub1${string}`]: string }
|
||||
) => {
|
||||
try {
|
||||
const createSignatureEvent = parseNostrEvent(createSignature)
|
||||
const { signers } = parseCreateSignatureEventContent(
|
||||
createSignatureEvent.content
|
||||
)
|
||||
const getPrevSignerSig = (npub: `npub1${string}`) => {
|
||||
if (signers[0] === npub) {
|
||||
return createSignatureEvent.sig
|
||||
}
|
||||
|
||||
// Find the index of signer
|
||||
const currentSignerIndex = signers.findIndex(
|
||||
(signer) => signer === npub
|
||||
)
|
||||
|
||||
// Return if could not found user in signer's list
|
||||
if (currentSignerIndex === -1) return
|
||||
|
||||
// Find prev signer
|
||||
const prevSigner = signers[currentSignerIndex - 1]
|
||||
|
||||
// Get the signature of prev signer
|
||||
return this.#signatures.get(prevSigner)
|
||||
}
|
||||
|
||||
this.#signers = [...signers]
|
||||
for (const npub in docSignatures) {
|
||||
try {
|
||||
// Parse each signature event
|
||||
const event = parseNostrEvent(docSignatures[npub as `npub1${string}`])
|
||||
this.#signatures.set(npub as `npub1${string}`, event.sig)
|
||||
const isValidSignature = verifyEvent(event)
|
||||
if (isValidSignature) {
|
||||
const prevSignersSig = getPrevSignerSig(npub as `npub1${string}`)
|
||||
const signedEvent: SignedEventContent = JSON.parse(event.content)
|
||||
if (
|
||||
signedEvent.prevSig &&
|
||||
prevSignersSig &&
|
||||
signedEvent.prevSig === prevSignersSig
|
||||
) {
|
||||
this.#signersStatus.set(
|
||||
npub as `npub1${string}`,
|
||||
SignStatus.Signed
|
||||
)
|
||||
this.#lastSignerSig = event.sig
|
||||
}
|
||||
} else {
|
||||
this.#signersStatus.set(
|
||||
npub as `npub1${string}`,
|
||||
SignStatus.Invalid
|
||||
)
|
||||
}
|
||||
} catch (error) {
|
||||
this.#signersStatus.set(npub as `npub1${string}`, SignStatus.Invalid)
|
||||
}
|
||||
}
|
||||
|
||||
this.#signers
|
||||
.filter((s) => !this.#signatures.has(s))
|
||||
.forEach((s) => this.#signersStatus.set(s, SignStatus.Pending))
|
||||
|
||||
// Get the first signer that hasn't signed
|
||||
const nextSigner = this.#signers.find((s) => !this.#signatures.has(s))
|
||||
if (nextSigner) {
|
||||
this.#nextSigner = nextSigner
|
||||
this.#signersStatus.set(nextSigner, SignStatus.Awaiting)
|
||||
}
|
||||
} catch (error) {
|
||||
if (error instanceof MetaParseError) {
|
||||
toast.error(error.message)
|
||||
console.error(error.name, error.message, error.cause, error.context)
|
||||
} else {
|
||||
console.error('Unexpected error', error)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
import { Mark } from './mark'
|
||||
import { Keys } from '../store/auth/types'
|
||||
import { Event } from 'nostr-tools'
|
||||
import { SigitStatus, SignStatus } from '../utils'
|
||||
|
||||
export enum UserRole {
|
||||
signer = 'Signer',
|
||||
@ -35,11 +36,6 @@ export interface SignedEventContent {
|
||||
marks: Mark[]
|
||||
}
|
||||
|
||||
export interface Sigit {
|
||||
fileUrl: string
|
||||
meta: Meta
|
||||
}
|
||||
|
||||
export interface OpenTimestamp {
|
||||
nostrId: string
|
||||
value: string
|
||||
@ -92,3 +88,43 @@ export interface SigitNotification {
|
||||
export function isSigitNotification(obj: unknown): obj is SigitNotification {
|
||||
return typeof (obj as SigitNotification).metaUrl === 'string'
|
||||
}
|
||||
|
||||
/**
|
||||
* Flattened interface that combines properties `Meta`, `CreateSignatureEventContent`,
|
||||
* and `Event` (event's fields are made optional and pubkey and created_at replaced with our versions)
|
||||
*/
|
||||
export interface FlatMeta
|
||||
extends Meta,
|
||||
CreateSignatureEventContent,
|
||||
Partial<Omit<Event, 'pubkey' | 'created_at'>> {
|
||||
submittedBy?: string
|
||||
|
||||
// Optional field only present on exported sigits
|
||||
// Exporting adds user's pubkey
|
||||
exportedBy?: string
|
||||
|
||||
// Remove created_at and replace with createdAt
|
||||
createdAt?: number
|
||||
|
||||
// Validated create signature event
|
||||
isValid: boolean
|
||||
|
||||
// Decryption
|
||||
encryptionKey: string | undefined
|
||||
|
||||
// Parsed Document Signatures
|
||||
parsedSignatureEvents: {
|
||||
[signer: `npub1${string}`]: DocSignatureEvent
|
||||
}
|
||||
|
||||
// Calculated completion time
|
||||
completedAt?: number
|
||||
|
||||
// Calculated status fields
|
||||
signedStatus: SigitStatus
|
||||
signersStatus: {
|
||||
[signer: `npub1${string}`]: SignStatus
|
||||
}
|
||||
|
||||
timestamps?: OpenTimestamp[]
|
||||
}
|
||||
|
21
src/types/draft.ts
Normal file
21
src/types/draft.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { SigitFile } from '../utils/file'
|
||||
import { User } from './core'
|
||||
import { DrawnField } from './drawing'
|
||||
|
||||
export interface SigitFileDraft {
|
||||
name: string
|
||||
file: string
|
||||
pages: DrawnField[][]
|
||||
}
|
||||
export interface SigitDraft {
|
||||
title: string
|
||||
users: User[]
|
||||
files: SigitFile[]
|
||||
lastUpdated: number
|
||||
}
|
||||
export interface SerializedSigitDraft {
|
||||
title: string
|
||||
lastUpdated: number
|
||||
users: User[]
|
||||
files: SigitFileDraft[]
|
||||
}
|
23
src/types/errors/SendDMError.ts
Normal file
23
src/types/errors/SendDMError.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { Jsonable } from '.'
|
||||
|
||||
export enum SendDMErrorType {
|
||||
'MISSING_RECIEVER' = 'Sending DM failed. Reciever is required.',
|
||||
'ENCRYPTION_FAILED' = 'Sending DM failed. An error occurred in encrypting dm message.',
|
||||
'RELAY_PUBLISH_FAILED' = 'Sending DM failed. Publishing events failed.'
|
||||
}
|
||||
|
||||
export class SendDMError extends Error {
|
||||
public readonly context?: Jsonable
|
||||
|
||||
constructor(
|
||||
message: string,
|
||||
options: { cause?: Error; context?: Jsonable } = {}
|
||||
) {
|
||||
const { cause, context } = options
|
||||
|
||||
super(message, { cause })
|
||||
this.name = this.constructor.name
|
||||
|
||||
this.context = context
|
||||
}
|
||||
}
|
@ -4,3 +4,5 @@ export * from './nostr'
|
||||
export * from './relay'
|
||||
export * from './zip'
|
||||
export * from './event'
|
||||
export * from './drawing'
|
||||
export * from './draft'
|
||||
|
120
src/utils/draft.ts
Normal file
120
src/utils/draft.ts
Normal file
@ -0,0 +1,120 @@
|
||||
import {
|
||||
DrawnField,
|
||||
SerializedSigitDraft,
|
||||
SigitDraft,
|
||||
SigitFileDraft
|
||||
} from '../types'
|
||||
import {
|
||||
getMediaType,
|
||||
extractFileExtension,
|
||||
toFile,
|
||||
getSigitFile
|
||||
} from './file'
|
||||
const DRAFT_KEY = 'sigitDraft'
|
||||
let saveSigitDraftTimeout: number | null = null
|
||||
const serializeSigitDraft = async (
|
||||
draft: SigitDraft
|
||||
): Promise<SerializedSigitDraft> => {
|
||||
const serializedFiles = draft.files.map((file) => {
|
||||
return new Promise<SigitFileDraft>((resolve, reject) => {
|
||||
const reader = new FileReader()
|
||||
reader.onload = () => {
|
||||
const pages = file.pages
|
||||
? file.pages.map((page) =>
|
||||
page.drawnFields.map(
|
||||
(field) =>
|
||||
({
|
||||
left: field.left,
|
||||
top: field.top,
|
||||
width: field.width,
|
||||
height: field.height,
|
||||
type: field.type,
|
||||
counterpart: field.counterpart
|
||||
}) as DrawnField
|
||||
)
|
||||
)
|
||||
: []
|
||||
resolve({
|
||||
name: file.name,
|
||||
pages: pages,
|
||||
file: reader.result as string
|
||||
})
|
||||
}
|
||||
reader.onerror = (error) => reject(error)
|
||||
reader.readAsDataURL(file)
|
||||
})
|
||||
})
|
||||
|
||||
const serializedFileDraft = await Promise.all(serializedFiles)
|
||||
return {
|
||||
title: draft.title,
|
||||
lastUpdated: draft.lastUpdated,
|
||||
users: [...draft.users],
|
||||
files: serializedFileDraft
|
||||
}
|
||||
}
|
||||
|
||||
const deserializeSigitDraft = async (
|
||||
serializedDraft: SerializedSigitDraft
|
||||
): Promise<SigitDraft> => {
|
||||
const files = await Promise.all(
|
||||
serializedDraft.files.map(async (draft) => {
|
||||
const response = await fetch(draft.file)
|
||||
const arrayBuffer = await response.arrayBuffer()
|
||||
const type = getMediaType(extractFileExtension(draft.name))
|
||||
const file = toFile(arrayBuffer, draft.name, type)
|
||||
const sigitFile = await getSigitFile(file)
|
||||
if (draft.pages) {
|
||||
for (let i = 0; i < draft.pages.length; i++) {
|
||||
const drawnFields = draft.pages[i]
|
||||
if (sigitFile.pages) sigitFile.pages[i].drawnFields = [...drawnFields]
|
||||
}
|
||||
}
|
||||
return sigitFile
|
||||
})
|
||||
)
|
||||
|
||||
return {
|
||||
...serializedDraft,
|
||||
files: files
|
||||
}
|
||||
}
|
||||
|
||||
export const saveSigitDraft = (draft: SigitDraft): Promise<void> => {
|
||||
if (saveSigitDraftTimeout) {
|
||||
clearTimeout(saveSigitDraftTimeout)
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
saveSigitDraftTimeout = window.setTimeout(() => {
|
||||
serializeSigitDraft(draft)
|
||||
.then((draftToSave) => {
|
||||
localStorage.setItem(DRAFT_KEY, JSON.stringify(draftToSave))
|
||||
resolve()
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error)
|
||||
})
|
||||
}, 1000)
|
||||
})
|
||||
}
|
||||
|
||||
export const hasSigitDraft = () => {
|
||||
return DRAFT_KEY in localStorage
|
||||
}
|
||||
|
||||
export const getSigitDraft = async () => {
|
||||
const sigitDraft = localStorage.getItem(DRAFT_KEY)
|
||||
if (!sigitDraft) return null
|
||||
|
||||
try {
|
||||
const serializedDraft = JSON.parse(sigitDraft) as SerializedSigitDraft
|
||||
return await deserializeSigitDraft(serializedDraft)
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
export const clearSigitDraft = () => {
|
||||
localStorage.removeItem(DRAFT_KEY)
|
||||
}
|
@ -12,3 +12,4 @@ export * from './string'
|
||||
export * from './url'
|
||||
export * from './utils'
|
||||
export * from './zip'
|
||||
export * from './draft'
|
||||
|
@ -26,30 +26,6 @@ export const clearState = () => {
|
||||
localStorage.removeItem('state')
|
||||
}
|
||||
|
||||
export const saveVisitedLink = (pathname: string, search: string) => {
|
||||
localStorage.setItem(
|
||||
'visitedLink',
|
||||
JSON.stringify({
|
||||
pathname,
|
||||
search
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
export const getVisitedLink = () => {
|
||||
const visitedLink = localStorage.getItem('visitedLink')
|
||||
if (!visitedLink) return null
|
||||
|
||||
try {
|
||||
return JSON.parse(visitedLink) as {
|
||||
pathname: string
|
||||
search: string
|
||||
}
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
export const saveAuthToken = (token: string) => {
|
||||
localStorage.setItem('authToken', token)
|
||||
}
|
||||
@ -66,3 +42,47 @@ export const clear = () => {
|
||||
clearAuthToken()
|
||||
clearState()
|
||||
}
|
||||
|
||||
export function mergeWithInitialValue<T>(storedValue: T, initialValue: T): T {
|
||||
if (
|
||||
!Array.isArray(storedValue) &&
|
||||
typeof storedValue === 'object' &&
|
||||
storedValue !== null
|
||||
) {
|
||||
return { ...initialValue, ...storedValue }
|
||||
}
|
||||
return storedValue
|
||||
}
|
||||
|
||||
export function getLocalStorageItem<T>(key: string, defaultValue: T): string {
|
||||
try {
|
||||
const data = window.localStorage.getItem(key)
|
||||
if (data === null) return JSON.stringify(defaultValue)
|
||||
return data
|
||||
} catch (err) {
|
||||
console.error(`Error while fetching local storage value: `, err)
|
||||
return JSON.stringify(defaultValue)
|
||||
}
|
||||
}
|
||||
|
||||
export function setLocalStorageItem(key: string, value: string) {
|
||||
try {
|
||||
window.localStorage.setItem(key, value)
|
||||
dispatchLocalStorageEvent(key, value)
|
||||
} catch (err) {
|
||||
console.error(`Error while saving local storage value: `, err)
|
||||
}
|
||||
}
|
||||
|
||||
export function removeLocalStorageItem(key: string) {
|
||||
try {
|
||||
window.localStorage.removeItem(key)
|
||||
dispatchLocalStorageEvent(key, null)
|
||||
} catch (err) {
|
||||
console.error(`Error while deleting local storage value: `, err)
|
||||
}
|
||||
}
|
||||
|
||||
function dispatchLocalStorageEvent(key: string, newValue: string | null) {
|
||||
window.dispatchEvent(new StorageEvent('storage', { key, newValue }))
|
||||
}
|
||||
|
@ -171,20 +171,17 @@ export const DEFAULT_TOOLBOX: DrawTool[] = [
|
||||
{
|
||||
identifier: MarkType.FULLNAME,
|
||||
icon: faIdCard,
|
||||
label: 'Full Name',
|
||||
isComingSoon: true
|
||||
label: 'Full Name'
|
||||
},
|
||||
{
|
||||
identifier: MarkType.JOBTITLE,
|
||||
icon: faBriefcase,
|
||||
label: 'Job Title',
|
||||
isComingSoon: true
|
||||
label: 'Job Title'
|
||||
},
|
||||
{
|
||||
identifier: MarkType.DATETIME,
|
||||
icon: faClock,
|
||||
label: 'Date Time',
|
||||
isComingSoon: true
|
||||
label: 'Date Time'
|
||||
},
|
||||
{
|
||||
identifier: MarkType.NUMBER,
|
||||
@ -270,21 +267,10 @@ export const getToolboxLabelByMarkType = (markType: MarkType) => {
|
||||
return DEFAULT_TOOLBOX.find((t) => t.identifier === markType)?.label
|
||||
}
|
||||
|
||||
export const getOptimizedPathsWithStrokeWidth = (svgString: string) => {
|
||||
const parser = new DOMParser()
|
||||
const xmlDoc = parser.parseFromString(svgString, 'image/svg+xml')
|
||||
const paths = xmlDoc.querySelectorAll('path')
|
||||
const tuples: string[][] = []
|
||||
paths.forEach((path) => {
|
||||
const d = path.getAttribute('d') ?? ''
|
||||
const strokeWidth = path.getAttribute('stroke-width') ?? ''
|
||||
tuples.push([d, strokeWidth])
|
||||
})
|
||||
|
||||
return tuples
|
||||
}
|
||||
|
||||
export const processMarks = async (marks: Mark[], encryptionKey?: string) => {
|
||||
export const encryptAndUploadMarks = async (
|
||||
marks: Mark[],
|
||||
encryptionKey?: string
|
||||
) => {
|
||||
const _marks = [...marks]
|
||||
for (let i = 0; i < _marks.length; i++) {
|
||||
const mark = _marks[i]
|
||||
|
@ -31,7 +31,8 @@ export enum SignStatus {
|
||||
|
||||
export enum SigitStatus {
|
||||
Partial = 'In-Progress',
|
||||
Complete = 'Completed'
|
||||
Complete = 'Completed',
|
||||
LocalDraft = 'Draft'
|
||||
}
|
||||
|
||||
export interface SigitCardDisplayInfo {
|
||||
@ -49,9 +50,9 @@ export interface SigitCardDisplayInfo {
|
||||
* @param raw Raw string for parsing
|
||||
* @returns parsed Event
|
||||
*/
|
||||
export const parseNostrEvent = async (raw: string): Promise<Event> => {
|
||||
export const parseNostrEvent = (raw: string): Event => {
|
||||
try {
|
||||
const event = await parseJson<Event>(raw)
|
||||
const event = JSON.parse(raw) as Event
|
||||
return event
|
||||
} catch (error) {
|
||||
throw new MetaParseError(MetaParseErrorType.PARSE_ERROR_EVENT, {
|
||||
@ -66,12 +67,13 @@ export const parseNostrEvent = async (raw: string): Promise<Event> => {
|
||||
* @param raw Raw string for parsing
|
||||
* @returns parsed CreateSignatureEventContent
|
||||
*/
|
||||
export const parseCreateSignatureEventContent = async (
|
||||
export const parseCreateSignatureEventContent = (
|
||||
raw: string
|
||||
): Promise<CreateSignatureEventContent> => {
|
||||
): CreateSignatureEventContent => {
|
||||
try {
|
||||
const createSignatureEventContent =
|
||||
await parseJson<CreateSignatureEventContent>(raw)
|
||||
const createSignatureEventContent = JSON.parse(
|
||||
raw
|
||||
) as CreateSignatureEventContent
|
||||
return createSignatureEventContent
|
||||
} catch (error) {
|
||||
throw new MetaParseError(
|
||||
@ -89,7 +91,7 @@ export const parseCreateSignatureEventContent = async (
|
||||
* @param meta Sigit metadata
|
||||
* @returns SigitCardDisplayInfo
|
||||
*/
|
||||
export const extractSigitCardDisplayInfo = async (meta: Meta) => {
|
||||
export const extractSigitCardDisplayInfo = (meta: Meta) => {
|
||||
if (!meta?.createSignature) return
|
||||
|
||||
const sigitInfo: SigitCardDisplayInfo = {
|
||||
@ -100,14 +102,14 @@ export const extractSigitCardDisplayInfo = async (meta: Meta) => {
|
||||
}
|
||||
|
||||
try {
|
||||
const createSignatureEvent = await parseNostrEvent(meta.createSignature)
|
||||
const createSignatureEvent = parseNostrEvent(meta.createSignature)
|
||||
|
||||
sigitInfo.isValid = verifyEvent(createSignatureEvent)
|
||||
|
||||
// created_at in nostr events are stored in seconds
|
||||
sigitInfo.createdAt = fromUnixTimestamp(createSignatureEvent.created_at)
|
||||
|
||||
const createSignatureContent = await parseCreateSignatureEventContent(
|
||||
const createSignatureContent = parseCreateSignatureEventContent(
|
||||
createSignatureEvent.content
|
||||
)
|
||||
|
||||
|
@ -6,6 +6,7 @@ import {
|
||||
Event,
|
||||
EventTemplate,
|
||||
UnsignedEvent,
|
||||
VerifiedEvent,
|
||||
finalizeEvent,
|
||||
generateSecretKey,
|
||||
getEventHash,
|
||||
@ -214,6 +215,12 @@ export const toUnixTimestamp = (date: number | Date) => {
|
||||
export const fromUnixTimestamp = (unix: number) => {
|
||||
return unix * 1000
|
||||
}
|
||||
export const randomTimeUpTo2DaysInThePast = (): number => {
|
||||
const now = Date.now()
|
||||
const twoDaysInMilliseconds = 2 * 24 * 60 * 60 * 1000
|
||||
const randomPastTime = now - Math.floor(Math.random() * twoDaysInMilliseconds)
|
||||
return toUnixTimestamp(randomPastTime)
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate nip44 conversation key
|
||||
@ -263,19 +270,21 @@ export const countLeadingZeroes = (hex: string) => {
|
||||
|
||||
/**
|
||||
* Function to create a wrapped event with PoW
|
||||
* @param event Original event to be wrapped
|
||||
* @param event Original event to be wrapped (can be unsigned or verified)
|
||||
* @param receiver Public key of the receiver
|
||||
* @param difficulty PoW difficulty level (default is 20)
|
||||
* @returns
|
||||
*/
|
||||
//
|
||||
export const createWrap = (unsignedEvent: UnsignedEvent, receiver: string) => {
|
||||
export const createWrap = (
|
||||
event: UnsignedEvent | VerifiedEvent,
|
||||
receiver: string
|
||||
) => {
|
||||
// Generate a random secret key and its corresponding public key
|
||||
const randomKey = generateSecretKey()
|
||||
const pubkey = getPublicKey(randomKey)
|
||||
|
||||
// Encrypt the event content using nip44 encryption
|
||||
const content = nip44Encrypt(unsignedEvent, randomKey, receiver)
|
||||
const content = nip44Encrypt(event, randomKey, receiver)
|
||||
|
||||
// Initialize nonce and leadingZeroes for PoW calculation
|
||||
let nonce = 0
|
||||
@ -286,11 +295,12 @@ export const createWrap = (unsignedEvent: UnsignedEvent, receiver: string) => {
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
while (true) {
|
||||
// Create an unsigned event with the necessary fields
|
||||
// TODO: kinds.GiftWrap (wrong kind number in nostr-tools 10/11/2024 at v2.7.2)
|
||||
const event: UnsignedEvent = {
|
||||
kind: 1059, // Event kind
|
||||
content, // Encrypted content
|
||||
pubkey, // Public key of the creator
|
||||
created_at: unixNow(), // Current timestamp
|
||||
created_at: randomTimeUpTo2DaysInThePast(),
|
||||
tags: [
|
||||
// Tags including receiver and nonce
|
||||
['p', receiver],
|
||||
|
@ -37,7 +37,6 @@ export const getRelayMapFromNDKRelayList = (ndkRelayList: NDKRelayList) => {
|
||||
export const getDefaultRelayMap = (): RelayMap => ({
|
||||
[SIGIT_RELAY]: { write: true, read: true }
|
||||
})
|
||||
|
||||
/**
|
||||
* Publishes relay map.
|
||||
* @param relayMap - relay map.
|
||||
|
@ -1,46 +1,11 @@
|
||||
import { Event } from 'nostr-tools'
|
||||
import { Meta } from '../types'
|
||||
|
||||
/**
|
||||
* This function returns the signature of last signer
|
||||
* It will be used in the content of export signature's signedEvent
|
||||
*/
|
||||
const getLastSignersSig = (
|
||||
meta: Meta,
|
||||
signers: `npub1${string}`[]
|
||||
): string | null => {
|
||||
// if there're no signers then use creator's signature
|
||||
if (signers.length === 0) {
|
||||
try {
|
||||
const createSignatureEvent: Event = JSON.parse(meta.createSignature)
|
||||
return createSignatureEvent.sig
|
||||
} catch (error) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
// get last signer
|
||||
const lastSigner = signers[signers.length - 1]
|
||||
|
||||
// get the signature of last signer
|
||||
try {
|
||||
const lastSignatureEvent: Event = JSON.parse(meta.docSignatures[lastSigner])
|
||||
return lastSignatureEvent.sig
|
||||
} catch (error) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if all signers have signed the sigit
|
||||
* @param signers - an array of npubs of all signers from the Sigit
|
||||
* @param signedBy - an array of npubs that have signed it already
|
||||
*/
|
||||
const isFullySigned = (
|
||||
export const isFullySigned = (
|
||||
signers: `npub1${string}`[],
|
||||
signedBy: `npub1${string}`[]
|
||||
): boolean => {
|
||||
return signers.every((signer) => signedBy.includes(signer))
|
||||
}
|
||||
|
||||
export { getLastSignersSig, isFullySigned }
|
||||
|
140
src/utils/zip.ts
140
src/utils/zip.ts
@ -1,6 +1,12 @@
|
||||
import JSZip from 'jszip'
|
||||
import { toast } from 'react-toastify'
|
||||
import { InputFileFormat, OutputByType, OutputType } from '../types'
|
||||
import { InputFileFormat, Meta, OutputByType, OutputType } from '../types'
|
||||
import { NavigateOptions, To } from 'react-router-dom'
|
||||
import { appPublicRoutes } from '../routes'
|
||||
import { NostrController } from '../controllers'
|
||||
import { decryptArrayBuffer } from './crypto'
|
||||
import { hexToNpub, parseJson, SigitStatus, timeout } from '.'
|
||||
import { SignerService } from '../services'
|
||||
|
||||
/**
|
||||
* Read the content of a file within a zip archive.
|
||||
@ -9,7 +15,7 @@ import { InputFileFormat, OutputByType, OutputType } from '../types'
|
||||
* @param outputType The type of output to return (e.g., 'string', 'arraybuffer', 'uint8array', etc.).
|
||||
* @returns A Promise resolving to the content of the file, or null if an error occurs.
|
||||
*/
|
||||
const readContentOfZipEntry = async <T extends OutputType>(
|
||||
export const readContentOfZipEntry = async <T extends OutputType>(
|
||||
zip: JSZip,
|
||||
filePath: string,
|
||||
outputType: T
|
||||
@ -34,7 +40,7 @@ const readContentOfZipEntry = async <T extends OutputType>(
|
||||
})
|
||||
}
|
||||
|
||||
const loadZip = async (data: InputFileFormat): Promise<JSZip | null> => {
|
||||
export const loadZip = async (data: InputFileFormat): Promise<JSZip | null> => {
|
||||
try {
|
||||
return await JSZip.loadAsync(data)
|
||||
} catch (err) {
|
||||
@ -46,4 +52,130 @@ const loadZip = async (data: InputFileFormat): Promise<JSZip | null> => {
|
||||
}
|
||||
}
|
||||
|
||||
export { readContentOfZipEntry, loadZip }
|
||||
export const decrypt = async (file: File) => {
|
||||
const nostrController = NostrController.getInstance()
|
||||
|
||||
const zip = await loadZip(file)
|
||||
if (!zip) return
|
||||
|
||||
const keysFileContent = await readContentOfZipEntry(
|
||||
zip,
|
||||
'keys.json',
|
||||
'string'
|
||||
)
|
||||
|
||||
if (!keysFileContent) return null
|
||||
|
||||
const parsedKeysJson = await parseJson<{ sender: string; keys: string[] }>(
|
||||
keysFileContent
|
||||
).catch((err) => {
|
||||
console.log(`Error parsing content of keys.json:`, err)
|
||||
toast.error(err.message || `Error parsing content of keys.json`)
|
||||
return null
|
||||
})
|
||||
|
||||
if (!parsedKeysJson) return
|
||||
|
||||
const encryptedArrayBuffer = await readContentOfZipEntry(
|
||||
zip,
|
||||
'compressed.sigit',
|
||||
'arraybuffer'
|
||||
)
|
||||
|
||||
if (!encryptedArrayBuffer) return
|
||||
|
||||
const { keys, sender } = parsedKeysJson
|
||||
|
||||
for (const key of keys) {
|
||||
// decrypt the encryptionKey, with timeout (duration = 60 seconds)
|
||||
const encryptionKey = await Promise.race([
|
||||
nostrController.nip04Decrypt(sender, key),
|
||||
timeout(60000)
|
||||
])
|
||||
.then((res) => {
|
||||
return res
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log('err :>> ', err)
|
||||
return null
|
||||
})
|
||||
|
||||
// Return if encryption failed
|
||||
if (!encryptionKey) continue
|
||||
|
||||
const arrayBuffer = await decryptArrayBuffer(
|
||||
encryptedArrayBuffer,
|
||||
encryptionKey
|
||||
).catch((err) => {
|
||||
console.log('err in decryption:>> ', err)
|
||||
return null
|
||||
})
|
||||
|
||||
if (arrayBuffer) return arrayBuffer
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
type NavigateArgs = { to: To; options?: NavigateOptions }
|
||||
export const navigateFromZip = async (file: File, pubkey: `npub1${string}`) => {
|
||||
if (!file.name.endsWith('.sigit.zip')) {
|
||||
toast.error(`Not a SiGit zip file: ${file.name}`)
|
||||
}
|
||||
|
||||
try {
|
||||
let zip = await JSZip.loadAsync(file)
|
||||
if (!zip) {
|
||||
return null
|
||||
}
|
||||
|
||||
let arrayBuffer: ArrayBuffer | undefined
|
||||
if ('keys.json' in zip.files) {
|
||||
// Decrypt
|
||||
const decryptedArrayBuffer = await decrypt(file).catch((err) => {
|
||||
console.error(`error occurred in decryption`, err)
|
||||
toast.error(err.message || `error occurred in decryption`)
|
||||
})
|
||||
|
||||
if (decryptedArrayBuffer) {
|
||||
// Replace the zip and continue processing
|
||||
zip = await JSZip.loadAsync(decryptedArrayBuffer)
|
||||
arrayBuffer = decryptedArrayBuffer
|
||||
}
|
||||
}
|
||||
|
||||
if ('meta.json' in zip.files) {
|
||||
// Check where we need to navigate
|
||||
// Find Meta and process it for signer state
|
||||
const metaContent = await readContentOfZipEntry(
|
||||
zip,
|
||||
'meta.json',
|
||||
'string'
|
||||
)
|
||||
if (metaContent) {
|
||||
const meta = JSON.parse(metaContent) as Meta
|
||||
const signerService = new SignerService(meta)
|
||||
|
||||
const to =
|
||||
signerService.getSignedStatus() === SigitStatus.Complete
|
||||
? appPublicRoutes.verify
|
||||
: signerService.getNavigate(hexToNpub(pubkey))
|
||||
|
||||
return {
|
||||
to,
|
||||
options: {
|
||||
state: { uploadedZip: arrayBuffer || file }
|
||||
}
|
||||
} as NavigateArgs
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
} catch (err) {
|
||||
console.error('err in processing sigit zip file :>> ', err)
|
||||
if (err instanceof Error) {
|
||||
toast.error(err.message || 'An error occurred in loading zip file.')
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ import { defineConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
import tsconfigPaths from 'vite-tsconfig-paths'
|
||||
import { nodePolyfills } from 'vite-plugin-node-polyfills'
|
||||
import zipPack from 'vite-plugin-zip-pack'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
@ -9,7 +10,8 @@ export default defineConfig({
|
||||
tsconfigPaths(),
|
||||
nodePolyfills({
|
||||
include: ['os']
|
||||
})
|
||||
}),
|
||||
zipPack()
|
||||
],
|
||||
build: {
|
||||
target: 'ES2022'
|
||||
|
Loading…
x
Reference in New Issue
Block a user