sattle: Quasar PWA scaffold with lnurlcash-kit protocol core

M1: Quasar 2 / Vue 3 / TS / Pinia / i18n / PWA app shell in the lnurl-wallet
palette (#002222/#004444/#55ffcc, Noto Sans). Protocol layer is the external
lnurlcash-kit library (git dependency on the fork until upstream merges the
prepare fix / publishes to npm); keys.ts + receive.ts vendored from
lnurl-wallet with the derivation domain renamed to 'sattle'. Nix dev shell,
ci workflow (typecheck, vitest, pwa build).
This commit is contained in:
2026-08-19 13:29:34 +02:00
commit 54d6112414
60 changed files with 14447 additions and 0 deletions
+7
View File
@@ -0,0 +1,7 @@
[*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,vue}]
charset = utf-8
indent_size = 2
indent_style = space
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
+25
View File
@@ -0,0 +1,25 @@
name: ci
on:
push:
branches: [main]
pull_request:
permissions:
contents: read
jobs:
test-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
cache: npm
# installs the lnurlcash-kit git dependency and builds its dist via the
# package's prepare hook (standard npm runs prepare for git deps)
- run: npm ci
- run: npm run typecheck
- run: npx vitest run
- run: npx quasar build -m pwa
+26
View File
@@ -0,0 +1,26 @@
.DS_Store
.thumbs.db
node_modules
# .env files
.env*
# Quasar core related directories
.quasar
/dist
/quasar.config.*.temporary.compiled*
# Cordova related directories and files
/src-cordova/node_modules
/src-cordova/platforms
/src-cordova/plugins
/src-cordova/www
# Capacitor related directories and files
/src-capacitor/www
/src-capacitor/node_modules
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
+5
View File
@@ -0,0 +1,5 @@
{
"$schema": "https://json.schemastore.org/prettierrc",
"singleQuote": true,
"printWidth": 100
}
+15
View File
@@ -0,0 +1,15 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"editorconfig.editorconfig",
"vue.volar",
"wayou.vscode-todo-highlight"
],
"unwantedRecommendations": [
"octref.vetur",
"hookyqr.beautify",
"dbaeumer.jshint",
"ms-vscode.vscode-typescript-tslint-plugin"
]
}
+14
View File
@@ -0,0 +1,14 @@
{
"editor.bracketPairColorization.enabled": true,
"editor.guides.bracketPairs": true,
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": ["source.fixAll.eslint"],
"eslint.validate": ["javascript", "javascriptreact", "typescript", "vue"],
"js/ts.tsdk.path": "node_modules/typescript/lib",
"search.exclude": {
"dist/": true,
".quasar/": true,
"/quasar.config.js.temporary.*": true
}
}
+38
View File
@@ -0,0 +1,38 @@
# sattle (sattle)
## Install the dependencies
```bash
pnpm install
# or: yarn/npm/bun install
```
### Start the app in development mode (HMR, error reporting, etc.)
```bash
quasar dev
```
### Format & Lint the files
```bash
pnpm run lint
# or: yarn/npm/bun run lint
```
...or just check formatting & linting:
```bash
pnpm run lint:check
# or: yarn/npm/bun run lint:check
```
### Build the app for production
```bash
quasar build
```
### Customize the configuration
See [Configuring quasar.config.js](https://v2.quasar.dev/quasar-cli-vite/quasar-config-file).
Vendored
+15
View File
@@ -0,0 +1,15 @@
/**
* Add types (that are not auto-magically added by Quasar CLI already)
* for your custom variables to avoid TypeScript errors, like dynamic
* process.env variables or definitions in dotenv files configured ONLY
* for the /quasar.config file itself.
*
* https://quasar.dev/quasar-cli-vite/handling-import-meta-env#type-inference
*
* @example
* interface ImportMetaEnv {
* readonly MY_VAR: string;
* readonly MY_OTHER_VAR: string;
* }
*/
interface ImportMetaEnv {}
+96
View File
@@ -0,0 +1,96 @@
import js from '@eslint/js';
import globals from 'globals';
import pluginVue from 'eslint-plugin-vue';
import pluginQuasar from '@quasar/app-vite/eslint';
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript';
import prettierSkipFormatting from '@vue/eslint-config-prettier/skip-formatting';
export default defineConfigWithVueTs(
{
/**
* Ignore the following files.
* Please note that pluginQuasar.configs.recommended() already ignores
* the "node_modules" folder for you (and all other Quasar project
* relevant folders and files).
*
* ESLint requires "ignores" key to be the only one in this object
*/
// ignores: []
},
pluginQuasar.configs.recommended(),
js.configs.recommended,
/**
* https://eslint.vuejs.org
*
* pluginVue.configs.base
* -> Settings and rules to enable correct ESLint parsing.
* pluginVue.configs[ 'flat/essential']
* -> base, plus rules to prevent errors or unintended behavior.
* pluginVue.configs["flat/strongly-recommended"]
* -> Above, plus rules to considerably improve code readability and/or dev experience.
* pluginVue.configs["flat/recommended"]
* -> Above, plus rules to enforce subjective community defaults to ensure consistency.
*/
pluginVue.configs['flat/essential'],
{
files: ['**/*.ts', '**/*.vue'],
rules: {
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }],
},
},
// https://github.com/vuejs/eslint-config-typescript
vueTsConfigs.recommendedTypeChecked,
{
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: {
...globals.browser,
...globals.node, // SSR, Electron, config files
process: 'readonly', // process.env.*
ga: 'readonly', // Google Analytics
cordova: 'readonly',
Capacitor: 'readonly',
chrome: 'readonly', // BEX related
browser: 'readonly', // BEX related
},
},
// add your custom rules here
rules: {
'prefer-promise-reject-errors': 'off',
// allow debugger during development only
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
},
},
{
files: ['src-pwa/sw/**/*.ts'],
languageOptions: {
globals: {
...globals.serviceworker,
},
},
},
{
// src/lnurlcash is a verbatim, test-covered protocol client extracted
// from lnurl-wallet - it keeps its upstream conventions untouched, so
// the type-checked style rules that would force edits are off there.
files: ['src/lnurlcash/**/*.ts'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/require-await': 'off',
},
},
prettierSkipFormatting,
);
Generated
+27
View File
@@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1787070829,
"narHash": "sha256-vXNVDVtvfiQuXthP0NHPFdNvvMTkGpx0UP8oddIWbNk=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "0ae2bc1419c3f345984c2629e72e7a631820fa4d",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}
+41
View File
@@ -0,0 +1,41 @@
{
description = "sattle - end-user wallet for LNURLcash (LUD-25) Lightning bearer notes.";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
outputs =
{ self, nixpkgs }:
let
systems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
"x86_64-darwin"
];
forAllSystems = nixpkgs.lib.genAttrs systems;
in
{
devShells = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
default = pkgs.mkShell {
packages = with pkgs; [
# lnurlcash-kit requires node >= 22
nodejs_22
corepack_22
git
# extensible: playwright browsers, capacitor/android SDK tooling,
# etc. go here as the project grows
];
shellHook = ''
echo "sattle dev shell (node $(node --version))"
'';
};
}
);
};
}
+24
View File
@@ -0,0 +1,24 @@
<!doctype html>
<html>
<head>
<title><%= productName %></title>
<meta charset="utf-8" />
<meta name="description" content="<%= productDescription %>" />
<meta name="format-detection" content="telephone=no" />
<meta name="msapplication-tap-highlight" content="no" />
<meta
name="viewport"
content="width=device-width, initial-scale=1<% if (ctx.mode.cordova || ctx.mode.capacitor) { %>, maximum-scale=1, minimum-scale=1, user-scalable=no, viewport-fit=cover<% } %>"
/>
<link rel="icon" type="image/png" sizes="128x128" href="icons/favicon-128x128.png" />
<link rel="icon" type="image/png" sizes="96x96" href="icons/favicon-96x96.png" />
<link rel="icon" type="image/png" sizes="32x32" href="icons/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="icons/favicon-16x16.png" />
<link rel="icon" type="image/ico" href="favicon.ico" />
</head>
<body>
<!-- quasar:entry-point -->
</body>
</html>
+7418
View File
File diff suppressed because it is too large Load Diff
+73
View File
@@ -0,0 +1,73 @@
{
"name": "sattle",
"version": "0.0.1",
"description": "A Quasar Project",
"productName": "sattle",
"author": "protom <office@protom.eu>",
"type": "module",
"private": true,
"scripts": {
"lint": "prettier --write \"**/*.{js,ts,vue,css,scss,html,md,json}\" --ignore-path .gitignore && eslint --fix -c ./eslint.config.js \"./src*/**/*.{ts,js,cjs,mjs,vue}\"",
"lint:check": "prettier \"**/*.{js,ts,vue,css,scss,html,md,json}\" --ignore-path .gitignore && eslint -c ./eslint.config.js \"./src*/**/*.{ts,js,cjs,mjs,vue}\"",
"dev": "quasar dev",
"build": "quasar build",
"test": "vitest run",
"typecheck": "vue-tsc --noEmit",
"postinstall": "quasar prepare --silent"
},
"dependencies": {
"@fontsource/noto-sans": "^5.3.0",
"@noble/curves": "^2.3.0",
"@noble/hashes": "^2.3.0",
"@quasar/extras": "^2.0.4",
"@scure/bip32": "^2.3.0",
"@scure/bip39": "^2.3.0",
"lnurlcash-kit": "github:tompro/lnurlcash-kit#prepare-git-install",
"pinia": "^4.0.2",
"quasar": "^2.25.1",
"vue": "^3.5.22",
"vue-i18n": "^11.3.0",
"vue-router": "^5.0.6"
},
"devDependencies": {
"@eslint/js": "^10.0.1",
"@intlify/unplugin-vue-i18n": "^11.0.0",
"@quasar/app-vite": "^3.7.0",
"@types/node": "^22.19.11",
"@vue/eslint-config-prettier": "^10.2.0",
"@vue/eslint-config-typescript": "^14.7.0",
"autoprefixer": "^10.4.27",
"esbuild": "^0.28.2",
"eslint": "^10.8.0",
"eslint-plugin-vue": "^10.8.0",
"globals": "^17.4.0",
"postcss": "^8.5.8",
"prettier": "^3.8.1",
"sass": "^1.102.0",
"typescript": "^6.0.0",
"vite-plugin-checker": "^0.14.5",
"vitest": "^4.1.11",
"vue-eslint-parser": "^10.4.0",
"vue-tsc": "^3.3.3"
},
"keywords": [
"quasar",
"quasar-app",
"quasar-cli",
"quasar-app-vite",
"vite",
"vue",
"vuejs"
],
"engines": {
"node": ">= 26 || ^24 || ^22.12"
},
"overrides": {
"sass-embedded": "npm:sass@^1.102.0"
},
"allowScripts": {
"esbuild@0.25.12": true,
"@parcel/watcher@2.6.0": true,
"esbuild@0.28.2": true
}
}
+10
View File
@@ -0,0 +1,10 @@
# https://pnpm.io/settings
allowBuilds:
'@parcel/watcher': true
core-js: true
electron-winstaller: true
esbuild: true
lightningcss: true
rolldown: true
unrs-resolver: true
+30
View File
@@ -0,0 +1,30 @@
// https://github.com/michael-ciniawsky/postcss-load-config
import autoprefixer from 'autoprefixer';
// import rtlcss from 'postcss-rtlcss'
// import { Mode } from 'postcss-rtlcss/options'
export default {
plugins: [
// https://github.com/postcss/autoprefixer
autoprefixer({
overrideBrowserslist: [
'last 4 Chrome versions',
'last 4 Firefox versions',
'last 4 Edge versions',
'last 4 Safari versions',
'last 4 Android versions',
'last 4 ChromeAndroid versions',
'last 4 FirefoxAndroid versions',
'last 4 iOS versions',
],
}),
// https://github.com/elchininet/postcss-rtlcss
// If you want to support RTL css, then
// 1. yarn/pnpm/bun/npm install postcss-rtlcss
// 2. optionally set quasar.config.js > framework > lang to an RTL language
// 3. uncomment the following line (and its import statement above):
// rtlcss({ mode: Mode.Override })
],
};
Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 859 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 7.5 KiB

+260
View File
@@ -0,0 +1,260 @@
// Configuration for your app
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-file
import { defineConfig } from '#q-app';
export default defineConfig((ctx) => {
return {
// https://v2.quasar.dev/quasar-cli-vite/prefetch-feature
// preFetch: true,
// app boot file (/src/boot)
// --> boot files are part of "main.js"
// https://v2.quasar.dev/quasar-cli-vite/boot-files
boot: ['i18n'],
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-file#css
css: ['app.scss'],
// https://github.com/quasarframework/quasar/tree/dev/extras
extras: [
// 'ionicons-v4',
// 'mdi-v7',
// 'fontawesome-v7',
// 'eva-icons',
// 'themify',
// 'line-awesome',
// 'roboto-font-latin-ext', // this or either 'roboto-font', NEVER both!
'material-icons', // optional, you are not bound to it
],
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-file#build
build: {
target: {
// browser: 'baseline-widely-available',
// node: 'node22'
},
typescript: {
strict: true,
vueShim: true,
// extendTsConfig (tsConfig) {}
},
// https://v2.quasar.dev/quasar-cli-vite/page-routing-with-vue-router#filename-based-routing
// filenameBasedRouting: true,
vueRouterMode: 'hash', // available values: 'hash', 'history'
// vueRouterBase,
// publicPath: '/',
// define: {},
// defineEnv: {}
// ignorePublicFolder: true,
// minify: false,
// distDir
// extendViteConf (viteConf) {},
// viteVuePluginOptions: {},
vitePlugins: [
[
'@intlify/unplugin-vue-i18n/vite',
{
// if you want to use Vue I18n Legacy API, you need to set `compositionOnly: false`
// compositionOnly: false,
// if you want to use named tokens in your Vue I18n messages, such as 'Hello {name}',
// you need to set `runtimeOnly: false`
// runtimeOnly: false,
ssr: ctx.mode.ssr || ctx.mode.ssg,
// you need to set i18n resource including paths !
include: [ctx.appPaths.resolve.app('src/i18n')],
},
],
[
'vite-plugin-checker',
{
vueTsc: true,
eslint: {
lintCommand: 'eslint -c ./eslint.config.js "./src*/**/*.{ts,js,mjs,cjs,vue}"',
useFlatConfig: true,
},
},
{ server: false },
],
],
},
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-file#devserver
devServer: {
// vueDevtools: true,
// https: true,
open: true, // opens browser window automatically
},
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-file#framework
framework: {
config: {
// sattle is dark-only: lnurl-wallet's dark-teal identity is the
// brand, there is no light theme
dark: true,
},
// iconSet: 'material-icons', // Quasar icon set
// lang: 'en-US', // Quasar language pack
// For special cases outside of where the auto-import strategy can have an impact
// (like functional components as one of the examples),
// you can manually specify Quasar components/directives to be available everywhere:
//
// components: [],
// directives: [],
// Quasar plugins
plugins: [],
},
// animations: 'all', // --- includes all animations
// https://v2.quasar.dev/options/animations
animations: [],
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-file#sourcefiles
// sourceFiles: {
// rootComponent: 'src/App.vue',
// router: 'src/router/index',
// store: 'src/store/index',
// pwaRegisterServiceWorker: 'src-pwa/register-sw',
// pwaServiceWorker: 'src-pwa/sw/custom-sw',
// pwaManifestFile: 'src-pwa/manifest.json',
// electronMain: 'src-electron/electron-main',
// electronPreload: 'src-electron/electron-preload'
// bexManifestFile: 'src-bex/manifest.json
// },
// https://v2.quasar.dev/quasar-cli-vite/developing-ssr/configuring-ssr
ssr: {
/**
* The default port that the production server should use
* (gets superseded if process.env.PORT is specified at runtime)
*/
prodPort: 3000,
middlewares: [
'render', // keep this as last one
],
// clientSideRenderingRoutes: [],
// noPreloadTagRoutes: [],
// manualStoreSerialization: true,
// manualStoreSsrContextInjection: true,
// manualStoreHydration: true,
// manualPostHydrationTrigger: true,
// prodScriptNamedExport: false,
// extendSSRPackageJson (pkgJson) {},
// extendSSRManifestJson (json) {},
// extendSSRWebserverConf (rolldownConf) {},
// pwa: true,
// pwaOfflineHtmlFilename: 'offline.html', // do NOT use index.html as name!
// extendSSRGenerateSWOptions (cfg) {},
// extendSSRInjectManifestOptions (cfg) {},
},
// https://v2.quasar.dev/quasar-cli-vite/developing-ssg/configuring-ssg
ssg: {
// onSsgRendererError: 'abort',
// ssgRendererConcurrency: 1,
// ssgRendererRetryCount: 0,
// ssgRendererRetryDelay: 1000,
// ssgRendererDirectoryIndexes: true,
// error404HtmlFilename: '404.html',
// clientSideRenderingHtmlFilename: 'csr.html',
// clientSideRenderingRoutes: [],
// noPreloadTagRoutes: []
// extendSSGRendererConf (rolldownConf) {},
// extendSSGManifestJson (json) {},
// manualStoreSerialization: true,
// manualStoreSsrContextInjection: true,
// manualStoreHydration: true,
// manualPostHydrationTrigger: true,
// pwa: true,
// pwaOfflineHtmlFilename: 'offline.html',
// extendSSGGenerateSWOptions (cfg) {},
// extendSSGInjectManifestOptions (cfg) {},
},
// https://v2.quasar.dev/quasar-cli-vite/developing-pwa/configuring-pwa
pwa: {
workboxMode: 'GenerateSW', // 'GenerateSW' or 'InjectManifest'
// swFilename: 'sw.js',
// manifestFilename: 'manifest.json',
// extendPWAManifestJson (json) {},
// useCredentialsForManifestTag: true,
// injectPWAMetaTags: false,
// extendPWACustomSWConf (rolldownConf) {},
// extendPWAGenerateSWOptions (cfg) {},
// extendPWAInjectManifestOptions (cfg) {},
// extendPWASwTsConfig (tsConfig) {}
},
// https://v2.quasar.dev/quasar-cli-vite/developing-cordova-apps/configuring-cordova
cordova: {},
// https://v2.quasar.dev/quasar-cli-vite/developing-capacitor-apps/configuring-capacitor
capacitor: {
hideSplashscreen: true,
},
// https://v2.quasar.dev/quasar-cli-vite/developing-electron-apps/configuring-electron
electron: {
// extendElectronMainConf (rolldownConf) {},
// extendElectronPreloadConf (rolldownConf) {},
// extendElectronPackageJson (pkgJson) {},
// Electron preload scripts (if any) from /src-electron, WITHOUT file extension
preloadScripts: ['electron-preload'],
// specify the debugging port to use for the Electron app when running in development mode
inspectPort: 5858,
bundler: 'packager', // 'packager' or 'builder'
packager: {
// https://github.com/electron-userland/electron-packager/blob/master/docs/api.md#options
// OS X / Mac App Store
// appBundleId: '',
// appCategoryType: '',
// osxSign: '',
// protocol: 'myapp://path',
// Windows only
// win32metadata: { ... }
},
builder: {
// https://www.electron.build/configuration
appId: 'sattle',
},
},
// https://v2.quasar.dev/quasar-cli-vite/developing-browser-extensions/configuring-bex
bex: {
// extendBexScriptsConf (rolldownConf) {},
// extendBexManifestJson (json) {},
/**
* The list of extra scripts (js/ts) not in your bex manifest that you want to
* compile and use in your browser extension. Maybe dynamic use them?
*
* Each entry in the list should be a relative filename to /src-bex/
*
* @example [ 'my-script.ts', 'sub-folder/my-other-script.js' ]
*/
extraScripts: [],
},
};
});
+35
View File
@@ -0,0 +1,35 @@
{
"orientation": "portrait",
"background_color": "#002222",
"theme_color": "#002222",
"id": "sattle",
"display_override": ["fullscreen", "minimal-ui"],
"display": "standalone",
"icons": [
{
"src": "icons/icon-128x128.png",
"sizes": "128x128",
"type": "image/png"
},
{
"src": "icons/icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "icons/icon-256x256.png",
"sizes": "256x256",
"type": "image/png"
},
{
"src": "icons/icon-384x384.png",
"sizes": "384x384",
"type": "image/png"
},
{
"src": "icons/icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
]
}
+5335
View File
File diff suppressed because it is too large Load Diff
+19
View File
@@ -0,0 +1,19 @@
{
"name": "quasar-pwa-app",
"version": "1.0.0",
"description": "Quasar PWA Folder",
"private": true,
"type": "module",
"dependencies": {
"register-service-worker": "^1.7.2"
},
"devDependencies": {
"workbox-build": "^7.0.0",
"workbox-cacheable-response": "^7.0.0",
"workbox-core": "^7.0.0",
"workbox-expiration": "^7.0.0",
"workbox-precaching": "^7.0.0",
"workbox-routing": "^7.0.0",
"workbox-strategies": "^7.0.0"
}
}
+41
View File
@@ -0,0 +1,41 @@
import { register } from "register-service-worker";
// The ready(), registered(), cached(), updatefound() and updated()
// events passes a ServiceWorkerRegistration instance in their arguments.
// ServiceWorkerRegistration: https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration
register(import.meta.env.QUASAR_SERVICE_WORKER_FILE, {
// The registrationOptions object will be passed as the second argument
// to ServiceWorkerContainer.register()
// https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register#Parameter
// registrationOptions: { scope: './' },
ready(/* registration */) {
// console.log('Service worker is active.')
},
registered(/* registration */) {
// console.log('Service worker has been registered.')
},
cached(/* registration */) {
// console.log('Content has been cached for offline use.')
},
updatefound(/* registration */) {
// console.log('New content is downloading.')
},
updated(/* registration */) {
// console.log('New content is available; please refresh.')
},
offline() {
// console.log('No internet connection found. App is running in offline mode.')
},
error(/* err */) {
// console.error('Error during service worker registration:', err)
}
});
+39
View File
@@ -0,0 +1,39 @@
/*
* This file (which will be your service worker)
* is picked up by the build system ONLY if
* quasar.config file > pwa > workboxMode is set to "InjectManifest"
*/
import { clientsClaim } from "workbox-core";
import { NavigationRoute, registerRoute } from "workbox-routing";
import {
cleanupOutdatedCaches,
createHandlerBoundToURL,
precacheAndRoute
} from "workbox-precaching";
declare const self: ServiceWorkerGlobalScope & typeof globalThis;
void self.skipWaiting();
clientsClaim();
// Use with precache injection
precacheAndRoute(self.__WB_MANIFEST);
cleanupOutdatedCaches();
if (import.meta.env.QUASAR_PROD) {
// Non-SSR/SSG fallbacks to index.html
// Production SSR/SSG fallbacks to offline.html (except for dev)
registerRoute(
new NavigationRoute(
createHandlerBoundToURL(import.meta.env.QUASAR_PWA_FALLBACK_HTML),
{
denylist: [
new RegExp(import.meta.env.QUASAR_PWA_SERVICE_WORKER_REGEX),
/workbox-(.)*\.js$/
]
}
)
);
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "../../.quasar/tsconfig.pwa-sw.json"
}
+3
View File
@@ -0,0 +1,3 @@
<template>
<router-view />
</template>
+15
View File
@@ -0,0 +1,15 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 356 360">
<path
d="M43.4 303.4c0 3.8-2.3 6.3-7.1 6.3h-15v-22h14.4c4.3 0 6.2 2.2 6.2 5.2 0 2.6-1.5 4.4-3.4 5 2.8.4 4.9 2.5 4.9 5.5zm-8-13H24.1v6.9H35c2.1 0 4-1.3 4-3.8 0-2.2-1.3-3.1-3.7-3.1zm5.1 12.6c0-2.3-1.8-3.7-4-3.7H24.2v7.7h11.7c3.4 0 4.6-1.8 4.6-4zm36.3 4v2.7H56v-22h20.6v2.7H58.9v6.8h14.6v2.3H58.9v7.5h17.9zm23-5.8v8.5H97v-8.5l-11-13.4h3.4l8.9 11 8.8-11h3.4l-10.8 13.4zm19.1-1.8V298c0-7.9 5.2-10.7 12.7-10.7 7.5 0 13 2.8 13 10.7v1.4c0 7.9-5.5 10.8-13 10.8s-12.7-3-12.7-10.8zm22.7 0V298c0-5.7-3.9-8-10-8-6 0-9.8 2.3-9.8 8v1.4c0 5.8 3.8 8.1 9.8 8.1 6 0 10-2.3 10-8.1zm37.2-11.6v21.9h-2.9l-15.8-17.9v17.9h-2.8v-22h3l15.6 18v-18h2.9zm37.9 10.2v1.3c0 7.8-5.2 10.4-12.4 10.4H193v-22h11.2c7.2 0 12.4 2.8 12.4 10.3zm-3 0c0-5.3-3.3-7.6-9.4-7.6h-8.4V307h8.4c6 0 9.5-2 9.5-7.7V298zm50.8-7.6h-9.7v19.3h-3v-19.3h-9.7v-2.6h22.4v2.6zm34.4-2.6v21.9h-3v-10.1h-16.8v10h-2.8v-21.8h2.8v9.2H296v-9.2h2.9zm34.9 19.2v2.7h-20.7v-22h20.6v2.7H316v6.8h14.5v2.3H316v7.5h17.8zM24 340.2v7.3h13.9v2.4h-14v9.6H21v-22h20v2.7H24zm41.5 11.4h-9.8v7.9H53v-22h13.3c5.1 0 8 1.9 8 6.8 0 3.7-2 6.3-5.6 7l6 8.2h-3.3l-5.8-8zm-9.8-2.6H66c3.1 0 5.3-1.5 5.3-4.7 0-3.3-2.2-4.1-5.3-4.1H55.7v8.8zm47.9 6.2H89l-2 4.3h-3.2l10.7-22.2H98l10.7 22.2h-3.2l-2-4.3zm-1-2.3l-6.3-13-6 13h12.2zm46.3-15.3v21.9H146v-17.2L135.7 358h-2.1l-10.2-15.6v17h-2.8v-21.8h3l11 16.9 11.3-17h3zm35 19.3v2.6h-20.7v-22h20.6v2.7H166v6.8h14.5v2.3H166v7.6h17.8zm47-19.3l-8.3 22h-3l-7.1-18.6-7 18.6h-3l-8.2-22h3.3L204 356l6.8-18.5h3.4L221 356l6.6-18.5h3.3zm10 11.6v-1.4c0-7.8 5.2-10.7 12.7-10.7 7.6 0 13 2.9 13 10.7v1.4c0 7.9-5.4 10.8-13 10.8-7.5 0-12.7-3-12.7-10.8zm22.8 0v-1.4c0-5.7-4-8-10-8s-9.9 2.3-9.9 8v1.4c0 5.8 3.8 8.2 9.8 8.2 6.1 0 10-2.4 10-8.2zm28.3 2.4h-9.8v7.9h-2.8v-22h13.2c5.2 0 8 1.9 8 6.8 0 3.7-2 6.3-5.6 7l6 8.2h-3.3l-5.8-8zm-9.8-2.6h10.2c3 0 5.2-1.5 5.2-4.7 0-3.3-2.1-4.1-5.2-4.1h-10.2v8.8zm40.3-1.5l-6.8 5.6v6.4h-2.9v-22h2.9v12.3l15.2-12.2h3.7l-9.9 8.1 10.3 13.8h-3.6l-8.9-12z" />
<path fill="#050A14"
d="M188.4 71.7a10.4 10.4 0 01-20.8 0 10.4 10.4 0 1120.8 0zM224.2 45c-2.2-3.9-5-7.5-8.2-10.7l-12 7c-3.7-3.2-8-5.7-12.6-7.3a49.4 49.4 0 00-9.7 13.9 59 59 0 0140.1 14l7.6-4.4a57 57 0 00-5.2-12.5zM178 125.1c4.5 0 9-.6 13.4-1.7v-14a40 40 0 0012.5-7.2 47.7 47.7 0 00-7.1-15.3 59 59 0 01-32.2 27.7v8.7c4.4 1.2 8.9 1.8 13.4 1.8zM131.8 45c-2.3 4-4 8.1-5.2 12.5l12 7a40 40 0 000 14.4c5.7 1.5 11.3 2 16.9 1.5a59 59 0 01-8-41.7l-7.5-4.3c-3.2 3.2-6 6.7-8.2 10.6z" />
<path fill="#00B4FF"
d="M224.2 98.4c2.3-3.9 4-8 5.2-12.4l-12-7a40 40 0 000-14.5c-5.7-1.5-11.3-2-16.9-1.5a59 59 0 018 41.7l7.5 4.4c3.2-3.2 6-6.8 8.2-10.7zm-92.4 0c2.2 4 5 7.5 8.2 10.7l12-7a40 40 0 0012.6 7.3c4-4.1 7.3-8.8 9.7-13.8a59 59 0 01-40-14l-7.7 4.4c1.2 4.3 3 8.5 5.2 12.4zm46.2-80c-4.5 0-9 .5-13.4 1.7V34a40 40 0 00-12.5 7.2c1.5 5.7 4 10.8 7.1 15.4a59 59 0 0132.2-27.7V20a53.3 53.3 0 00-13.4-1.8z" />
<path fill="#00B4FF"
d="M178 9.2a62.6 62.6 0 11-.1 125.2A62.6 62.6 0 01178 9.2m0-9.2a71.7 71.7 0 100 143.5A71.7 71.7 0 00178 0z" />
<path fill="#050A14"
d="M96.6 212v4.3c-9.2-.8-15.4-5.8-15.4-17.8V180h4.6v18.4c0 8.6 4 12.6 10.8 13.5zm16-31.9v18.4c0 8.9-4.3 12.8-10.9 13.5v4.4c9.2-.7 15.5-5.6 15.5-18v-18.3h-4.7zM62.2 199v-2.2c0-12.7-8.8-17.4-21-17.4-12.1 0-20.7 4.7-20.7 17.4v2.2c0 12.8 8.6 17.6 20.7 17.6 1.5 0 3-.1 4.4-.3l11.8 6.2 2-3.3-8.2-4-6.4-3.1a32 32 0 01-3.6.2c-9.8 0-16-3.9-16-13.3v-2.2c0-9.3 6.2-13.1 16-13.1 9.9 0 16.3 3.8 16.3 13.1v2.2c0 5.3-2.1 8.7-5.6 10.8l4.8 2.4c3.4-2.8 5.5-7 5.5-13.2zM168 215.6h5.1L156 179.7h-4.8l17 36zM143 205l7.4-15.7-2.4-5-15.1 31.4h5.1l3.3-7h18.3l-1.8-3.7H143zm133.7 10.7h5.2l-17.3-35.9h-4.8l17 36zm-25-10.7l7.4-15.7-2.4-5-15.1 31.4h5.1l3.3-7h18.3l-1.7-3.7h-14.8zm73.8-2.5c6-1.2 9-5.4 9-11.4 0-8-4.5-10.9-12.9-10.9h-21.4v35.5h4.6v-31.3h16.5c5 0 8.5 1.4 8.5 6.7 0 5.2-3.5 7.7-8.5 7.7h-11.4v4.1h10.7l9.3 12.8h5.5l-9.9-13.2zm-117.4 9.9c-9.7 0-14.7-2.5-18.6-6.3l-2.2 3.8c5.1 5 11 6.7 21 6.7 1.6 0 3.1-.1 4.6-.3l-1.9-4h-3zm18.4-7c0-6.4-4.7-8.6-13.8-9.4l-10.1-1c-6.7-.7-9.3-2.2-9.3-5.6 0-2.5 1.4-4 4.6-5l-1.8-3.8c-4.7 1.4-7.5 4.2-7.5 8.9 0 5.2 3.4 8.7 13 9.6l11.3 1.2c6.4.6 8.9 2 8.9 5.4 0 2.7-2.1 4.7-6 5.8l1.8 3.9c5.3-1.6 8.9-4.7 8.9-10zm-20.3-21.9c7.9 0 13.3 1.8 18.1 5.7l1.8-3.9a30 30 0 00-19.6-5.9c-2 0-4 .1-5.7.3l1.9 4 3.5-.2z" />
<path fill="#00B4FF"
d="M.5 251.9c29.6-.5 59.2-.8 88.8-1l88.7-.3 88.7.3 44.4.4 44.4.6-44.4.6-44.4.4-88.7.3-88.7-.3a7981 7981 0 01-88.8-1z" />
<path fill="none" d="M-565.2 324H-252v15.8h-313.2z" />
</svg>

After

Width:  |  Height:  |  Size: 4.4 KiB

View File
+33
View File
@@ -0,0 +1,33 @@
import { defineBoot } from '#q-app';
import { createI18n } from 'vue-i18n';
import messages from '@/i18n';
export type MessageLanguages = keyof typeof messages;
// Type-define 'en-US' as the master schema for the resource
export type MessageSchema = (typeof messages)['en-US'];
// See https://vue-i18n.intlify.dev/guide/advanced/typescript.html#global-resource-schema-type-definition
/* eslint-disable @typescript-eslint/no-empty-object-type */
declare module 'vue-i18n' {
// define the locale messages schema
export interface DefineLocaleMessage extends MessageSchema {}
// define the datetime format schema
export interface DefineDateTimeFormat {}
// define the number format schema
export interface DefineNumberFormat {}
}
/* eslint-enable @typescript-eslint/no-empty-object-type */
export default defineBoot(({ app }) => {
const i18n = createI18n<{ message: MessageSchema }, MessageLanguages>({
locale: 'en-US',
legacy: false,
messages,
});
// Set i18n instance on app
app.use(i18n);
});
+19
View File
@@ -0,0 +1,19 @@
// app global css - sattle's visual identity is inherited from lnurl-wallet
// (see src/lnurlcash/ provenance): dark teal surfaces, mint-green accents
@import '@fontsource/noto-sans/400.css';
@import '@fontsource/noto-sans/700.css';
body {
font-family: 'Noto Sans', sans-serif;
background: linear-gradient(160deg, #001616 0%, #002222 55%, #001a1a 100%);
background-attachment: fixed;
color: #55ffcc;
}
// glassy dark-teal card surface, lnurl-wallet style
.sattle-card {
background: rgba(0, 68, 68, 0.6);
border-radius: 8px;
backdrop-filter: blur(4px);
}
+23
View File
@@ -0,0 +1,23 @@
// Quasar Sass (& SCSS) Variables
// --------------------------------------------------
// sattle's visual identity is inherited from lnurl-wallet (dark teal +
// mint green). Exact values from lnurl-wallet's src/styles/style.scss:
// bg #002222, accent base #004444, primary #55ffcc,
// warning #ff8800, negative #ff4444, spent #ff6666,
// signed badge #66cc66, device badge #6699cc
$primary: #55ffcc;
$secondary: #004444;
$accent: #004444;
$dark: #002222;
$dark-page: #001616;
$positive: #66cc66;
$negative: #ff4444;
$info: #6699cc;
$warning: #ff8800;
// extra lnurl-wallet palette tokens, for use in app.scss / components
$spent: #ff6666;
$bg-glow: #001a1a;
+7
View File
@@ -0,0 +1,7 @@
// This is just an example,
// so you can safely delete all default props below
export default {
failed: 'Action failed',
success: 'Action was successful',
};
+5
View File
@@ -0,0 +1,5 @@
import enUS from './en-US';
export default {
'en-US': enUS,
};
+23
View File
@@ -0,0 +1,23 @@
<template>
<q-layout view="hHh lpR fFf">
<q-header class="bg-transparent">
<q-toolbar>
<q-toolbar-title class="text-weight-bold">sattle</q-toolbar-title>
<q-btn
flat
dense
round
icon="settings"
aria-label="Settings"
@click="$router.push('/settings')"
/>
</q-toolbar>
</q-header>
<q-page-container>
<router-view />
</q-page-container>
</q-layout>
</template>
<script setup lang="ts"></script>
+288
View File
@@ -0,0 +1,288 @@
import {
mnemonicToSeedSync,
generateMnemonic,
validateMnemonic
} from '@scure/bip39'
import {wordlist} from '@scure/bip39/wordlists/english.js'
import {HDKey, HARDENED_OFFSET} from '@scure/bip32'
import {hmac} from '@noble/hashes/hmac.js'
import {sha256} from '@noble/hashes/sha2.js'
import {secp256k1} from '@noble/curves/secp256k1.js'
import {bytesToHex, hexToBytes, utf8ToBytes} from '@noble/hashes/utils.js'
// The wallet's identity is derived against this fixed domain rather than
// window.location.hostname, so the same seed phrase always yields the same
// linking key (and thus decrypts the same bearer tokens) no matter where
// this static build happens to be hosted - github.io, a mirror, file://.
export const WALLET_DOMAIN = 'sattle'
export const generateSeedPhrase = (): string => generateMnemonic(wordlist, 128)
export const isValidSeedPhrase = (phrase: string): boolean =>
validateMnemonic(phrase.trim().toLowerCase(), wordlist)
const readUint32BE = (bytes: Uint8Array, offset: number): number =>
((bytes[offset] << 24) |
(bytes[offset + 1] << 16) |
(bytes[offset + 2] << 8) |
bytes[offset + 3]) >>>
0
// LUD-05: BIP32-based linking-key derivation, same scheme as lnurl_server -
// a seed restored there or here produces the same identity for a given domain
export const deriveLud05LinkingKey = (
seedPhrase: string,
domain: string
): Uint8Array => {
const seed = mnemonicToSeedSync(seedPhrase.trim().toLowerCase())
const master = HDKey.fromMasterSeed(seed)
const hashingKeyNode = master.derive("m/138'/0")
if (!hashingKeyNode.privateKey)
throw new Error('Could not derive hashing key')
const suffix = lud05PathSuffix(hashingKeyNode.privateKey, domain)
// path suffix longs are raw BIP32 child indices: whether each level ends up
// hardened depends solely on its own magnitude (>= 2^31), never forced
let node = master.deriveChild(138 + HARDENED_OFFSET)
for (const index of suffix) {
node = node.deriveChild(index)
}
if (!node.privateKey) throw new Error('Could not derive linking key')
return node.privateKey
}
// the HMAC half of the derivation, split out so the LUD-05 test vector
// (which starts from a fixed hashingPrivKey, not a seed phrase) can pin it
// directly - see keys.test.ts
export const lud05PathSuffix = (
hashingKey: Uint8Array,
domain: string
): number[] => {
const material = hmac(sha256, hashingKey, utf8ToBytes(domain))
return [0, 4, 8, 12].map(i => readUint32BE(material, i))
}
export const deriveWalletLinkingKey = (seedPhrase: string): Uint8Array =>
deriveLud05LinkingKey(seedPhrase, WALLET_DOMAIN)
export const linkingPubKeyHex = (linkingPrivKey: Uint8Array): string =>
bytesToHex(secp256k1.getPublicKey(linkingPrivKey, true))
// Encrypted-at-rest localStorage secret, same shape as lnurl_server's: the
// stored value is either plaintext or, if the holder opted in with a
// password, AES-GCM ciphertext keyed by a PBKDF2 stretch of that password -
// GCM's auth tag doubles as the "wrong password" check on decrypt.
const PBKDF2_ITERATIONS = 210_000
export type StoredSecret =
| {enc: false; value: string}
| {enc: true; salt: string; iv: string; ciphertext: string}
// strict shape check on a StoredSecret - a plaintext form must be exactly a
// 32-byte hex key, an encrypted form must carry hex salt/iv/ciphertext of
// the sizes encryptSecretParts produces. Guards the backup-restore path
// (storage.ts's applyBackup), where a crafted file would otherwise get an
// arbitrary "linking key" installed verbatim.
export const isValidStoredSecret = (
stored: unknown
): stored is StoredSecret => {
if (typeof stored !== 'object' || stored === null) return false
const s = stored as Record<string, unknown>
if (s.enc === false) {
return typeof s.value === 'string' && /^[0-9a-f]{64}$/i.test(s.value)
}
if (s.enc === true) {
return (
typeof s.salt === 'string' &&
/^[0-9a-f]{32}$/i.test(s.salt) &&
typeof s.iv === 'string' &&
/^[0-9a-f]{24}$/i.test(s.iv) &&
typeof s.ciphertext === 'string' &&
s.ciphertext.length > 0 &&
s.ciphertext.length % 2 === 0 &&
/^[0-9a-f]+$/i.test(s.ciphertext)
)
}
return false
}
const readSecret = (storageKey: string): StoredSecret | null => {
const raw = localStorage.getItem(storageKey)
if (!raw) return null
try {
const parsed: unknown = JSON.parse(raw)
return isValidStoredSecret(parsed) ? parsed : null
} catch {
return null
}
}
const deriveAesKeyFromPassword = (
password: string,
salt: Uint8Array
): Promise<CryptoKey> =>
crypto.subtle
.importKey('raw', utf8ToBytes(password), 'PBKDF2', false, ['deriveKey'])
.then(baseKey =>
crypto.subtle.deriveKey(
// the copy pins the TS type to Uint8Array<ArrayBuffer> - hexToBytes
// returns Uint8Array<ArrayBufferLike>, which BufferSource rejects
{
name: 'PBKDF2',
salt: new Uint8Array(salt),
iterations: PBKDF2_ITERATIONS,
hash: 'SHA-256'
},
baseKey,
{name: 'AES-GCM', length: 256},
false,
['encrypt', 'decrypt']
)
)
export type EncryptedSecretParts = {
salt: string
iv: string
ciphertext: string
}
export const encryptSecretParts = async (
value: string,
password: string
): Promise<EncryptedSecretParts> => {
const salt = crypto.getRandomValues(new Uint8Array(16))
const iv = crypto.getRandomValues(new Uint8Array(12))
const aesKey = await deriveAesKeyFromPassword(password, salt)
const ciphertext = new Uint8Array(
await crypto.subtle.encrypt(
{name: 'AES-GCM', iv},
aesKey,
utf8ToBytes(value)
)
)
return {
salt: bytesToHex(salt),
iv: bytesToHex(iv),
ciphertext: bytesToHex(ciphertext)
}
}
// rejects (WebCrypto's own auth-tag check) if the password is wrong
export const decryptSecretParts = async (
parts: EncryptedSecretParts,
password: string
): Promise<string> => {
const salt = hexToBytes(parts.salt)
const iv = hexToBytes(parts.iv)
const aesKey = await deriveAesKeyFromPassword(password, salt)
const plaintext = await crypto.subtle.decrypt(
{name: 'AES-GCM', iv},
aesKey,
hexToBytes(parts.ciphertext)
)
return new TextDecoder().decode(plaintext)
}
// The linking key is the only secret this wallet persists - the seed phrase
// it was derived from is shown once at setup and never stored. Everything
// else at rest (the bearer tokens) is encrypted with a key derived from it,
// so protecting this one record with a password protects the whole wallet.
const LINKING_KEY_STORAGE_KEY = 'sattle_linking_key'
export const savedKeyExists = (): boolean =>
readSecret(LINKING_KEY_STORAGE_KEY) !== null
export const savedKeyIsEncrypted = (): boolean =>
readSecret(LINKING_KEY_STORAGE_KEY)?.enc === true
export const getSavedLinkingKeyStored = (): StoredSecret | null =>
readSecret(LINKING_KEY_STORAGE_KEY)
export const getPlainLinkingKey = (): Uint8Array | null => {
const stored = readSecret(LINKING_KEY_STORAGE_KEY)
if (stored === null || stored.enc === true) return null
return hexToBytes(stored.value)
}
export const saveLinkingKey = async (
linkingPrivKey: Uint8Array,
password?: string
): Promise<void> => {
const hex = bytesToHex(linkingPrivKey)
if (!password) {
localStorage.setItem(
LINKING_KEY_STORAGE_KEY,
JSON.stringify({enc: false, value: hex})
)
return
}
const parts = await encryptSecretParts(hex, password)
localStorage.setItem(
LINKING_KEY_STORAGE_KEY,
JSON.stringify({enc: true, ...parts})
)
}
export const restoreLinkingKeyStored = (stored: StoredSecret): void => {
localStorage.setItem(LINKING_KEY_STORAGE_KEY, JSON.stringify(stored))
}
export const decryptSavedLinkingKey = async (
password: string
): Promise<Uint8Array> => {
const stored = readSecret(LINKING_KEY_STORAGE_KEY)
if (!stored || !stored.enc) throw new Error('No encrypted linking key saved.')
return hexToBytes(await decryptSecretParts(stored, password))
}
export const clearSavedLinkingKey = (): void => {
localStorage.removeItem(LINKING_KEY_STORAGE_KEY)
}
// The bearer-encryption key is derived (not random): sha256 over the linking
// key plus a fixed context string. Deterministic derivation is what makes
// backup/restore work with nothing but the seed phrase - restore the seed on
// a fresh device and every previously exported ciphertext decrypts again.
const BEARER_KEY_CONTEXT = 'lnurlcash-bearer-encryption-v1'
export const deriveBearerAesKey = (
linkingPrivKey: Uint8Array
): Promise<CryptoKey> => {
const material = sha256(
new Uint8Array([...linkingPrivKey, ...utf8ToBytes(BEARER_KEY_CONTEXT)])
)
return crypto.subtle.importKey('raw', material, 'AES-GCM', false, [
'encrypt',
'decrypt'
])
}
export type EncryptedRecordParts = {iv: string; ciphertext: string}
export const encryptRecord = async (
aesKey: CryptoKey,
value: object
): Promise<EncryptedRecordParts> => {
const iv = crypto.getRandomValues(new Uint8Array(12))
const ciphertext = new Uint8Array(
await crypto.subtle.encrypt(
{name: 'AES-GCM', iv},
aesKey,
utf8ToBytes(JSON.stringify(value))
)
)
return {iv: bytesToHex(iv), ciphertext: bytesToHex(ciphertext)}
}
export const decryptRecord = async <T>(
aesKey: CryptoKey,
parts: EncryptedRecordParts
): Promise<T> => {
const plaintext = await crypto.subtle.decrypt(
{name: 'AES-GCM', iv: hexToBytes(parts.iv)},
aesKey,
hexToBytes(parts.ciphertext)
)
return JSON.parse(new TextDecoder().decode(plaintext)) as T
}
+82
View File
@@ -0,0 +1,82 @@
import {
resolveNoteInput,
noteK1,
noteDeclaredAmount,
serverOf,
fetchNoteInfo,
rotateNote,
withNewK1,
NoteSpentError,
NoteUnknownError
} from 'lnurlcash-kit'
import type {Bearer, NewBearer} from './types'
// shared by Scan and Paste: resolve whatever came in to a note URL, ask the
// issuing service what it is worth (an informational GET - per spec this
// always puts k1 on the wire, so receive.ts's caller should rotate right
// after, see secureReceivedNote). Returns the note even when the info fetch
// fails - a bearer is better stored unverified than dropped.
export const receiveNote = async (
input: string,
existing: Bearer[]
): Promise<NewBearer> => {
const url = resolveNoteInput(input)
if (!url) {
throw new Error('Not an LNURLcash bearer note (needs a k1).')
}
const k1 = noteK1(url)
if (
existing.some(
b => noteK1(b.url) === k1 && serverOf(b.url) === serverOf(url)
)
) {
throw new Error('This note is already in your wallet.')
}
try {
const info = await fetchNoteInfo(url)
return {
url,
callback: info.callback,
amount: info.maxWithdrawable,
verified: true,
mintPubkey: info.mintPubkey
}
} catch (err) {
// the service positively told us this k1 is dead - that's worth more
// than the sender's own claim, so don't paper over it with an
// unverified fallback the way an unreachable/unknown-shaped error
// below does. The caller (ReceiveDialog.tsx) surfaces this and never stores
// the note.
if (err instanceof NoteSpentError || err instanceof NoteUnknownError) {
throw err
}
// service unreachable (or some other non-definitive failure) - fall
// back to the sender's own (unverified) declared amount so the note
// isn't shown as worth nothing
return {
url,
callback: '',
amount: noteDeclaredAmount(url) ?? 0,
verified: false
}
}
}
// After receiving a note, rotate it: the previous holder (and anything that
// logged the URL in transit, since the informational GET above already put
// k1 on the wire) still knows the old secret - a rotate burns it and mints
// a fresh one only this wallet knows. Returns the updated note URL. Throws
// when the service refuses (e.g. a plain LUD-03 withdraw link that doesn't
// speak lnurlcash) - the caller should warn, not fail the receive.
export const secureReceivedNote = async (note: {
url: string
callback: string
amount: number
}): Promise<string> => {
const k1 = noteK1(note.url)
if (!k1 || !note.callback) {
throw new Error('Note has no callback to rotate against yet.')
}
const result = await rotateNote(note.callback, k1)
return withNewK1(note.url, result.k1, note.amount, result.signature)
}
+49
View File
@@ -0,0 +1,49 @@
// Shared note types for the protocol core. In lnurl-wallet these lived in
// storage.ts (Bearer) and WalletContext.tsx (NewBearer); here they are
// extracted framework-free so receive.ts doesn't pull in app state modules.
// One bearer note held by this wallet - the decrypted, in-memory shape.
// `url` is the note's withdraw LNURL with the secret as its k1 param (so it
// IS the asset); the displayable bech32/lnurlw:// forms are re-encoded from
// it on demand.
export type Bearer = {
id: string
url: string
callback: string // the mutating callback from the withdrawRequest JSON, '' until first verified
amount: number // msat, last known (maxWithdrawable) - refreshed on demand
verified: boolean // false while the issuing service hasn't confirmed the note yet
// the issuing service's signing pubkey, cached once seen (withdrawRequest/
// payRequest's optional mintPubkey) - lets a note's ?sig= be checked
// offline against it without a network round trip
mintPubkey?: string
// a local-only lock, not a server-verified state: true once this wallet
// has melted/handed over the note, or the holder marked it manually. It
// just disables further mutating actions here so this copy can't be
// reused by accident - it says nothing about whether the service has
// actually burned it yet
spent?: boolean
// manual display order within its mint group - absent means "never
// manually placed", which sorts by -createdAt instead, i.e. newest first
sortIndex?: number
// a free-text note the holder can attach for their own reference (e.g.
// "rent", "gift for Alex") - purely local, never sent anywhere, no
// protocol meaning at all
label?: string
// present if this note's secret lives on a paired LNURLvault device,
// never in this browser's storage - the device's own note id. When set,
// `url` never carries a real k1 (see lnurlcash.ts's withoutK1) - it's a
// blank mirror, kept only so this bearer displays like any other
// (amount/host/label/state)
deviceId?: string
createdAt: number
updatedAt: number
}
export type NewBearer = {
url: string
callback: string
amount: number
verified: boolean
mintPubkey?: string
deviceId?: string
}
+19
View File
@@ -0,0 +1,19 @@
<template>
<div class="fullscreen bg-blue text-white text-center q-pa-md flex flex-center">
<div>
<div style="font-size: 30vh">404</div>
<div class="text-h2" style="opacity: 0.4">Oops. Nothing here...</div>
<q-btn
class="q-mt-xl"
color="white"
text-color="blue"
unelevated
to="/"
label="Go Home"
no-caps
/>
</div>
</div>
</template>
+95
View File
@@ -0,0 +1,95 @@
<template>
<q-page class="column items-center q-pa-md">
<!-- balance hero: placeholder until M2 wires the note store -->
<q-card class="sattle-card balance-card full-width q-mt-xl q-pa-lg text-center">
<div class="text-h2 text-weight-bold text-primary">0</div>
<div class="text-subtitle1 text-grey-5">sats</div>
</q-card>
<div class="col" />
<!-- primary actions: visual only, protocol flows land in M2 -->
<div class="row full-width justify-center items-center q-gutter-md q-mb-xl">
<q-btn
unelevated
color="secondary"
text-color="primary"
icon="call_received"
label="Receive"
class="action-btn"
@click="showReceive = true"
/>
<q-btn
fab
color="primary"
text-color="dark"
icon="qr_code_scanner"
aria-label="Scan"
class="scan-btn"
@click="showScan = true"
/>
<q-btn
unelevated
color="secondary"
text-color="primary"
icon="call_made"
label="Send"
class="action-btn"
@click="showSend = true"
/>
</div>
<q-dialog v-model="showReceive">
<q-card class="sattle-card q-pa-lg">
<div class="text-h6">Receive</div>
<div class="text-grey-5 q-mt-sm">Coming in milestone M2.</div>
<q-card-actions align="right">
<q-btn v-close-popup flat label="Close" color="primary" />
</q-card-actions>
</q-card>
</q-dialog>
<q-dialog v-model="showSend">
<q-card class="sattle-card q-pa-lg">
<div class="text-h6">Send</div>
<div class="text-grey-5 q-mt-sm">Coming in milestone M2.</div>
<q-card-actions align="right">
<q-btn v-close-popup flat label="Close" color="primary" />
</q-card-actions>
</q-card>
</q-dialog>
<q-dialog v-model="showScan">
<q-card class="sattle-card q-pa-lg">
<div class="text-h6">Scan</div>
<div class="text-grey-5 q-mt-sm">Coming in milestone M2.</div>
<q-card-actions align="right">
<q-btn v-close-popup flat label="Close" color="primary" />
</q-card-actions>
</q-card>
</q-dialog>
</q-page>
</template>
<script setup lang="ts">
import { ref } from 'vue';
const showReceive = ref(false);
const showSend = ref(false);
const showScan = ref(false);
</script>
<style lang="scss" scoped>
.balance-card {
max-width: 420px;
}
.action-btn {
min-width: 120px;
border-radius: 8px;
}
.scan-btn {
margin: 0 8px;
}
</style>
+37
View File
@@ -0,0 +1,37 @@
<template>
<q-page class="q-pa-md">
<div class="text-h5 text-weight-bold q-mb-md">Settings</div>
<!-- group shells only - entries are placeholders until their milestone
lands (see project plan: M2 flows, M3 mints, M4 backup/security,
M5 NWC) -->
<q-list
v-for="group in groups"
:key="group.label"
class="sattle-card q-mb-md"
bordered
separator
>
<q-item-label header class="text-primary text-weight-bold">
{{ group.label }}
</q-item-label>
<q-item v-for="item in group.items" :key="item" disable>
<q-item-section>{{ item }}</q-item-section>
</q-item>
</q-list>
</q-page>
</template>
<script setup lang="ts">
const groups: { label: string; items: string[] }[] = [
{ label: 'Wallet', items: ['Backup', 'Security'] },
{ label: 'Connections', items: ['Nostr Wallet Connect', 'Nostr'] },
{ label: 'Mints', items: ['Manage mints', 'Move funds'] },
{ label: 'Preferences', items: ['Appearance', 'Language', 'Fiat unit'] },
{
label: 'Advanced',
items: ['Notes', 'Offline mode', 'Activity log', 'Export / import', 'Developer'],
},
{ label: 'About', items: ['Docs', 'Protocol'] },
];
</script>
+34
View File
@@ -0,0 +1,34 @@
<template>
<q-page class="column items-center justify-center q-pa-md">
<div class="text-h3 text-weight-bold text-primary">sattle</div>
<div class="text-subtitle1 text-grey-5 q-mt-sm q-mb-xl text-center">
A wallet for lnurlcash bearer notes.
</div>
<!-- onboarding placeholder: create/restore flows land in M4 -->
<q-btn
unelevated
color="secondary"
text-color="primary"
label="Create wallet"
class="full-width q-mb-sm onboarding-btn"
disable
/>
<q-btn
outline
color="primary"
label="Restore wallet"
class="full-width onboarding-btn"
disable
/>
</q-page>
</template>
<script setup lang="ts"></script>
<style lang="scss" scoped>
.onboarding-btn {
max-width: 320px;
border-radius: 8px;
}
</style>
+38
View File
@@ -0,0 +1,38 @@
import { defineRouter } from '#q-app';
import {
createMemoryHistory,
createRouter,
createWebHashHistory,
createWebHistory,
} from 'vue-router';
import routes from './routes';
/*
* If not building with SSR mode, you can
* directly export the Router instantiation;
*
* The function below can be async too; either use
* async/await or return a Promise which resolves
* with the Router instance.
*/
export default defineRouter((/* { store, ssrContext } */) => {
const createHistory = import.meta.env.QUASAR_SERVER
? createMemoryHistory
: import.meta.env.QUASAR_VUE_ROUTER_MODE === 'history'
? createWebHistory
: createWebHashHistory;
const Router = createRouter({
scrollBehavior: () => ({ left: 0, top: 0 }),
routes,
// Leave this as is and make changes in quasar.conf.js instead!
// quasar.conf.js -> build -> vueRouterMode
// quasar.conf.js -> build -> publicPath
history: createHistory(import.meta.env.QUASAR_VUE_ROUTER_BASE),
});
return Router;
});
+25
View File
@@ -0,0 +1,25 @@
import type { RouteRecordRaw } from 'vue-router';
const routes: RouteRecordRaw[] = [
{
path: '/',
component: () => import('@/layouts/MainLayout.vue'),
children: [
{ path: '', component: () => import('@/pages/IndexPage.vue') },
{ path: 'settings', component: () => import('@/pages/SettingsPage.vue') },
],
},
{
path: '/welcome',
component: () => import('@/pages/WelcomePage.vue'),
},
// Always leave this as last one,
// but you can also remove it
{
path: '/:catchAll(.*)*',
component: () => import('@/pages/ErrorNotFound.vue'),
},
];
export default routes;
+32
View File
@@ -0,0 +1,32 @@
import { defineStore } from '#q-app';
import { createPinia } from 'pinia';
/*
* When adding new properties to stores, you should also
* extend the `PiniaCustomProperties` interface.
* @see https://pinia.vuejs.org/core-concepts/plugins.html#typing-new-store-properties
*/
declare module 'pinia' {
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface PiniaCustomProperties {
// add your custom properties here, if any
}
}
/*
* If not building with SSR mode, you can
* directly export the Store instantiation;
*
* The function below can be async too; either use
* async/await or return a Promise which resolves
* with the Store instance.
*/
export default defineStore((/* { ssrContext } */) => {
const pinia = createPinia();
// You can add Pinia plugins here
// pinia.use(SomePiniaPlugin)
return pinia;
});
+10
View File
@@ -0,0 +1,10 @@
{
"extends": "./.quasar/tsconfig.json",
"compilerOptions": {
// The extracted protocol core (src/lnurlcash/) is a verbatim, tested
// client from lnurl-wallet, written against standard `strict` without
// these two extended flags. Keep them off so the core stays untouched.
"exactOptionalPropertyTypes": false,
"noUncheckedIndexedAccess": false
}
}
+13
View File
@@ -0,0 +1,13 @@
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
// the tested modules are pure crypto/codec helpers - node's own
// WebCrypto (crypto.subtle) covers everything they need, no jsdom
environment: 'node',
include: ['src/**/*.test.ts'],
// protocol tests live in lnurlcash-kit (its conformance suite); app tests
// arrive with M2 flows. Don't fail CI until then.
passWithNoTests: true,
},
});