pleasenobugs 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +141 -0
- package/dist/client.js +279 -0
- package/dist/index.js +1153 -0
- package/dist/pleasenobugs.iife.js +2 -0
- package/dist/types/client.d.ts +125 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/element.d.ts +71 -0
- package/dist/types/element.d.ts.map +1 -0
- package/dist/types/i18n.d.ts +343 -0
- package/dist/types/i18n.d.ts.map +1 -0
- package/dist/types/index.d.ts +32 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/signer.d.ts +80 -0
- package/dist/types/signer.d.ts.map +1 -0
- package/dist/types/ui/App.d.ts +35 -0
- package/dist/types/ui/App.d.ts.map +1 -0
- package/dist/types/ui/Compose.d.ts +55 -0
- package/dist/types/ui/Compose.d.ts.map +1 -0
- package/dist/types/ui/PostCard.d.ts +53 -0
- package/dist/types/ui/PostCard.d.ts.map +1 -0
- package/dist/types/ui/Sheets.d.ts +27 -0
- package/dist/types/ui/Sheets.d.ts.map +1 -0
- package/dist/types/ui/icons.d.ts +23 -0
- package/dist/types/ui/icons.d.ts.map +1 -0
- package/dist/types/when.d.ts +19 -0
- package/dist/types/when.d.ts.map +1 -0
- package/package.json +62 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 lennylenders
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# pleasenobugs
|
|
2
|
+
|
|
3
|
+
The [PleaseNoBugs](../../README.md) widget: a feedback board in one tag, plus
|
|
4
|
+
the headless client it is built on. Inside Nimiq Pay it signs with the user's
|
|
5
|
+
wallet by itself; everywhere else it reads, and your app can hand it a signer.
|
|
6
|
+
|
|
7
|
+
## One line, a button in the corner
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<script src="https://unpkg.com/pleasenobugs"></script>
|
|
11
|
+
<please-no-bugs project="YOUR_PROJECT_ID" server="https://YOUR_SERVER" mode="floating"></please-no-bugs>
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Three ways to show it
|
|
15
|
+
|
|
16
|
+
| `mode` | What it does |
|
|
17
|
+
|---|---|
|
|
18
|
+
| `inline` (default) | Fills the element. Give it a height, or it grows with its posts. |
|
|
19
|
+
| `floating` | A small button in the corner that opens the board over the whole screen. |
|
|
20
|
+
| `overlay` | The board over the whole screen, right now. |
|
|
21
|
+
|
|
22
|
+
From a button of your own:
|
|
23
|
+
|
|
24
|
+
```js
|
|
25
|
+
import { open } from 'pleasenobugs';
|
|
26
|
+
menuItem.onclick = () => open({ project: 'YOUR_PROJECT_ID', server: 'https://YOUR_SERVER' });
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Attributes, properties and events
|
|
30
|
+
|
|
31
|
+
| Attribute | |
|
|
32
|
+
|---|---|
|
|
33
|
+
| `project`, `server` | Required. |
|
|
34
|
+
| `mode` | `inline`, `floating` or `overlay`. |
|
|
35
|
+
| `lang` | `en`, `nl`, `de`, or any code you supply `strings` for. Defaults to Nimiq Pay's language, then the page's. |
|
|
36
|
+
| `theme` | `auto` (follows the phone), `light`, `dark`, `shitti`. |
|
|
37
|
+
| `accent` | One colour, e.g. `#e84a5f`. The text on it picks black or white by itself. |
|
|
38
|
+
| `app-name` | What answers are signed with ("Shitti says"). Defaults to the project's name. |
|
|
39
|
+
| `name` | A display name you already know, offered when the user chooses to show theirs. |
|
|
40
|
+
|
|
41
|
+
| Property | |
|
|
42
|
+
|---|---|
|
|
43
|
+
| `signer` | How to sign outside Nimiq Pay (below). |
|
|
44
|
+
| `appLogin` | Your app's own login signature, so nobody signs twice (below). |
|
|
45
|
+
| `context` | Sent with every bug report, to owners only: `{ version: '1.4.0' }`. |
|
|
46
|
+
| `noise` | Words common in your app, so "said already?" ignores them: `['nim', 'wallet']`. |
|
|
47
|
+
| `strings` | Override any text: `{ 'board.title': 'Ideas box' }`. Keys are in `src/i18n.ts`. |
|
|
48
|
+
|
|
49
|
+
Events: `pleasenobugs:posted` (`detail: { id, kind }`) and `pleasenobugs:close`.
|
|
50
|
+
|
|
51
|
+
## Theming
|
|
52
|
+
|
|
53
|
+
The widget lives in a shadow root, so your CSS cannot break it. These custom
|
|
54
|
+
properties cross that boundary on purpose and are the theming API:
|
|
55
|
+
|
|
56
|
+
```css
|
|
57
|
+
please-no-bugs {
|
|
58
|
+
--pnb-bg: #fff; /* the page */
|
|
59
|
+
--pnb-surface: #f4f4f7; /* a card */
|
|
60
|
+
--pnb-surface-2: #e8e8ef; /* a chip or field inside a card */
|
|
61
|
+
--pnb-sunken: #e8e8ef; /* the Top/New trough */
|
|
62
|
+
--pnb-line: #dcdce5;
|
|
63
|
+
--pnb-text: #1b1b24;
|
|
64
|
+
--pnb-text-quiet: #5a5a6b;
|
|
65
|
+
--pnb-accent: #2563eb;
|
|
66
|
+
--pnb-on-accent: #fff;
|
|
67
|
+
--pnb-danger: #d23b2f;
|
|
68
|
+
--pnb-bug: #e5484d; --pnb-idea: #e9a00b;
|
|
69
|
+
--pnb-planned: #3e7bfa; --pnb-done: #2f9e66; --pnb-declined: #8b8d98;
|
|
70
|
+
--pnb-radius: 8px;
|
|
71
|
+
--pnb-radius-sheet: 16px;
|
|
72
|
+
--pnb-font: inherit; /* your app's font */
|
|
73
|
+
--pnb-z: 2147483000; /* overlay and floating button */
|
|
74
|
+
--pnb-inset-top: env(safe-area-inset-top, 0px); /* what covers the screen's top */
|
|
75
|
+
--pnb-inset-bottom: env(safe-area-inset-bottom, 0px); /* and its bottom */
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Inside Nimiq Pay, set the two insets yourself if you measure Pay's bar.**
|
|
80
|
+
Pay draws its own bar over the page and `env()` cannot see it, so a full-screen
|
|
81
|
+
board can end up underneath it. Only the overlay and the floating button use
|
|
82
|
+
them; an inline board ignores both.
|
|
83
|
+
|
|
84
|
+
## Reusing your app's own login
|
|
85
|
+
|
|
86
|
+
If your app already has users sign a fixed login message, hand that signature
|
|
87
|
+
to the widget and nobody signs twice:
|
|
88
|
+
|
|
89
|
+
```js
|
|
90
|
+
board.appLogin = { address, publicKey, signature, message: 'Sign in to My app' };
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
The project has to list that exact message first (`loginMessages`, through the
|
|
94
|
+
dashboard or `create-project --login-message`). Set `appLogin` to `null` when
|
|
95
|
+
the user logs out of your app.
|
|
96
|
+
|
|
97
|
+
## Signing outside Nimiq Pay
|
|
98
|
+
|
|
99
|
+
Give the element a function that signs a message and says which address did.
|
|
100
|
+
With the Nimiq Hub:
|
|
101
|
+
|
|
102
|
+
```js
|
|
103
|
+
import HubApi from '@nimiq/hub-api';
|
|
104
|
+
const hub = new HubApi('https://hub.nimiq.com');
|
|
105
|
+
const hex = (b) => Array.from(b, (x) => x.toString(16).padStart(2, '0')).join('');
|
|
106
|
+
|
|
107
|
+
document.querySelector('please-no-bugs').signer = async (message) => {
|
|
108
|
+
const r = await hub.signMessage({ appName: 'My app', message });
|
|
109
|
+
return { address: r.signer, publicKey: hex(r.signerPublicKey), signature: hex(r.signature) };
|
|
110
|
+
};
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Without a signer outside Nimiq Pay, the board is read-only and says so when
|
|
114
|
+
somebody tries to post.
|
|
115
|
+
|
|
116
|
+
## Headless
|
|
117
|
+
|
|
118
|
+
Everything the widget does goes through a client you can use directly, with no
|
|
119
|
+
UI and no Preact:
|
|
120
|
+
|
|
121
|
+
```js
|
|
122
|
+
import { createClient, sortPosts, createMatcher } from 'pleasenobugs/client';
|
|
123
|
+
|
|
124
|
+
const client = createClient({ server: 'https://YOUR_SERVER', project: 'YOUR_PROJECT_ID' });
|
|
125
|
+
const board = await client.board(); // never asks the wallet
|
|
126
|
+
if (board.ok) render(sortPosts(board.data.posts, 'top'));
|
|
127
|
+
await client.post({ id: crypto.randomUUID(), kind: 'idea', text: 'Dark mode' }); // asks once, then remembers
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Every call answers `{ ok: true, data }` or `{ ok: false, status, error }`, and
|
|
131
|
+
never throws.
|
|
132
|
+
|
|
133
|
+
## Try it
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
npm run build && npm run demo -w pleasenobugs
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Opens a demo on http://localhost:5180 with a seeded board and three fake
|
|
140
|
+
wallets to switch between. The demo server signs for them; nothing in the
|
|
141
|
+
package does.
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
function L(e) {
|
|
2
|
+
return e.replace(/\s+/g, "").toUpperCase();
|
|
3
|
+
}
|
|
4
|
+
const z = 30 * 24 * 60 * 60 * 1e3, A = 5 * 60 * 1e3;
|
|
5
|
+
function D(e) {
|
|
6
|
+
return [
|
|
7
|
+
"PleaseNoBugs login",
|
|
8
|
+
`Project: ${e.project}`,
|
|
9
|
+
`Origin: ${j(e.origin)}`,
|
|
10
|
+
`Issued: ${new Date(e.issued).toISOString()}`
|
|
11
|
+
].join(`
|
|
12
|
+
`);
|
|
13
|
+
}
|
|
14
|
+
function j(e) {
|
|
15
|
+
try {
|
|
16
|
+
return new URL(e).origin;
|
|
17
|
+
} catch {
|
|
18
|
+
return e;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function E(e, r = Date.now()) {
|
|
22
|
+
return Number.isFinite(e) && e <= r + A && r - e <= z;
|
|
23
|
+
}
|
|
24
|
+
function M(e) {
|
|
25
|
+
return `Nimiq ${U(JSON.stringify(e))}`;
|
|
26
|
+
}
|
|
27
|
+
function U(e) {
|
|
28
|
+
const r = new TextEncoder().encode(e);
|
|
29
|
+
let o = "";
|
|
30
|
+
for (const i of r)
|
|
31
|
+
o += String.fromCharCode(i);
|
|
32
|
+
return btoa(o).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
33
|
+
}
|
|
34
|
+
const G = [
|
|
35
|
+
// Dutch
|
|
36
|
+
"aan",
|
|
37
|
+
"als",
|
|
38
|
+
"bij",
|
|
39
|
+
"dan",
|
|
40
|
+
"dat",
|
|
41
|
+
"deze",
|
|
42
|
+
"die",
|
|
43
|
+
"dit",
|
|
44
|
+
"een",
|
|
45
|
+
"heb",
|
|
46
|
+
"het",
|
|
47
|
+
"ik",
|
|
48
|
+
"is",
|
|
49
|
+
"kan",
|
|
50
|
+
"kun",
|
|
51
|
+
"maar",
|
|
52
|
+
"met",
|
|
53
|
+
"mijn",
|
|
54
|
+
"niet",
|
|
55
|
+
"ook",
|
|
56
|
+
"van",
|
|
57
|
+
"voor",
|
|
58
|
+
"wil",
|
|
59
|
+
"word",
|
|
60
|
+
"wordt",
|
|
61
|
+
"zijn",
|
|
62
|
+
"zou",
|
|
63
|
+
"graag",
|
|
64
|
+
"meer",
|
|
65
|
+
"moet",
|
|
66
|
+
// English
|
|
67
|
+
"and",
|
|
68
|
+
"are",
|
|
69
|
+
"but",
|
|
70
|
+
"can",
|
|
71
|
+
"for",
|
|
72
|
+
"have",
|
|
73
|
+
"more",
|
|
74
|
+
"not",
|
|
75
|
+
"should",
|
|
76
|
+
"that",
|
|
77
|
+
"the",
|
|
78
|
+
"this",
|
|
79
|
+
"want",
|
|
80
|
+
"when",
|
|
81
|
+
"with",
|
|
82
|
+
"would",
|
|
83
|
+
"you",
|
|
84
|
+
"your",
|
|
85
|
+
// German
|
|
86
|
+
"aber",
|
|
87
|
+
"auch",
|
|
88
|
+
"bitte",
|
|
89
|
+
"dass",
|
|
90
|
+
"denn",
|
|
91
|
+
"ein",
|
|
92
|
+
"eine",
|
|
93
|
+
"einen",
|
|
94
|
+
"gerne",
|
|
95
|
+
"ich",
|
|
96
|
+
"ist",
|
|
97
|
+
"kann",
|
|
98
|
+
"mehr",
|
|
99
|
+
"mein",
|
|
100
|
+
"meine",
|
|
101
|
+
"nicht",
|
|
102
|
+
"oder",
|
|
103
|
+
"sein",
|
|
104
|
+
"sollte",
|
|
105
|
+
"und",
|
|
106
|
+
"wenn",
|
|
107
|
+
"werden",
|
|
108
|
+
"wird",
|
|
109
|
+
"wollen",
|
|
110
|
+
"möchte",
|
|
111
|
+
// Every board is about an app
|
|
112
|
+
"app"
|
|
113
|
+
];
|
|
114
|
+
function W(e = []) {
|
|
115
|
+
const r = /* @__PURE__ */ new Set([...G, ...[...e].map((t) => t.toLowerCase())]), o = /* @__PURE__ */ new WeakMap(), i = (t) => new Set(t.toLowerCase().replace(/[^\p{L}\p{N}\s]/gu, " ").split(/\s+/).filter((f) => f.length >= 4 && !r.has(f)));
|
|
116
|
+
return function(f, m, w = 3) {
|
|
117
|
+
const d = i(m);
|
|
118
|
+
return d.size < 2 ? [] : f.map((s) => {
|
|
119
|
+
let u = o.get(s);
|
|
120
|
+
u || (u = i(s.text), o.set(s, u));
|
|
121
|
+
let g = 0;
|
|
122
|
+
for (const T of d)
|
|
123
|
+
u.has(T) && g++;
|
|
124
|
+
return { post: s, shared: g };
|
|
125
|
+
}).filter((s) => s.shared >= 2).sort((s, u) => u.shared - s.shared || u.post.votes - s.post.votes).slice(0, w).map((s) => s.post);
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function B(e, r) {
|
|
129
|
+
const o = [...e];
|
|
130
|
+
return r === "new" ? o.sort((i, t) => t.at - i.at) : o.sort((i, t) => t.votes - i.votes || t.at - i.at);
|
|
131
|
+
}
|
|
132
|
+
class I extends Error {
|
|
133
|
+
constructor(r, o) {
|
|
134
|
+
super(o ?? r), this.reason = r, this.name = "SignerError";
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
const x = 2e3;
|
|
138
|
+
function J() {
|
|
139
|
+
return typeof window < "u" && !!window.nimiq;
|
|
140
|
+
}
|
|
141
|
+
function R(e) {
|
|
142
|
+
return window.nimiq ? Promise.resolve(window.nimiq) : new Promise((r, o) => {
|
|
143
|
+
const i = Date.now(), t = setInterval(() => {
|
|
144
|
+
window.nimiq ? (clearInterval(t), r(window.nimiq)) : Date.now() - i > e && (clearInterval(t), o(new I("no_wallet", "Not running inside Nimiq Pay")));
|
|
145
|
+
}, 50);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function F(e = x) {
|
|
149
|
+
return async (r) => {
|
|
150
|
+
const o = await R(e), i = await o.listAccounts();
|
|
151
|
+
if (!Array.isArray(i) || !i.length) throw new I("no_account");
|
|
152
|
+
const t = await o.sign(r);
|
|
153
|
+
if (!t || !("signature" in t))
|
|
154
|
+
throw new I("declined", t && "error" in t ? t.error.message : void 0);
|
|
155
|
+
return { address: i[0], publicKey: t.publicKey, signature: t.signature };
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function H(e) {
|
|
159
|
+
const r = e.server.replace(/\/+$/, ""), o = e.project, i = j(e.origin ?? (typeof location < "u" ? location.origin : "")), t = e.signer === null ? void 0 : e.signer ?? (J() ? F() : void 0), f = e.fetch ?? globalThis.fetch.bind(globalThis), m = e.storage === void 0 ? K() : e.storage, w = `pleasenobugs.proof.${o}.${i}`;
|
|
160
|
+
let d = T(), s = null, u = !1;
|
|
161
|
+
function g() {
|
|
162
|
+
if (u || !e.appLogin) return null;
|
|
163
|
+
const n = typeof e.appLogin == "function" ? e.appLogin() : e.appLogin;
|
|
164
|
+
return n ? { ...n, origin: i, issued: 0 } : null;
|
|
165
|
+
}
|
|
166
|
+
function T() {
|
|
167
|
+
try {
|
|
168
|
+
const n = m?.getItem(w);
|
|
169
|
+
if (!n) return null;
|
|
170
|
+
const a = JSON.parse(n);
|
|
171
|
+
return E(a.issued) ? a : null;
|
|
172
|
+
} catch {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
function v(n) {
|
|
177
|
+
d = n;
|
|
178
|
+
try {
|
|
179
|
+
n ? m?.setItem(w, JSON.stringify(n)) : m?.removeItem(w);
|
|
180
|
+
} catch {
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function S() {
|
|
184
|
+
const n = g();
|
|
185
|
+
return n || (d && !E(d.issued) && v(null), d);
|
|
186
|
+
}
|
|
187
|
+
function N() {
|
|
188
|
+
const n = g();
|
|
189
|
+
return n ? Promise.resolve({ ok: !0, data: L(n.address) }) : t ? s || (s = (async () => {
|
|
190
|
+
try {
|
|
191
|
+
const a = Date.now(), c = await t(D({ project: o, origin: i, issued: a }));
|
|
192
|
+
return v({ ...c, origin: i, issued: a }), { ok: !0, data: L(c.address) };
|
|
193
|
+
} catch (a) {
|
|
194
|
+
return a instanceof I && a.reason === "no_wallet" ? { ok: !1, status: 0, error: "no_signer" } : { ok: !1, status: 0, error: "declined" };
|
|
195
|
+
} finally {
|
|
196
|
+
s = null;
|
|
197
|
+
}
|
|
198
|
+
})(), s) : Promise.resolve({ ok: !1, status: 0, error: "no_signer" });
|
|
199
|
+
}
|
|
200
|
+
async function l(n, a, c) {
|
|
201
|
+
const k = async (y) => {
|
|
202
|
+
const $ = {};
|
|
203
|
+
c.body !== void 0 && ($["content-type"] = "application/json"), y && ($.authorization = M(y));
|
|
204
|
+
let q;
|
|
205
|
+
try {
|
|
206
|
+
q = await f(`${r}${a}`, {
|
|
207
|
+
method: n,
|
|
208
|
+
headers: $,
|
|
209
|
+
...c.body !== void 0 ? { body: JSON.stringify(c.body) } : {}
|
|
210
|
+
});
|
|
211
|
+
} catch {
|
|
212
|
+
return { ok: !1, status: 0, error: "network" };
|
|
213
|
+
}
|
|
214
|
+
const b = await q.json().catch(() => null);
|
|
215
|
+
if (q.ok) return { ok: !0, data: b };
|
|
216
|
+
const C = b && typeof b.error == "string" ? b.error : "internal";
|
|
217
|
+
return { ok: !1, status: q.status, error: C, body: b };
|
|
218
|
+
};
|
|
219
|
+
if (c.auth === "none") return k(null);
|
|
220
|
+
let p = S();
|
|
221
|
+
if (!p && c.auth === "required") {
|
|
222
|
+
const y = await N();
|
|
223
|
+
if (!y.ok) return y;
|
|
224
|
+
p = S();
|
|
225
|
+
}
|
|
226
|
+
const _ = await k(p);
|
|
227
|
+
if (_.ok || _.status !== 401 || !p) return _;
|
|
228
|
+
if (p.message !== void 0 ? u = !0 : v(null), c.auth === "optional") return k(null);
|
|
229
|
+
const O = await N();
|
|
230
|
+
return O.ok ? k(S()) : O;
|
|
231
|
+
}
|
|
232
|
+
const h = (n = "") => `/v1/projects/${encodeURIComponent(o)}${n}`, P = (n) => h(`/posts/${encodeURIComponent(n)}`);
|
|
233
|
+
return {
|
|
234
|
+
/** The project this client talks to. */
|
|
235
|
+
project: o,
|
|
236
|
+
/** Whether the user can be signed in at all: a signer, or an app login. */
|
|
237
|
+
get canSign() {
|
|
238
|
+
return !!t || g() !== null;
|
|
239
|
+
},
|
|
240
|
+
/** The signed-in address, if a proof is stored. */
|
|
241
|
+
address() {
|
|
242
|
+
const n = S();
|
|
243
|
+
return n ? L(n.address) : null;
|
|
244
|
+
},
|
|
245
|
+
signIn: N,
|
|
246
|
+
/** Forget the stored proof. The next write asks the wallet again. */
|
|
247
|
+
signOut() {
|
|
248
|
+
v(null);
|
|
249
|
+
},
|
|
250
|
+
/** The whole board, plus `me` when signed in. Never prompts. */
|
|
251
|
+
board: () => l("GET", h("/posts"), { auth: "optional" }),
|
|
252
|
+
me: () => l("GET", h("/me"), { auth: "required" }),
|
|
253
|
+
answers: () => l("GET", h("/answers"), { auth: "required" }),
|
|
254
|
+
post: (n) => l("POST", h("/posts"), { body: n, auth: "required" }),
|
|
255
|
+
vote: (n, a) => l("POST", `${P(n)}/vote`, {
|
|
256
|
+
body: { up: a },
|
|
257
|
+
auth: "required"
|
|
258
|
+
}),
|
|
259
|
+
remove: (n) => l("DELETE", P(n), { auth: "required" }),
|
|
260
|
+
setName: (n) => l("PUT", h("/me"), { body: { name: n }, auth: "required" }),
|
|
261
|
+
manage: (n, a) => l("POST", `${P(n)}/manage`, { body: a, auth: "required" })
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
function K() {
|
|
265
|
+
try {
|
|
266
|
+
const e = globalThis.localStorage, r = "__pleasenobugs__";
|
|
267
|
+
return e.setItem(r, "1"), e.removeItem(r), e;
|
|
268
|
+
} catch {
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
export {
|
|
273
|
+
I as SignerError,
|
|
274
|
+
H as createClient,
|
|
275
|
+
W as createMatcher,
|
|
276
|
+
J as insideNimiqPay,
|
|
277
|
+
F as nimiqPaySigner,
|
|
278
|
+
B as sortPosts
|
|
279
|
+
};
|