Skip to content
Snippets Groups Projects
Commit 07cb2516 authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Merge branch 'project/base32768' into 'project/HavenBeta'

Project/base32768

See merge request !128
parents a3a647a3 9dc7c711
No related branches found
No related tags found
2 merge requests!128Project/base32768,!109Project/haven beta
Showing
with 100 additions and 139 deletions
......@@ -11,20 +11,20 @@ build:
GOOS=js GOARCH=wasm go build ./...
update_release:
GOFLAGS="" go get gitlab.com/elixxir/wasm-utils@release
GOFLAGS="" go get gitlab.com/xx_network/primitives@release
GOFLAGS="" go get gitlab.com/elixxir/primitives@release
GOFLAGS="" go get gitlab.com/xx_network/crypto@release
GOFLAGS="" go get gitlab.com/elixxir/crypto@release
GOFLAGS="" go get -d gitlab.com/elixxir/client/v4@project/HavenBeta
GOFLAGS="" go get -d gitlab.com/elixxir/client/v4@release
GOFLAGS="" go get gitlab.com/elixxir/wasm-utils@release
update_master:
GOFLAGS="" go get gitlab.com/elixxir/wasm-utils@master
GOFLAGS="" go get gitlab.com/xx_network/primitives@master
GOFLAGS="" go get gitlab.com/elixxir/primitives@master
GOFLAGS="" go get gitlab.com/xx_network/crypto@master
GOFLAGS="" go get gitlab.com/elixxir/crypto@master
GOFLAGS="" go get -d gitlab.com/elixxir/client/v4@master
GOFLAGS="" go get gitlab.com/elixxir/wasm-utils@master
binary:
GOOS=js GOARCH=wasm go build -ldflags '-w -s' -trimpath -o xxdk.wasm main.go
......
......@@ -9,10 +9,10 @@ require (
github.com/spf13/cobra v1.7.0
github.com/spf13/jwalterweatherman v1.1.0
github.com/stretchr/testify v1.8.2
gitlab.com/elixxir/client/v4 v4.6.4-0.20230608163043-96d0be74ffb0
gitlab.com/elixxir/crypto v0.0.7-0.20230522162218-45433d877235
gitlab.com/elixxir/client/v4 v4.6.4-0.20230608170359-6f802c11e487
gitlab.com/elixxir/crypto v0.0.7-0.20230607170539-92d9508c78f9
gitlab.com/elixxir/primitives v0.0.3-0.20230214180039-9a25e2d3969c
gitlab.com/elixxir/wasm-utils v0.0.0-20230522231408-a43b2c1481b2
gitlab.com/elixxir/wasm-utils v0.0.0-20230607204433-22c46f9d680f
gitlab.com/xx_network/crypto v0.0.5-0.20230214003943-8a09396e95dd
gitlab.com/xx_network/primitives v0.0.4-0.20230522171102-940cdd68e516
golang.org/x/crypto v0.5.0
......@@ -21,6 +21,7 @@ require (
require (
filippo.io/edwards25519 v1.0.0 // indirect
git.xx.network/elixxir/grpc-web-go-client v0.0.0-20230214175953-5b5a8c33d28a // indirect
github.com/Max-Sum/base32768 v0.0.0-20230304063302-18e6ce5945fd // indirect
github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129 // indirect
github.com/badoux/checkmail v1.2.1 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
......
......@@ -43,6 +43,8 @@ git.xx.network/elixxir/grpc-web-go-client v0.0.0-20230214175953-5b5a8c33d28a/go.
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/Max-Sum/base32768 v0.0.0-20230304063302-18e6ce5945fd h1:nzE1YQBdx1bq9IlZinHa+HVffy+NmVRoKr+wHN8fpLE=
github.com/Max-Sum/base32768 v0.0.0-20230304063302-18e6ce5945fd/go.mod h1:C8yoIfvESpM3GD07OCHU7fqI7lhwyZ2Td1rbNbTAhnc=
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
......@@ -513,76 +515,22 @@ github.com/zeebo/pcg v1.0.1 h1:lyqfGeWiv4ahac6ttHs+I5hwtH/+1mrhlCtVNQM2kHo=
github.com/zeebo/pcg v1.0.1/go.mod h1:09F0S9iiKrwn9rlI5yjLkmrug154/YRW6KnnXVDM/l4=
gitlab.com/elixxir/bloomfilter v0.0.0-20230322223210-fa84f6842de8 h1:uAFCyBkXprQoPkcDDfxXtaMyL5x+xSGrAWzR907xROQ=
gitlab.com/elixxir/bloomfilter v0.0.0-20230322223210-fa84f6842de8/go.mod h1:1X8gRIAPDisS3W6Vtr/ymiUmZMJUIwDV1o5DEOo/pzw=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230525191042-3795029e4315 h1:rOgY9KPwq0wCQGM2VWzHQLidUwo/igqEbHvrfrX14NE=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230525191042-3795029e4315/go.mod h1:1+FU4spF6kwSA84AnFq0i6j4jsAICuvVfp6ACh00K0U=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230526074923-c0fb2a45c312 h1:yUyz1L/rzodZxUU45CeH7mfMfmKAs706+s2j2ZGUSwE=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230526074923-c0fb2a45c312/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230530165750-f6ea41bc69e4 h1:dgq4fwLdVzsPGdk1E7vLZI1gWk/QB/K7Rntg+DrxAjY=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230530165750-f6ea41bc69e4/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230530170051-243baab3da48 h1:2HP8w4HOlqjg0FcvSnhMmpwUa1pcU0WbvWMOUNiy/hE=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230530170051-243baab3da48/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230530182422-d12ab437257f h1:8TJwqKjeD0eZSvWIlPwjgIwfgdzcHhTzGwaiUJCwwuI=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230530182422-d12ab437257f/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230530201605-ba087da90ba2 h1:sxAgLmG2RLarBuXtcH8g5ZcQbAF9PmS3wrnlwZVFrLA=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230530201605-ba087da90ba2/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230530211720-a1bc89986df8 h1:XTklpI9leJYgZ4bYZLQUOzzgoxlYUz7xDmcl2Fy7knc=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230530211720-a1bc89986df8/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230530220505-726d2194d278 h1:etC7c2JeKbykuSHIm8jvb3cpMUdJGlyMsBQbImXlIK8=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230530220505-726d2194d278/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230530222715-a0c0ea0de57f h1:67k1pJg8w6bGfDLex3/e4rdm8Cb2m43qjrryKjVo/UE=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230530222715-a0c0ea0de57f/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230531180314-040f2bf4bc9f h1:KJQjb0WfOtrJo1vKGeISwlmdQTwtV3CmCg4nbP6bzlM=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230531180314-040f2bf4bc9f/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230531193105-0f398d814565 h1:kBbMa8AdCD/0KaLY7jIMk8yWsrRYSMb4zrdGRT4xZ6w=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230531193105-0f398d814565/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230531195028-ad25aee27c19 h1:OLZTJAqRm1hqGeeHs+aYZ9v3ojgiv+6qykC8+9pFBVM=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230531195028-ad25aee27c19/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230531195851-a65797612a21 h1:u4H7ITaOwO4aQoSJCo8zpfRpenaqgHuvjqF3GAe8RrE=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230531195851-a65797612a21/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230531212217-e21b55fbf23c h1:6OTyW9U/ntZ41Xry+8qDkOH4LoxhlyWTwKpAxi2fvZY=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230531212217-e21b55fbf23c/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230531224642-b24cd3f5e4a4 h1:YacWU7IJUfixfZyckdXEWPwhix7sq+STK+8Vz8DzVO4=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230531224642-b24cd3f5e4a4/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230601191407-1b0289b33708 h1:wNIKci4XuDfzAJM8+4awP5CgY0jlOEaVbHgp+BkEtz4=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230601191407-1b0289b33708/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230602201618-11b41b04386f h1:jwXyq/17fo5VxdQUDQiIfUHqr8m6Df1bV8wRjV4ssyw=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230602201618-11b41b04386f/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230602205033-94b7a8f73adf h1:n9P9trdEGTBQBhraTI800+ZTrNeahmb01uFtfuyaga0=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230602205033-94b7a8f73adf/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230605163131-05f3396132b7 h1:10vkqej0JYCBYgJqjclTBnfVpc3//SY015O69HbTaVA=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230605163131-05f3396132b7/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230605225443-4ab5e5b32c16 h1:OEiENhrAHDgSG5ZI3GLCgYr+e7sLKmYr/6AC+HBHdsc=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230605225443-4ab5e5b32c16/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230605230916-3e5554db4b70 h1:8GTmUVLfPasdreToIgnoduhwVvUeAnUnUs2btzgBr+0=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230605230916-3e5554db4b70/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230606161714-339cef753b8d h1:o7PqwDJ8fSoHc+AYX1InCD1uI2SmMkawwdJMvaxKjmY=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230606161714-339cef753b8d/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230606201910-fe9f57e3141f h1:JTPDrf4MsaYIuUOFTawEQLZ9rNbCA/SBENPUMFNFijY=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230606201910-fe9f57e3141f/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230606202433-a9136c29d24d h1:bh4tINZyGSZPS9TSOd9exPymYA9shMSvAqeslMGZFH0=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230606202433-a9136c29d24d/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230606205101-cc748980feed h1:UOrzm9I7ZwKSxl+3NKf3hyqHLfKlneE9ifx533bXMSg=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230606205101-cc748980feed/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230606205543-83a88c354a91 h1:7+XixtLZdt9jnDFKsOovfIFQ9Z3/hKNtxNOn3ixLhGQ=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230606205543-83a88c354a91/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230607192055-bb48aae366c4 h1:65ivQ2uhBNYPuxZAC9vMIH+4Sljzu2GD9tQpqcOkphk=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230607192055-bb48aae366c4/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230607195322-23fc4942a31f h1:bH4KKrsoMbIR0nga2F2kIVuTyAGfKvNtV8wd5JIbric=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230607195322-23fc4942a31f/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230608163043-96d0be74ffb0 h1:jkdITfmmBH8ou6ip43OvyplXrmZfnVrP+5Y6ZI0R2L0=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230608163043-96d0be74ffb0/go.mod h1:fegbuF1/6a+H3QgsoMG8teLnyuKtDxkELMw8pn5WlZ8=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230607172502-b56996e764f5 h1:TbuQ5a0HJifvNaUey1AnqpX8v/OPdb2GvNmHPy2hm9g=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230607172502-b56996e764f5/go.mod h1:LmbxL4WIT2qiDN7wzpcJG+U13jn3pSqUHtT1+uxN4VI=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230607204847-4a74a5fe2066 h1:NxTd/+AjbVkg+uzf1dIRF23AoDBDDI83jQ2lMJzdEcw=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230607204847-4a74a5fe2066/go.mod h1:GyXpu03l8AybmrGSq+AiKTuB+oJI5of78MdvdqFo29U=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230608170359-6f802c11e487 h1:th4mIU968ZuTd0ZhX6RakJKwgQ3zUESENXdlsWe9jco=
gitlab.com/elixxir/client/v4 v4.6.4-0.20230608170359-6f802c11e487/go.mod h1:GyXpu03l8AybmrGSq+AiKTuB+oJI5of78MdvdqFo29U=
gitlab.com/elixxir/comms v0.0.4-0.20230519211512-4a998f4b0938 h1:f27+QUFiGWrprKm+fstOg3ABkYLpWcZi3+8Lf5eDnqY=
gitlab.com/elixxir/comms v0.0.4-0.20230519211512-4a998f4b0938/go.mod h1:z+qW0D9VpY5QKTd7wRlb5SK4kBNqLYsa4DXBcUXue9Q=
gitlab.com/elixxir/crypto v0.0.7-0.20230522162218-45433d877235 h1:0BySdXTzRWxzH8k5RiNNMmmn2lpuQWLVcDDA/7ehyqc=
gitlab.com/elixxir/crypto v0.0.7-0.20230522162218-45433d877235/go.mod h1:IYInxKr5Q7EH3oNhg1QX1/sTTRNi7L0JkcyfdRegoio=
gitlab.com/elixxir/ekv v0.3.1-0.20230525165450-f444c687504b h1:hf28yepO93tCacx1bUAh8vVFkBUEuBaJhOjifBxEQK4=
gitlab.com/elixxir/ekv v0.3.1-0.20230525165450-f444c687504b/go.mod h1:EMaUQrsOxvEPQ0/8V/PSkGqFmEC2axBG/uqY0oW2uJM=
gitlab.com/elixxir/crypto v0.0.7-0.20230607170539-92d9508c78f9 h1:+RZcoU7NOPXCenkKM/ImYyLcNDdG4vsWrJyKqoAAv8k=
gitlab.com/elixxir/crypto v0.0.7-0.20230607170539-92d9508c78f9/go.mod h1:lAib0KO9TeTLWbwgFk2uszRxPkHeu843xqnYdkzdEB0=
gitlab.com/elixxir/ekv v0.3.1-0.20230525213559-f9da13f4fce1 h1:8XBo6QQBXXGCTrgXHFuqPL21mROLKLAoO3X9xR5TwA0=
gitlab.com/elixxir/ekv v0.3.1-0.20230525213559-f9da13f4fce1/go.mod h1:UStTZ9d1UVn9Ahyb49lrbPKyr/Wb8xFWqMXbDgIqQhE=
gitlab.com/elixxir/primitives v0.0.3-0.20230214180039-9a25e2d3969c h1:muG8ff95woeVVwQoJHCEclxBFB22lc7EixPylEkYDRU=
gitlab.com/elixxir/primitives v0.0.3-0.20230214180039-9a25e2d3969c/go.mod h1:phun4PLkHJA6wcL4JIhhxZztrmCyJHWPNppBP3DUD2Y=
gitlab.com/elixxir/wasm-utils v0.0.0-20230522231408-a43b2c1481b2 h1:GQb350yPBkWRkPRgNSVFF0ZZDOAlXWIKQBI/1Ff6biU=
gitlab.com/elixxir/wasm-utils v0.0.0-20230522231408-a43b2c1481b2/go.mod h1:wB7Vh/7LWUm8wYRBSd+6lxfpk4CnDaHTkLCIVKfL2TA=
gitlab.com/elixxir/wasm-utils v0.0.0-20230607204433-22c46f9d680f h1:Nz87zyNu85uxCI+fiS7dJl6HHxPoGUzyec4FpZy7Vv8=
gitlab.com/elixxir/wasm-utils v0.0.0-20230607204433-22c46f9d680f/go.mod h1:wB7Vh/7LWUm8wYRBSd+6lxfpk4CnDaHTkLCIVKfL2TA=
gitlab.com/xx_network/comms v0.0.4-0.20230214180029-5387fb85736d h1:AZf2h0fxyO1KxhZPP9//jG3Swb2BcuKbxtNXJgooLss=
gitlab.com/xx_network/comms v0.0.4-0.20230214180029-5387fb85736d/go.mod h1:8cwPyH6G8C4qf/U5KDghn1ksOh79MrNqthjKDrfvbXY=
gitlab.com/xx_network/crypto v0.0.5-0.20230214003943-8a09396e95dd h1:IleH6U5D/c2zF6YL/z3cBKqBPnI5ApNMCtU7ia4t228=
......
......@@ -18,8 +18,8 @@ import (
"gitlab.com/elixxir/client/v4/channels"
"gitlab.com/elixxir/client/v4/cmix/rounds"
cryptoBroadcast "gitlab.com/elixxir/crypto/broadcast"
cryptoChannel "gitlab.com/elixxir/crypto/channel"
"gitlab.com/elixxir/crypto/fastRNG"
idbCrypto "gitlab.com/elixxir/crypto/indexedDb"
"gitlab.com/elixxir/crypto/message"
wChannels "gitlab.com/elixxir/xxdk-wasm/indexedDb/worker/channels"
"gitlab.com/elixxir/xxdk-wasm/worker"
......@@ -64,7 +64,7 @@ func (m *manager) newWASMEventModelCB(data []byte) ([]byte, error) {
// Create new encryption cipher
rng := fastRNG.NewStreamGenerator(12, 1024, csprng.NewSystemRNG)
encryption, err := cryptoChannel.NewCipherFromJSON(
encryption, err := idbCrypto.NewCipherFromJSON(
[]byte(msg.EncryptionJSON), rng.GetStream())
if err != nil {
return []byte{}, errors.Errorf(
......
......@@ -25,7 +25,7 @@ import (
"gitlab.com/elixxir/client/v4/channels"
"gitlab.com/elixxir/client/v4/cmix/rounds"
cryptoBroadcast "gitlab.com/elixxir/crypto/broadcast"
cryptoChannel "gitlab.com/elixxir/crypto/channel"
idbCrypto "gitlab.com/elixxir/crypto/indexedDb"
"gitlab.com/elixxir/crypto/message"
"gitlab.com/elixxir/wasm-utils/utils"
"gitlab.com/elixxir/xxdk-wasm/indexedDb/impl"
......@@ -37,7 +37,7 @@ import (
// caller to ensure that its methods are called sequentially.
type wasmModel struct {
db *idb.Database
cipher cryptoChannel.Cipher
cipher idbCrypto.Cipher
eventUpdate func(eventType int64, jsonMarshallable any)
}
......@@ -145,12 +145,11 @@ func (w *wasmModel) ReceiveMessage(channelID *id.ID, messageID message.ID,
nickname, text string, pubKey ed25519.PublicKey, dmToken uint32,
codeset uint8, timestamp time.Time, lease time.Duration, round rounds.Round,
mType channels.MessageType, status channels.SentStatus, hidden bool) uint64 {
textBytes := []byte(text)
var err error
// Handle encryption, if it is present
if w.cipher != nil {
textBytes, err = w.cipher.Encrypt([]byte(text))
text, err = w.cipher.Encrypt([]byte(text))
if err != nil {
jww.ERROR.Printf("Failed to encrypt Message: %+v", err)
return 0
......@@ -161,7 +160,7 @@ func (w *wasmModel) ReceiveMessage(channelID *id.ID, messageID message.ID,
msgToInsert := buildMessage(
channelIDBytes, messageID.Bytes(), nil, nickname,
textBytes, pubKey, dmToken, codeset, timestamp, lease, round.ID, mType,
text, pubKey, dmToken, codeset, timestamp, lease, round.ID, mType,
false, hidden, status)
uuid, err := w.upsertMessage(msgToInsert)
......@@ -189,12 +188,11 @@ func (w *wasmModel) ReceiveReply(channelID *id.ID, messageID,
dmToken uint32, codeset uint8, timestamp time.Time, lease time.Duration,
round rounds.Round, mType channels.MessageType, status channels.SentStatus,
hidden bool) uint64 {
textBytes := []byte(text)
var err error
// Handle encryption, if it is present
if w.cipher != nil {
textBytes, err = w.cipher.Encrypt([]byte(text))
text, err = w.cipher.Encrypt([]byte(text))
if err != nil {
jww.ERROR.Printf("Failed to encrypt Message: %+v", err)
return 0
......@@ -204,7 +202,7 @@ func (w *wasmModel) ReceiveReply(channelID *id.ID, messageID,
channelIDBytes := channelID.Marshal()
msgToInsert := buildMessage(channelIDBytes, messageID.Bytes(),
replyTo.Bytes(), nickname, textBytes, pubKey, dmToken, codeset,
replyTo.Bytes(), nickname, text, pubKey, dmToken, codeset,
timestamp, lease, round.ID, mType, hidden, false, status)
uuid, err := w.upsertMessage(msgToInsert)
......@@ -232,12 +230,11 @@ func (w *wasmModel) ReceiveReaction(channelID *id.ID, messageID,
dmToken uint32, codeset uint8, timestamp time.Time, lease time.Duration,
round rounds.Round, mType channels.MessageType, status channels.SentStatus,
hidden bool) uint64 {
textBytes := []byte(reaction)
var err error
// Handle encryption, if it is present
if w.cipher != nil {
textBytes, err = w.cipher.Encrypt([]byte(reaction))
reaction, err = w.cipher.Encrypt([]byte(reaction))
if err != nil {
jww.ERROR.Printf("Failed to encrypt Message: %+v", err)
return 0
......@@ -247,7 +244,7 @@ func (w *wasmModel) ReceiveReaction(channelID *id.ID, messageID,
channelIDBytes := channelID.Marshal()
msgToInsert := buildMessage(
channelIDBytes, messageID.Bytes(), reactionTo.Bytes(), nickname,
textBytes, pubKey, dmToken, codeset, timestamp, lease, round.ID, mType,
reaction, pubKey, dmToken, codeset, timestamp, lease, round.ID, mType,
false, hidden, status)
uuid, err := w.upsertMessage(msgToInsert)
......@@ -349,8 +346,8 @@ func (w *wasmModel) UpdateFromMessageID(messageID message.ID,
// NOTE: ID is not set inside this function because we want to use the
// autoincrement key by default. If you are trying to overwrite an existing
// message, then you need to set it manually yourself.
func buildMessage(channelID, messageID, parentID []byte, nickname string,
text []byte, pubKey ed25519.PublicKey, dmToken uint32, codeset uint8,
func buildMessage(channelID, messageID, parentID []byte, nickname,
text string, pubKey ed25519.PublicKey, dmToken uint32, codeset uint8,
timestamp time.Time, lease time.Duration, round id.Round,
mType channels.MessageType, pinned, hidden bool,
status channels.SentStatus) *Message {
......@@ -499,7 +496,7 @@ func (w *wasmModel) GetMessage(
Status: channels.SentStatus(lookupResult.Status),
Hidden: lookupResult.Hidden,
Pinned: lookupResult.Pinned,
Content: lookupResult.Text,
Content: []byte(lookupResult.Text),
Type: channels.MessageType(lookupResult.Type),
Round: id.Round(lookupResult.Round),
PubKey: lookupResult.Pubkey,
......
......@@ -27,8 +27,8 @@ import (
cft "gitlab.com/elixxir/client/v4/channelsFileTransfer"
"gitlab.com/elixxir/client/v4/cmix/rounds"
cryptoBroadcast "gitlab.com/elixxir/crypto/broadcast"
cryptoChannel "gitlab.com/elixxir/crypto/channel"
"gitlab.com/elixxir/crypto/fileTransfer"
idbCrypto "gitlab.com/elixxir/crypto/indexedDb"
"gitlab.com/elixxir/crypto/message"
"gitlab.com/elixxir/wasm-utils/storage"
"gitlab.com/elixxir/xxdk-wasm/indexedDb/impl"
......@@ -120,12 +120,12 @@ func TestWasmModel_ReceiveFile(t *testing.T) {
// Happy path, insert message and look it up
func TestWasmModel_GetMessage(t *testing.T) {
cipher, err := cryptoChannel.NewCipher(
cipher, err := idbCrypto.NewCipher(
[]byte("testPass"), []byte("testSalt"), 128, csprng.NewSystemRNG())
if err != nil {
t.Fatalf("Failed to create cipher")
}
for _, c := range []cryptoChannel.Cipher{nil, cipher} {
for _, c := range []idbCrypto.Cipher{nil, cipher} {
cs := ""
if c != nil {
cs = "_withCipher"
......@@ -142,7 +142,7 @@ func TestWasmModel_GetMessage(t *testing.T) {
}
testMsg := buildMessage(id.NewIdFromBytes([]byte(testString), t).Marshal(),
testMsgId.Bytes(), nil, testString, []byte(testString),
testMsgId.Bytes(), nil, testString, testString,
[]byte{8, 6, 7, 5}, 0, 0, netTime.Now(),
time.Second, 0, 0, false, false, channels.Sent)
_, err = eventModel.upsertMessage(testMsg)
......@@ -173,7 +173,7 @@ func TestWasmModel_DeleteMessage(t *testing.T) {
// Insert a message
testMsg := buildMessage([]byte(testString), testMsgId.Bytes(), nil,
testString, []byte(testString), []byte{8, 6, 7, 5}, 0, 0, netTime.Now(),
testString, testString, []byte{8, 6, 7, 5}, 0, 0, netTime.Now(),
time.Second, 0, 0, false, false, channels.Sent)
_, err = eventModel.upsertMessage(testMsg)
if err != nil {
......@@ -207,12 +207,12 @@ func TestWasmModel_DeleteMessage(t *testing.T) {
// Test wasmModel.UpdateSentStatus happy path and ensure fields don't change.
func Test_wasmModel_UpdateSentStatus(t *testing.T) {
cipher, err := cryptoChannel.NewCipher(
cipher, err := idbCrypto.NewCipher(
[]byte("testPass"), []byte("testSalt"), 128, csprng.NewSystemRNG())
if err != nil {
t.Fatalf("Failed to create cipher")
}
for _, c := range []cryptoChannel.Cipher{nil, cipher} {
for _, c := range []idbCrypto.Cipher{nil, cipher} {
cs := ""
if c != nil {
cs = "_withCipher"
......@@ -234,7 +234,7 @@ func Test_wasmModel_UpdateSentStatus(t *testing.T) {
// Store a test message
testMsg := buildMessage(cid.Bytes(), testMsgId.Bytes(), nil,
testString, []byte(testString), []byte{8, 6, 7, 5}, 0, 0,
testString, testString, []byte{8, 6, 7, 5}, 0, 0,
netTime.Now(), time.Second, 0, 0, false, false, channels.Sent)
uuid, err2 := eventModel.upsertMessage(testMsg)
if err2 != nil {
......@@ -282,12 +282,12 @@ func Test_wasmModel_UpdateSentStatus(t *testing.T) {
// Smoke test wasmModel.JoinChannel/wasmModel.LeaveChannel happy paths.
func Test_wasmModel_JoinChannel_LeaveChannel(t *testing.T) {
cipher, err := cryptoChannel.NewCipher(
cipher, err := idbCrypto.NewCipher(
[]byte("testPass"), []byte("testSalt"), 128, csprng.NewSystemRNG())
if err != nil {
t.Fatalf("Failed to create cipher")
}
for _, c := range []cryptoChannel.Cipher{nil, cipher} {
for _, c := range []idbCrypto.Cipher{nil, cipher} {
cs := ""
if c != nil {
cs = "_withCipher"
......@@ -334,12 +334,12 @@ func Test_wasmModel_JoinChannel_LeaveChannel(t *testing.T) {
// Test UUID gets returned when different messages are added.
func Test_wasmModel_UUIDTest(t *testing.T) {
cipher, err := cryptoChannel.NewCipher(
cipher, err := idbCrypto.NewCipher(
[]byte("testPass"), []byte("testSalt"), 128, csprng.NewSystemRNG())
if err != nil {
t.Fatalf("Failed to create cipher")
}
for _, c := range []cryptoChannel.Cipher{nil, cipher} {
for _, c := range []idbCrypto.Cipher{nil, cipher} {
cs := ""
if c != nil {
cs = "_withCipher"
......@@ -381,12 +381,12 @@ func Test_wasmModel_UUIDTest(t *testing.T) {
// Tests if the same message ID being sent always returns the same UUID.
func Test_wasmModel_DuplicateReceives(t *testing.T) {
cipher, err := cryptoChannel.NewCipher(
cipher, err := idbCrypto.NewCipher(
[]byte("testPass"), []byte("testSalt"), 128, csprng.NewSystemRNG())
if err != nil {
t.Fatalf("Failed to create cipher")
}
for _, c := range []cryptoChannel.Cipher{nil, cipher} {
for _, c := range []idbCrypto.Cipher{nil, cipher} {
cs := ""
if c != nil {
cs = "_withCipher"
......@@ -428,12 +428,12 @@ func Test_wasmModel_DuplicateReceives(t *testing.T) {
// Happy path: Inserts many messages, deletes some, and checks that the final
// result is as expected.
func Test_wasmModel_deleteMsgByChannel(t *testing.T) {
cipher, err := cryptoChannel.NewCipher(
cipher, err := idbCrypto.NewCipher(
[]byte("testPass"), []byte("testSalt"), 128, csprng.NewSystemRNG())
if err != nil {
t.Fatalf("Failed to create cipher")
}
for _, c := range []cryptoChannel.Cipher{nil, cipher} {
for _, c := range []idbCrypto.Cipher{nil, cipher} {
cs := ""
if c != nil {
cs = "_withCipher"
......@@ -501,12 +501,12 @@ func Test_wasmModel_deleteMsgByChannel(t *testing.T) {
// This test is designed to prove the behavior of unique indexes.
// Inserts will not fail, they simply will not happen.
func TestWasmModel_receiveHelper_UniqueIndex(t *testing.T) {
cipher, err := cryptoChannel.NewCipher(
cipher, err := idbCrypto.NewCipher(
[]byte("testPass"), []byte("testSalt"), 128, csprng.NewSystemRNG())
if err != nil {
t.Fatalf("Failed to create cipher")
}
for i, c := range []cryptoChannel.Cipher{nil, cipher} {
for i, c := range []idbCrypto.Cipher{nil, cipher} {
cs := ""
if c != nil {
cs = "_withCipher"
......@@ -542,12 +542,12 @@ func TestWasmModel_receiveHelper_UniqueIndex(t *testing.T) {
testMsgId := message.DeriveChannelMessageID(&id.ID{1}, 0, []byte(testString))
testMsg := buildMessage([]byte(testString), testMsgId.Bytes(), nil,
testString, []byte(testString), []byte{8, 6, 7, 5}, 0, 0,
testString, testString, []byte{8, 6, 7, 5}, 0, 0,
netTime.Now(), time.Second, 0, 0, false, false, channels.Sent)
testMsgId2 := message.DeriveChannelMessageID(&id.ID{2}, 0, []byte(testString))
testMsg2 := buildMessage([]byte(testString), testMsgId2.Bytes(), nil,
testString, []byte(testString), []byte{8, 6, 7, 5}, 0, 0,
testString, testString, []byte{8, 6, 7, 5}, 0, 0,
netTime.Now(), time.Second, 0, 0, false, false, channels.Sent)
// First message insert should succeed
......
......@@ -18,7 +18,7 @@ import (
"gitlab.com/elixxir/client/v4/bindings"
"gitlab.com/elixxir/client/v4/channels"
cryptoChannel "gitlab.com/elixxir/crypto/channel"
idbCrypto "gitlab.com/elixxir/crypto/indexedDb"
"gitlab.com/elixxir/xxdk-wasm/indexedDb/impl"
)
......@@ -29,13 +29,13 @@ const currentVersion uint = 1
// NewWASMEventModel returns a [channels.EventModel] backed by a wasmModel.
// The name should be a base64 encoding of the users public key. Returns the
// EventModel based on IndexedDb and the database name as reported by IndexedDb.
func NewWASMEventModel(databaseName string, encryption cryptoChannel.Cipher,
func NewWASMEventModel(databaseName string, encryption idbCrypto.Cipher,
uiCallbacks bindings.ChannelUICallbacks) (channels.EventModel, error) {
return newWASMModel(databaseName, encryption, uiCallbacks)
}
// newWASMModel creates the given [idb.Database] and returns a wasmModel.
func newWASMModel(databaseName string, encryption cryptoChannel.Cipher,
func newWASMModel(databaseName string, encryption idbCrypto.Cipher,
uiCallbacks bindings.ChannelUICallbacks) (*wasmModel, error) {
// Attempt to open database object
ctx, cancel := impl.NewContext()
......
......@@ -56,7 +56,7 @@ type Message struct {
Status uint8 `json:"status"`
Hidden bool `json:"hidden"`
Pinned bool `json:"pinned"` // Index
Text []byte `json:"text"`
Text string `json:"text"`
Type uint16 `json:"type"`
Round uint64 `json:"round"`
......
......@@ -17,8 +17,8 @@ import (
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/v4/dm"
cryptoChannel "gitlab.com/elixxir/crypto/channel"
"gitlab.com/elixxir/crypto/fastRNG"
idbCrypto "gitlab.com/elixxir/crypto/indexedDb"
wDm "gitlab.com/elixxir/xxdk-wasm/indexedDb/worker/dm"
"gitlab.com/elixxir/xxdk-wasm/worker"
"gitlab.com/xx_network/crypto/csprng"
......@@ -61,7 +61,7 @@ func (m *manager) newWASMEventModelCB(data []byte) ([]byte, error) {
// Create new encryption cipher
rng := fastRNG.NewStreamGenerator(12, 1024, csprng.NewSystemRNG)
encryption, err := cryptoChannel.NewCipherFromJSON(
encryption, err := idbCrypto.NewCipherFromJSON(
[]byte(msg.EncryptionJSON), rng.GetStream())
if err != nil {
return []byte{}, errors.Errorf("failed to JSON unmarshal channel "+
......
......@@ -24,7 +24,7 @@ import (
"gitlab.com/elixxir/client/v4/cmix/rounds"
"gitlab.com/elixxir/client/v4/dm"
cryptoChannel "gitlab.com/elixxir/crypto/channel"
idbCrypto "gitlab.com/elixxir/crypto/indexedDb"
"gitlab.com/elixxir/crypto/message"
"gitlab.com/elixxir/wasm-utils/utils"
"gitlab.com/elixxir/xxdk-wasm/indexedDb/impl"
......@@ -36,7 +36,7 @@ import (
// caller to ensure that its methods are called sequentially.
type wasmModel struct {
db *idb.Database
cipher cryptoChannel.Cipher
cipher idbCrypto.Cipher
receivedMessageCB MessageReceivedCallback
}
......@@ -81,7 +81,7 @@ func (w *wasmModel) upsertConversation(nickname string,
// NOTE: ID is not set inside this function because we want to use the
// autoincrement key by default. If you are trying to overwrite an existing
// message, then you need to set it manually yourself.
func buildMessage(messageID, parentID, text []byte, partnerKey,
func buildMessage(messageID, parentID []byte, text string, partnerKey []byte,
senderKey ed25519.PublicKey, timestamp time.Time, round id.Round,
mType dm.MessageType, codeset uint8, status dm.Status) *Message {
return &Message{
......@@ -276,9 +276,8 @@ func (w *wasmModel) receiveWrapper(messageID message.ID, parentID *message.ID, n
}
// Handle encryption, if it is present
textBytes := []byte(data)
if w.cipher != nil {
textBytes, err = w.cipher.Encrypt(textBytes)
data, err = w.cipher.Encrypt([]byte(data))
if err != nil {
return 0, err
}
......@@ -289,7 +288,7 @@ func (w *wasmModel) receiveWrapper(messageID message.ID, parentID *message.ID, n
parentIdBytes = parentID.Marshal()
}
msgToInsert := buildMessage(messageID.Bytes(), parentIdBytes, textBytes,
msgToInsert := buildMessage(messageID.Bytes(), parentIdBytes, data,
partnerKey, senderKey, timestamp, round.ID, mType, codeset, status)
uuid, err := w.upsertMessage(msgToInsert)
......
......@@ -17,7 +17,7 @@ import (
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/v4/dm"
cryptoChannel "gitlab.com/elixxir/crypto/channel"
idbCrypto "gitlab.com/elixxir/crypto/indexedDb"
"gitlab.com/elixxir/xxdk-wasm/indexedDb/impl"
)
......@@ -35,13 +35,13 @@ type MessageReceivedCallback func(
// NewWASMEventModel returns a [channels.EventModel] backed by a wasmModel.
// The name should be a base64 encoding of the users public key. Returns the
// EventModel based on IndexedDb and the database name as reported by IndexedDb.
func NewWASMEventModel(databaseName string, encryption cryptoChannel.Cipher,
func NewWASMEventModel(databaseName string, encryption idbCrypto.Cipher,
cb MessageReceivedCallback) (dm.EventModel, error) {
return newWASMModel(databaseName, encryption, cb)
}
// newWASMModel creates the given [idb.Database] and returns a wasmModel.
func newWASMModel(databaseName string, encryption cryptoChannel.Cipher,
func newWASMModel(databaseName string, encryption idbCrypto.Cipher,
cb MessageReceivedCallback) (*wasmModel, error) {
// Attempt to open database object
ctx, cancel := impl.NewContext()
......
......@@ -46,7 +46,7 @@ type Message struct {
SenderPubKey []byte `json:"sender_pub_key"` // Index
CodesetVersion uint8 `json:"codeset_version"`
Status uint8 `json:"status"`
Text []byte `json:"text"`
Text string `json:"text"`
Type uint16 `json:"type"`
Round uint64 `json:"round"`
}
......
......@@ -12,8 +12,8 @@ package main
import (
"encoding/json"
"github.com/pkg/errors"
"gitlab.com/elixxir/xxdk-wasm/indexedDb/impl"
"gitlab.com/elixxir/client/v4/storage/utility"
stateWorker "gitlab.com/elixxir/xxdk-wasm/indexedDb/worker/state"
"gitlab.com/elixxir/xxdk-wasm/worker"
)
......@@ -22,7 +22,7 @@ import (
// send information between the model and the main thread.
type manager struct {
wtm *worker.ThreadManager
model utility.WebState
model impl.WebState
}
// registerCallbacks registers all the reception callbacks to manage messages
......
......@@ -12,7 +12,6 @@ package main
import (
"github.com/hack-pad/go-indexeddb/idb"
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/v4/storage/utility"
"gitlab.com/elixxir/xxdk-wasm/indexedDb/impl"
"syscall/js"
)
......@@ -23,7 +22,7 @@ const currentVersion uint = 1
// NewState returns a [utility.WebState] backed by IndexedDb.
// The name should be a base64 encoding of the users public key.
func NewState(databaseName string) (utility.WebState, error) {
func NewState(databaseName string) (impl.WebState, error) {
return newState(databaseName)
}
......
......@@ -32,6 +32,13 @@ const (
ErrDoesNotExist = "result is undefined"
)
// WebState defines an interface for setting persistent state in a KV format
// specifically for web-based implementations.
type WebState interface {
Get(key string) ([]byte, error)
Set(key string, value []byte) error
}
// NewContext builds a context for indexedDb operations.
func NewContext() (context.Context, context.CancelFunc) {
return context.WithTimeout(context.Background(), dbTimeout)
......
......@@ -18,8 +18,7 @@ import (
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/v4/bindings"
"gitlab.com/elixxir/client/v4/channels"
cryptoChannel "gitlab.com/elixxir/crypto/channel"
idbCrypto "gitlab.com/elixxir/crypto/indexedDb"
"gitlab.com/elixxir/xxdk-wasm/storage"
"gitlab.com/elixxir/xxdk-wasm/worker"
)
......@@ -36,7 +35,7 @@ type eventUpdateCallback func(eventType int64, jsonData []byte)
// the channel manager to define the path but the callback is the same
// across the board.
func NewWASMEventModelBuilder(wasmJsPath string,
encryption cryptoChannel.Cipher,
encryption idbCrypto.Cipher,
channelCbs bindings.ChannelUICallbacks) channels.EventModelBuilder {
fn := func(path string) (channels.EventModel, error) {
return NewWASMEventModel(path, wasmJsPath, encryption,
......@@ -54,7 +53,7 @@ type NewWASMEventModelMessage struct {
// NewWASMEventModel returns a [channels.EventModel] backed by a wasmModel.
// The name should be a base64 encoding of the users public key.
func NewWASMEventModel(path, wasmJsPath string, encryption cryptoChannel.Cipher,
func NewWASMEventModel(path, wasmJsPath string, encryption idbCrypto.Cipher,
channelCbs bindings.ChannelUICallbacks) (
channels.EventModel, error) {
databaseName := path + databaseSuffix
......
......@@ -18,7 +18,7 @@ import (
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/v4/dm"
cryptoChannel "gitlab.com/elixxir/crypto/channel"
idbCrypto "gitlab.com/elixxir/crypto/indexedDb"
"gitlab.com/elixxir/xxdk-wasm/storage"
"gitlab.com/elixxir/xxdk-wasm/worker"
)
......@@ -42,7 +42,7 @@ type NewWASMEventModelMessage struct {
// NewWASMEventModel returns a [channels.EventModel] backed by a wasmModel.
// The name should be a base64 encoding of the users public key.
func NewWASMEventModel(path, wasmJsPath string, encryption cryptoChannel.Cipher,
func NewWASMEventModel(path, wasmJsPath string, encryption idbCrypto.Cipher,
cb MessageReceivedCallback) (dm.EventModel, error) {
databaseName := path + databaseSuffix
......
......@@ -11,11 +11,11 @@ package dm
import (
"encoding/json"
"gitlab.com/elixxir/xxdk-wasm/indexedDb/impl"
"time"
"github.com/pkg/errors"
"gitlab.com/elixxir/client/v4/storage/utility"
"gitlab.com/elixxir/xxdk-wasm/storage"
"gitlab.com/elixxir/xxdk-wasm/worker"
)
......@@ -29,9 +29,16 @@ type NewStateMessage struct {
DatabaseName string `json:"databaseName"`
}
// WebState defines an interface for setting persistent state in a KV format
// specifically for web-based implementations.
type WebState interface {
Get(key string) ([]byte, error)
Set(key string, value []byte) error
}
// NewState returns a [utility.WebState] backed by indexeddb.
// The name should be a base64 encoding of the users public key.
func NewState(path, wasmJsPath string) (utility.WebState, error) {
func NewState(path, wasmJsPath string) (impl.WebState, error) {
databaseName := path + databaseSuffix
wh, err := worker.NewManager(wasmJsPath, "stateIndexedDb", true)
......
......@@ -136,8 +136,12 @@ func setGlobals() {
js.FuncOf(wasm.GetChannelNotificationReportsForMe))
js.Global().Set("GetNoMessageErr", js.FuncOf(wasm.GetNoMessageErr))
js.Global().Set("CheckNoMessageErr", js.FuncOf(wasm.CheckNoMessageErr))
js.Global().Set("NewChannelsDatabaseCipher",
js.FuncOf(wasm.NewChannelsDatabaseCipher))
js.Global().Set("GetNotificationReportsForMe",
js.FuncOf(wasm.GetChannelNotificationReportsForMe))
// wasm/cipher.go
js.Global().Set("NewDatabaseCipher",
js.FuncOf(wasm.NewDatabaseCipher))
// wasm/dm.go
js.Global().Set("InitChannelsFileTransfer",
......@@ -150,7 +154,7 @@ func setGlobals() {
js.Global().Set("NewDMClientWithIndexedDbUnsafe",
js.FuncOf(wasm.NewDMClientWithIndexedDbUnsafe))
js.Global().Set("NewDMsDatabaseCipher",
js.FuncOf(wasm.NewDMsDatabaseCipher))
js.FuncOf(wasm.NewDatabaseCipher))
// wasm/cmix.go
js.Global().Set("NewCmix", js.FuncOf(wasm.NewCmix))
......
......@@ -195,7 +195,7 @@ func verifyPassword(externalPassword string) bool {
// initInternalPassword generates a new internal password, stores an encrypted
// version in local storage, and returns it.
func initInternalPassword(externalPassword string,
localStorage *storage.LocalStorage, csprng io.Reader,
localStorage storage.LocalStorage, csprng io.Reader,
params argonParams) ([]byte, error) {
internalPassword := make([]byte, internalPasswordLen)
......@@ -250,7 +250,7 @@ func initInternalPassword(externalPassword string,
// getInternalPassword retrieves the internal password from local storage,
// decrypts it, and returns it.
func getInternalPassword(
externalPassword string, localStorage *storage.LocalStorage) ([]byte, error) {
externalPassword string, localStorage storage.LocalStorage) ([]byte, error) {
encryptedInternalPassword, err := localStorage.Get(passwordKey)
if err != nil {
return nil, errors.WithMessage(err, getPasswordStorageErr)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment