on master help sign in
Got things working on device
commitcc304be5a0c5af9b2df90eb2891ddb5761c1951e authoriko <ilyakooo0@gmail.com> dateMon 25 Jul 2022, 19:53 (4 years ago) parent50a3a0b
10 files changed+41−27
appname.desktop+2−2 build.sh+5−11 bw/src/BW.js+14−10 bw/src/BW.purs+6−2 bw/src/Data/EncString.js+5 bw/src/Data/EncString.purs+7 clickable.yaml+1 dev/build-bw.sh+1−1 index.html−1 assets/logo.svg → logo.svg
appname.desktop+2−2
@@ -1,7 +1,7 @@
11[Desktop Entry]
22Name=App Title
3−Exec=webapp-container --app-id="appname.iko" $@ index.html
4−Icon=assets/logo.svg
3+Exec=webapp-container --inspector=9223 --app-id="appname.iko" $@ index.html
4+Icon=logo.svg
55Terminal=false
66Type=Application
77X-Ubuntu-Touch=true
build.sh+5−11
@@ -1,15 +1,9 @@
1−#!/bin/sh
1+#!/bin/bash
22
3−cp -r "$SRC_DIR"/{appname.apparmor,appname.desktop,vanilla,index.html,style.css} "$INSTALL_DIR"
3+set -e
44
5−BUILDDIR=$(mktemp -d)
5+cp -r "$SRC_DIR"/{appname.apparmor,appname.desktop,vanilla,index.html,style.css,manifest.json,logo.svg} "$INSTALL_DIR"
66
7−cp -r $SRC_DIR/* $BUILDDIR
7+elm make --debug "$SRC_DIR/frontend/Main.elm" --output="$INSTALL_DIR/elm.js"
88
9−ls $BUILDDIR
10−
11−elm make --debug "$BUILDDIR/frontend/Main.elm" --output="$INSTALL_DIR/elm.js"
12−
13−(cd "$BUILDDIR" && ./dev/build-bw.sh)
14−
15−(cd "$BUILDDIR" && spago bundle-app --to "$INSTALL_DIR/backend.js")
9+(cd "$SRC_DIR" && spago bundle-app --to "$INSTALL_DIR/backend.js")
bw/src/BW.js+14−10
@@ -17,7 +17,6 @@ import { StateService as BaseStateService } from "../../deps/bw/libs/shared/dist
1717import { PasswordTokenRequest } from "../../deps/bw/libs/shared/dist/src/models/request/identityToken/passwordTokenRequest";
1818import { TokenRequestTwoFactor } from "../../deps/bw/libs/common/src/models/request/identityToken/tokenRequestTwoFactor.ts";
1919
20−
2120function sanitize(obj) {
2221 return JSON.parse(JSON.stringify(obj));
2322}
@@ -201,7 +200,12 @@ class BrowserCryptoService extends CryptoService {
201200 async retrieveKeyFromStorage(keySuffix) {
202201 if (keySuffix === "biometric") {
203202 await this.platformUtilService.authenticateBiometric();
204− return (await this.getKey())?.keyB64;
203+ const k = await this.getKey()
204+ if (k == null) {
205+ return null
206+ } else {
207+ return k.keyB64
208+ }
205209 }
206210
207211 return await super.retrieveKeyFromStorage(keySuffix);
@@ -502,8 +506,8 @@ class StateService extends BaseStateService {
502506 }
503507
504508 async getBrowserGroupingComponentState(options) {
505− return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))
506− ?.groupings;
509+ const x = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions))
510+ return x == null ? null : x.groupings;
507511 }
508512
509513 async setBrowserGroupingComponentState(value, options) {
@@ -515,8 +519,8 @@ class StateService extends BaseStateService {
515519 }
516520
517521 async getBrowserCipherComponentState(options) {
518− return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))
519− ?.ciphers;
522+ const x = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions))
523+ return x == null ? null : x.ciphers;
520524 }
521525
522526 async setBrowserCipherComponentState(value, options) {
@@ -528,8 +532,8 @@ class StateService extends BaseStateService {
528532 }
529533
530534 async getBrowserSendComponentState(options) {
531− return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))
532− ?.send;
535+ const x = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions))
536+ return x == null ? null : x.send;
533537 }
534538
535539 async setBrowserSendComponentState(value, options) {
@@ -540,8 +544,8 @@ class StateService extends BaseStateService {
540544 await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions));
541545 }
542546 async getBrowserSendTypeComponentState(options) {
543− return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))
544− ?.sendType;
547+ const x = await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions))
548+ return x == null ? null : x.sendType;
545549 }
546550
547551 async setBrowserSendTypeComponentState(value, options) {
bw/src/BW.purs+6−2
@@ -4,13 +4,17 @@ import BW.Types
44import Prelude
55
66import Control.Promise (Promise)
7−import Data.Function.Uncurried (Fn3, Fn4)
7+import Data.ArrayBuffer.Types (ArrayBuffer)
8+import Data.EncString (EncString)
9+import Data.Function.Uncurried (Fn2, Fn3, Fn4)
810import Data.Nullable (Nullable)
911import Effect (Effect)
1012
1113type CryptoService = {
1214 makeKey :: Fn4 Password String KDF Int (Promise SymmetricCryptoKey),
13− hashPassword :: Fn3 Password SymmetricCryptoKey (Nullable HashPurpose) (Promise Hash)
15+ hashPassword :: Fn3 Password SymmetricCryptoKey (Nullable HashPurpose) (Promise Hash),
16+ decryptToUtf8 :: Fn2 EncString SymmetricCryptoKey (Promise String),
17+ decryptToBytes :: Fn2 EncString SymmetricCryptoKey (Promise ArrayBuffer)
1418}
1519
1620type ApiService = {
bw/src/Data/EncString.jsnew file+5
@@ -0,0 +1,5 @@
1+import { EncString } from "../../../deps/bw/libs/shared/dist/src/models/domain/encString"
2+
3+export function fromString(str) {
4+ return new EncString(str)
5+}
bw/src/Data/EncString.pursnew file+7
@@ -0,0 +1,7 @@
1+module Data.EncString where
2+
3+import Prelude
4+
5+foreign import data EncString :: Type
6+
7+foreign import fromString :: String -> EncString
clickable.yaml+1
@@ -12,5 +12,6 @@ image_setup:
1212
1313 - (cd /tmp && curl -L -o elm.gz https://github.com/elm/compiler/releases/download/0.19.1/binary-for-linux-64-bit.gz && gunzip elm.gz && chmod +x elm && mv elm /usr/local/bin/)
1414 - npm install -g spago esbuild purescript --unsafe-perm=true
15+ - (cd / && curl https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.37.1.tar.xz >git.tar.gz && tar -xvf git.tar.gz && cd git-2.37.1 && ./configure --without-curl && make)
1516
1617restrict_arch: all
dev/build-bw.sh+1−1
@@ -2,4 +2,4 @@
22
33(cd deps/bw && npm install)
44
5−(cd deps/bw/libs/common/ && npm run clean && npm exec -c "tsc -m es2020")
5+(cd deps/bw/libs/common/ && npm run clean && npm exec -c "tsc -m es2020 -t es2018")
index.html−1
@@ -13,7 +13,6 @@
1313
1414<body>
1515 <div id="elm"></div>
16− <div id="elm-2"></div>
1716 <script src="backend.js"></script>
1817</body>
1918
assets/logo.svg → logo.svgrenamed

The content is the same.