@bwalletx/connect 0.2.0 → 0.4.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/BRAND.md +16 -0
- package/CHANGELOG.md +25 -0
- package/README.md +189 -4
- package/dist/bwalletx-connect.global.js +41 -3
- package/dist/bwalletx-connect.global.js.map +1 -1
- package/dist/bwalletx-shell.global.js +54 -0
- package/dist/bwalletx-shell.global.js.map +1 -0
- package/dist/chunk-7NAKOJGZ.js +442 -0
- package/dist/chunk-7NAKOJGZ.js.map +1 -0
- package/dist/chunk-FUQ46RJV.js +404 -0
- package/dist/chunk-FUQ46RJV.js.map +1 -0
- package/dist/chunk-OMEKHKMM.js +530 -0
- package/dist/chunk-OMEKHKMM.js.map +1 -0
- package/dist/index.cjs +425 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -62
- package/dist/index.d.ts +23 -62
- package/dist/index.js +35 -1
- package/dist/index.js.map +1 -1
- package/dist/manifest-Caj_Raqm.d.cts +81 -0
- package/dist/manifest-Caj_Raqm.d.ts +81 -0
- package/dist/next.cjs +415 -0
- package/dist/next.cjs.map +1 -0
- package/dist/next.d.cts +48 -0
- package/dist/next.d.ts +48 -0
- package/dist/next.js +107 -0
- package/dist/next.js.map +1 -0
- package/dist/react.cjs +586 -36
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +74 -28
- package/dist/react.d.ts +74 -28
- package/dist/react.js +175 -3
- package/dist/react.js.map +1 -1
- package/dist/server.cjs +339 -4
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +204 -2
- package/dist/server.d.ts +204 -2
- package/dist/server.js +36 -107
- package/dist/server.js.map +1 -1
- package/dist/shell-react.cjs +361 -0
- package/dist/shell-react.cjs.map +1 -0
- package/dist/shell-react.d.cts +58 -0
- package/dist/shell-react.d.ts +58 -0
- package/dist/shell-react.js +52 -0
- package/dist/shell-react.js.map +1 -0
- package/dist/shell.cjs +578 -0
- package/dist/shell.cjs.map +1 -0
- package/dist/shell.d.cts +132 -0
- package/dist/shell.d.ts +132 -0
- package/dist/shell.js +51 -0
- package/dist/shell.js.map +1 -0
- package/dist/wallets-VOKIKBbO.d.cts +250 -0
- package/dist/wallets-VOKIKBbO.d.ts +250 -0
- package/package.json +65 -14
- package/schema/bapp.schema.json +95 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { WalletInterface, WalletProtocol } from '@bsv/sdk';
|
|
2
|
+
import { f as PairingOptions, W as WalletOption } from './wallets-VOKIKBbO.js';
|
|
3
|
+
export { g as BRC29_PROTOCOL, i as Brc29Remittance, B as BuyTokenRequest, C as ConnectedWallet, D as DiscoverWalletsOptions, H as HandCashAdapterOptions, L as LegacyPayer, j as PairConnectionOptions, k as PairStorage, l as PairedWallet, b as PayOptions, m as PayOutput, P as PayRequest, a as PayResult, n as PaySource, c as PaymentError, o as PaymentErrorCode, S as SocketFactory, q as SocketLike, T as TokenQuote, r as WalletKind, s as amountInSats, d as brc100Option, t as buyToken, u as clearPairing, e as discoverWallets, h as handcashAdapter, v as isIdentityKeyHex, w as isPaymail, x as pairBwalletX, p as pairingOption, y as pay, z as resolvePaymailP2P, A as restorePairing, E as tip } from './wallets-VOKIKBbO.js';
|
|
2
4
|
export { AuthorizeParams, GET_URL, SIGNIN_CSS, SIGNIN_TAG, SigninBrand, SigninLabel, SigninSize, SigninTheme, WEB_WALLET_URL, buildAuthorizeUrl, defineBwalletxSignin, markSvg, signinText } from './element.js';
|
|
3
5
|
|
|
4
6
|
/** Ids bWalletX announces in BRC-100 wallet discovery. */
|
|
@@ -24,67 +26,6 @@ declare function discoverBwalletX(ms?: number): Promise<FoundWallet | null>;
|
|
|
24
26
|
*/
|
|
25
27
|
declare function findBwalletX(ms?: number): Promise<WalletInterface | null>;
|
|
26
28
|
|
|
27
|
-
/** localStorage-shaped storage. Methods may be sync or async. */
|
|
28
|
-
interface PairStorage {
|
|
29
|
-
getItem(key: string): string | null | Promise<string | null>;
|
|
30
|
-
setItem(key: string, value: string): void | Promise<void>;
|
|
31
|
-
removeItem(key: string): void | Promise<void>;
|
|
32
|
-
}
|
|
33
|
-
/** The minimum of the browser WebSocket API this package uses (the `ws` package also fits). */
|
|
34
|
-
interface SocketLike {
|
|
35
|
-
readonly readyState: number;
|
|
36
|
-
onopen: ((ev: unknown) => void) | null;
|
|
37
|
-
onmessage: ((ev: {
|
|
38
|
-
data: unknown;
|
|
39
|
-
}) => void) | null;
|
|
40
|
-
onerror: ((ev: unknown) => void) | null;
|
|
41
|
-
onclose: ((ev: unknown) => void) | null;
|
|
42
|
-
send(data: string): void;
|
|
43
|
-
close(): void;
|
|
44
|
-
}
|
|
45
|
-
type SocketFactory = (url: string) => SocketLike;
|
|
46
|
-
interface PairConnectionOptions {
|
|
47
|
-
/** Where the pairing is kept so it survives a reload. Default: localStorage, else memory only. */
|
|
48
|
-
storage?: PairStorage | null;
|
|
49
|
-
/** Storage key. Default 'bwalletx.connect.pairing.v1'. */
|
|
50
|
-
storageKey?: string;
|
|
51
|
-
/** Opens a socket. Default: the global WebSocket. Pass one to run in Node or to test. */
|
|
52
|
-
socket?: SocketFactory;
|
|
53
|
-
/** Per-call timeout in ms. Default 120000. */
|
|
54
|
-
callTimeoutMs?: number;
|
|
55
|
-
}
|
|
56
|
-
interface PairingOptions extends PairConnectionOptions {
|
|
57
|
-
/** Show this link as a QR code, and as text to copy (web.bwalletx.com takes it pasted). */
|
|
58
|
-
onLink: (link: string) => void;
|
|
59
|
-
/** Show this 4-digit code. The wallet shows the same one; the user checks they match. */
|
|
60
|
-
onCode: (code: string) => void;
|
|
61
|
-
signal?: AbortSignal;
|
|
62
|
-
/** Relay host. Default relay.bwallet.space. */
|
|
63
|
-
relay?: string;
|
|
64
|
-
/** This page's origin, as the relay will see it. Default location.origin. */
|
|
65
|
-
origin?: string;
|
|
66
|
-
}
|
|
67
|
-
/** A BRC-100 wallet whose every call goes, end-to-end encrypted, to the paired phone or web wallet. */
|
|
68
|
-
type PairedWallet = WalletInterface & {
|
|
69
|
-
/** Close the relay connection. The pairing stays stored; the next call reconnects. */
|
|
70
|
-
close(): void;
|
|
71
|
-
/** Tell the wallet to unpair, close, and delete the stored pairing. */
|
|
72
|
-
forget(): Promise<void>;
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* Pair with bWalletX on a phone (scan the QR) or web.bwalletx.com (paste the link).
|
|
76
|
-
* Resolves with a wallet once the user taps Connect. The pairing is stored (see `storage`) so
|
|
77
|
-
* `restorePairing()` can reconnect after a reload without a new QR.
|
|
78
|
-
*/
|
|
79
|
-
declare function pairBwalletX(opts: PairingOptions): Promise<PairedWallet>;
|
|
80
|
-
/**
|
|
81
|
-
* The wallet from a pairing stored by an earlier `pairBwalletX`, or null if there is none.
|
|
82
|
-
* It connects on the first call. The wallet must still have this site paired.
|
|
83
|
-
*/
|
|
84
|
-
declare function restorePairing(opts?: PairConnectionOptions): Promise<PairedWallet | null>;
|
|
85
|
-
/** Delete the stored pairing without telling the wallet. */
|
|
86
|
-
declare function clearPairing(opts?: Pick<PairConnectionOptions, 'storage' | 'storageKey'>): Promise<void>;
|
|
87
|
-
|
|
88
29
|
/** Security level 2, a protocol name used for nothing else. */
|
|
89
30
|
declare const LOGIN_PROTOCOL: WalletProtocol;
|
|
90
31
|
/** What your server's challenge route returns (createChallenge from '@bwalletx/connect/server'). */
|
|
@@ -146,4 +87,24 @@ declare function renderButton(el: HTMLElement | string, opts?: ButtonOptions): H
|
|
|
146
87
|
*/
|
|
147
88
|
declare function inOrder<T>(handle: (frame: T) => Promise<void> | void, onError?: (e: unknown) => void): (frame: T) => Promise<void>;
|
|
148
89
|
|
|
149
|
-
|
|
90
|
+
/** An SVG QR code for `text` (error correction M). */
|
|
91
|
+
declare function qrSvg(text: string): string;
|
|
92
|
+
interface PairingModalOptions {
|
|
93
|
+
title?: string;
|
|
94
|
+
/** Called when the user closes the modal (the pairing is then aborted). */
|
|
95
|
+
onCancel?: () => void;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* PairingOptions that show a QR modal. Pass to signInWithBwalletX({ pairing: pairingModal() }) or
|
|
99
|
+
* connectBwalletX. The modal opens when the link is ready and shows the match code. Call `close()`
|
|
100
|
+
* once pairing settles (useBwalletX does this for you); Cancel aborts the pairing.
|
|
101
|
+
*/
|
|
102
|
+
declare function pairingModal(o?: PairingModalOptions): PairingOptions & {
|
|
103
|
+
close(): void;
|
|
104
|
+
};
|
|
105
|
+
/** Show the picker; resolves with the chosen option, or null if closed. */
|
|
106
|
+
declare function pickWallet(options: WalletOption[], o?: {
|
|
107
|
+
title?: string;
|
|
108
|
+
}): Promise<WalletOption | null>;
|
|
109
|
+
|
|
110
|
+
export { BWALLETX_RDNS, type ButtonOptions, type Challenge, type FoundBy, type FoundWallet, LOGIN_PROTOCOL, LOGO_URL, type PairingModalOptions, PairingOptions, RDNS_EXTENSION, RDNS_MOBILE, type SignInMethod, type SignInOptions, type SignInResult, WalletOption, connectBwalletX, discoverBwalletX, findBwalletX, inOrder, pairingModal, pickWallet, qrSvg, renderButton, signInWithBwalletX };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BRC29_PROTOCOL,
|
|
3
|
+
PaymentError,
|
|
4
|
+
amountInSats,
|
|
5
|
+
brc100Option,
|
|
6
|
+
buyToken,
|
|
7
|
+
discoverWallets,
|
|
8
|
+
handcashAdapter,
|
|
9
|
+
isIdentityKeyHex,
|
|
10
|
+
isPaymail,
|
|
11
|
+
pairingModal,
|
|
12
|
+
pairingOption,
|
|
13
|
+
pay,
|
|
14
|
+
pickWallet,
|
|
15
|
+
qrSvg,
|
|
16
|
+
resolvePaymailP2P,
|
|
17
|
+
tip
|
|
18
|
+
} from "./chunk-FUQ46RJV.js";
|
|
1
19
|
import {
|
|
2
20
|
BWALLETX_RDNS,
|
|
3
21
|
GET_URL,
|
|
@@ -65,27 +83,43 @@ function renderButton(el, opts = {}) {
|
|
|
65
83
|
return b;
|
|
66
84
|
}
|
|
67
85
|
export {
|
|
86
|
+
BRC29_PROTOCOL,
|
|
68
87
|
BWALLETX_RDNS,
|
|
69
88
|
GET_URL,
|
|
70
89
|
LOGIN_PROTOCOL,
|
|
71
90
|
LOGO_URL,
|
|
91
|
+
PaymentError,
|
|
72
92
|
RDNS_EXTENSION,
|
|
73
93
|
RDNS_MOBILE,
|
|
74
94
|
SIGNIN_CSS,
|
|
75
95
|
SIGNIN_TAG,
|
|
76
96
|
WEB_WALLET_URL,
|
|
97
|
+
amountInSats,
|
|
98
|
+
brc100Option,
|
|
77
99
|
buildAuthorizeUrl,
|
|
100
|
+
buyToken,
|
|
78
101
|
clearPairing,
|
|
79
102
|
connectBwalletX,
|
|
80
103
|
defineBwalletxSignin,
|
|
81
104
|
discoverBwalletX,
|
|
105
|
+
discoverWallets,
|
|
82
106
|
findBwalletX,
|
|
107
|
+
handcashAdapter,
|
|
83
108
|
inOrder,
|
|
109
|
+
isIdentityKeyHex,
|
|
110
|
+
isPaymail,
|
|
84
111
|
markSvg,
|
|
85
112
|
pairBwalletX,
|
|
113
|
+
pairingModal,
|
|
114
|
+
pairingOption,
|
|
115
|
+
pay,
|
|
116
|
+
pickWallet,
|
|
117
|
+
qrSvg,
|
|
86
118
|
renderButton,
|
|
119
|
+
resolvePaymailP2P,
|
|
87
120
|
restorePairing,
|
|
88
121
|
signInWithBwalletX,
|
|
89
|
-
signinText
|
|
122
|
+
signinText,
|
|
123
|
+
tip
|
|
90
124
|
};
|
|
91
125
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/button.ts"],"sourcesContent":["const CSS = `\n.bwx-signin{display:inline-flex;align-items:center;gap:12px;min-height:48px;padding:10px 22px 10px 10px;border:0;border-radius:12px;cursor:pointer;background:linear-gradient(180deg,#fcd34d,#f59e0b);color:#000;text-align:left;font:700 16px/1.2 system-ui,-apple-system,\"Segoe UI\",sans-serif;box-shadow:0 8px 24px rgba(245,158,11,.2)}\n.bwx-signin:hover{background:linear-gradient(180deg,#fde68a,#fbbf24)}\n.bwx-signin:focus-visible{outline:2px solid #ffd24d;outline-offset:3px}\n.bwx-signin:disabled{opacity:.6;cursor:wait}\n.bwx-signin .bwx-mark{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;border-radius:50%;background:#000;flex:none}\n.bwx-signin small{display:block;font-size:11px;font-weight:500;color:rgba(0,0,0,.6)}`;\n\nexport const LOGO_URL = 'https://bwalletx.com/logo.svg';\n\nexport interface ButtonOptions {\n /** Second line under the label. Default \"also works with bWallet\". false hides it. */\n subtitle?: string | false;\n onClick?: (button: HTMLButtonElement) => void;\n}\n\n/** Put the gold \"Sign in with bWalletX\" button into `el` (replacing its contents). */\nexport function renderButton(el: HTMLElement | string, opts: ButtonOptions = {}): HTMLButtonElement {\n const host = typeof el === 'string' ? document.querySelector<HTMLElement>(el) : el;\n if (!host) throw new Error(`renderButton: no element ${String(el)}`);\n if (!document.getElementById('bwx-signin-css')) {\n const style = document.createElement('style');\n style.id = 'bwx-signin-css';\n style.textContent = CSS;\n document.head.appendChild(style);\n }\n const b = document.createElement('button');\n b.type = 'button';\n b.className = 'bwx-signin';\n const mark = document.createElement('span');\n mark.className = 'bwx-mark';\n const img = document.createElement('img');\n img.src = LOGO_URL;\n img.alt = '';\n img.width = 15;\n img.height = 20;\n mark.appendChild(img);\n const label = document.createElement('span');\n label.className = 'bwx-label';\n label.textContent = 'Sign in with bWalletX';\n const sub = opts.subtitle === undefined ? 'also works with bWallet' : opts.subtitle;\n if (sub) {\n const small = document.createElement('small');\n small.textContent = sub;\n label.appendChild(small);\n }\n b.append(mark, label);\n if (opts.onClick) b.addEventListener('click', () => opts.onClick!(b));\n host.replaceChildren(b);\n return b;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/button.ts"],"sourcesContent":["const CSS = `\n.bwx-signin{display:inline-flex;align-items:center;gap:12px;min-height:48px;padding:10px 22px 10px 10px;border:0;border-radius:12px;cursor:pointer;background:linear-gradient(180deg,#fcd34d,#f59e0b);color:#000;text-align:left;font:700 16px/1.2 system-ui,-apple-system,\"Segoe UI\",sans-serif;box-shadow:0 8px 24px rgba(245,158,11,.2)}\n.bwx-signin:hover{background:linear-gradient(180deg,#fde68a,#fbbf24)}\n.bwx-signin:focus-visible{outline:2px solid #ffd24d;outline-offset:3px}\n.bwx-signin:disabled{opacity:.6;cursor:wait}\n.bwx-signin .bwx-mark{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;border-radius:50%;background:#000;flex:none}\n.bwx-signin small{display:block;font-size:11px;font-weight:500;color:rgba(0,0,0,.6)}`;\n\nexport const LOGO_URL = 'https://bwalletx.com/logo.svg';\n\nexport interface ButtonOptions {\n /** Second line under the label. Default \"also works with bWallet\". false hides it. */\n subtitle?: string | false;\n onClick?: (button: HTMLButtonElement) => void;\n}\n\n/** Put the gold \"Sign in with bWalletX\" button into `el` (replacing its contents). */\nexport function renderButton(el: HTMLElement | string, opts: ButtonOptions = {}): HTMLButtonElement {\n const host = typeof el === 'string' ? document.querySelector<HTMLElement>(el) : el;\n if (!host) throw new Error(`renderButton: no element ${String(el)}`);\n if (!document.getElementById('bwx-signin-css')) {\n const style = document.createElement('style');\n style.id = 'bwx-signin-css';\n style.textContent = CSS;\n document.head.appendChild(style);\n }\n const b = document.createElement('button');\n b.type = 'button';\n b.className = 'bwx-signin';\n const mark = document.createElement('span');\n mark.className = 'bwx-mark';\n const img = document.createElement('img');\n img.src = LOGO_URL;\n img.alt = '';\n img.width = 15;\n img.height = 20;\n mark.appendChild(img);\n const label = document.createElement('span');\n label.className = 'bwx-label';\n label.textContent = 'Sign in with bWalletX';\n const sub = opts.subtitle === undefined ? 'also works with bWallet' : opts.subtitle;\n if (sub) {\n const small = document.createElement('small');\n small.textContent = sub;\n label.appendChild(small);\n }\n b.append(mark, label);\n if (opts.onClick) b.addEventListener('click', () => opts.onClick!(b));\n host.replaceChildren(b);\n return b;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAM,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQL,IAAM,WAAW;AASjB,SAAS,aAAa,IAA0B,OAAsB,CAAC,GAAsB;AAClG,QAAM,OAAO,OAAO,OAAO,WAAW,SAAS,cAA2B,EAAE,IAAI;AAChF,MAAI,CAAC,KAAM,OAAM,IAAI,MAAM,4BAA4B,OAAO,EAAE,CAAC,EAAE;AACnE,MAAI,CAAC,SAAS,eAAe,gBAAgB,GAAG;AAC9C,UAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,UAAM,KAAK;AACX,UAAM,cAAc;AACpB,aAAS,KAAK,YAAY,KAAK;AAAA,EACjC;AACA,QAAM,IAAI,SAAS,cAAc,QAAQ;AACzC,IAAE,OAAO;AACT,IAAE,YAAY;AACd,QAAM,OAAO,SAAS,cAAc,MAAM;AAC1C,OAAK,YAAY;AACjB,QAAM,MAAM,SAAS,cAAc,KAAK;AACxC,MAAI,MAAM;AACV,MAAI,MAAM;AACV,MAAI,QAAQ;AACZ,MAAI,SAAS;AACb,OAAK,YAAY,GAAG;AACpB,QAAM,QAAQ,SAAS,cAAc,MAAM;AAC3C,QAAM,YAAY;AAClB,QAAM,cAAc;AACpB,QAAM,MAAM,KAAK,aAAa,SAAY,4BAA4B,KAAK;AAC3E,MAAI,KAAK;AACP,UAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,UAAM,cAAc;AACpB,UAAM,YAAY,KAAK;AAAA,EACzB;AACA,IAAE,OAAO,MAAM,KAAK;AACpB,MAAI,KAAK,QAAS,GAAE,iBAAiB,SAAS,MAAM,KAAK,QAAS,CAAC,CAAC;AACpE,OAAK,gBAAgB,CAAC;AACtB,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* bApp manifest: /.well-known/bapp.json. One file declares the app's five scoped slots, its drawer
|
|
3
|
+
* (Home + sections) and its like-to-fund config. The web bar draws from it; inside bWalletX the
|
|
4
|
+
* wallet's native dock reads the same file. Every path is same-origin: no URLs, no schemes.
|
|
5
|
+
*/
|
|
6
|
+
declare const SLOT_IDS: readonly ["wallet", "exchange", "b", "feed", "chat"];
|
|
7
|
+
type SlotId = (typeof SLOT_IDS)[number];
|
|
8
|
+
interface BappSlot {
|
|
9
|
+
/** Same-origin path, e.g. "/feed". Required when enabled, except for "b" (the agent). */
|
|
10
|
+
path?: string;
|
|
11
|
+
/** Optional rename ("Market"); the icon and position never change. */
|
|
12
|
+
label?: string;
|
|
13
|
+
/** false = shown greyed out and not clickable. Slots are never hidden. */
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
}
|
|
16
|
+
interface BappDrawerItem {
|
|
17
|
+
label: string;
|
|
18
|
+
path: string;
|
|
19
|
+
/** Optional same-origin icon path. */
|
|
20
|
+
icon?: string;
|
|
21
|
+
}
|
|
22
|
+
interface BappLikeConfig {
|
|
23
|
+
/** Which fields of a feed item hold the id, token (BSV-21 id / $TICKER), payee, title and media. */
|
|
24
|
+
fields: {
|
|
25
|
+
id: string;
|
|
26
|
+
token: string;
|
|
27
|
+
payee?: string;
|
|
28
|
+
title?: string;
|
|
29
|
+
media?: string;
|
|
30
|
+
};
|
|
31
|
+
/** Price of one Like in US cents. Default 1 (one PNEE). */
|
|
32
|
+
amountCents: number;
|
|
33
|
+
/** Pay in PNEE (the wallet's USD-cent token) when held, else BSV. Default "PNEE". */
|
|
34
|
+
currency: 'PNEE' | 'BSV';
|
|
35
|
+
/** Daily cap in US cents. Default 100 ($1), never more. */
|
|
36
|
+
dailyCapCents: number;
|
|
37
|
+
}
|
|
38
|
+
interface BappTheme {
|
|
39
|
+
/** Active/accent colour, #RRGGBB. Default #FFD24D. */
|
|
40
|
+
accent?: string;
|
|
41
|
+
}
|
|
42
|
+
interface BappManifest {
|
|
43
|
+
version: 1;
|
|
44
|
+
name: string;
|
|
45
|
+
/** Same-origin path to a square icon. */
|
|
46
|
+
icon: string;
|
|
47
|
+
/** The app's Home (first drawer item). Default "/". */
|
|
48
|
+
home: string;
|
|
49
|
+
theme?: BappTheme;
|
|
50
|
+
slots: Record<SlotId, BappSlot>;
|
|
51
|
+
drawer: BappDrawerItem[];
|
|
52
|
+
like?: BappLikeConfig;
|
|
53
|
+
}
|
|
54
|
+
type ValidationResult = {
|
|
55
|
+
ok: true;
|
|
56
|
+
manifest: BappManifest;
|
|
57
|
+
errors: [];
|
|
58
|
+
} | {
|
|
59
|
+
ok: false;
|
|
60
|
+
errors: string[];
|
|
61
|
+
manifest?: undefined;
|
|
62
|
+
};
|
|
63
|
+
declare const WELL_KNOWN_PATH = "/.well-known/bapp.json";
|
|
64
|
+
declare const LIKE_DEFAULT_CENTS = 1;
|
|
65
|
+
declare const LIKE_MAX_DAILY_CENTS = 100;
|
|
66
|
+
/**
|
|
67
|
+
* A same-origin path: starts with one "/", no "//" (protocol-relative), no backslashes, no control
|
|
68
|
+
* characters, no scheme. Query and hash are allowed.
|
|
69
|
+
*/
|
|
70
|
+
declare function isSameOriginPath(p: unknown): p is string;
|
|
71
|
+
/** Validate and normalise a parsed bapp.json. Never throws. */
|
|
72
|
+
declare function validateManifest(input: unknown): ValidationResult;
|
|
73
|
+
/** Same as validateManifest but throws with every error listed. */
|
|
74
|
+
declare function parseManifest(input: unknown): BappManifest;
|
|
75
|
+
/** Fetch and validate /.well-known/bapp.json (same origin). */
|
|
76
|
+
declare function loadManifest(path?: string, fetchImpl?: typeof fetch): Promise<BappManifest>;
|
|
77
|
+
/** The path a slot points at, or null when disabled / no path. */
|
|
78
|
+
declare function slotPath(m: BappManifest, slot: SlotId): string | null;
|
|
79
|
+
declare const isSlotId: (v: unknown) => v is SlotId;
|
|
80
|
+
|
|
81
|
+
export { type BappManifest as B, LIKE_DEFAULT_CENTS as L, type SlotId as S, type ValidationResult as V, WELL_KNOWN_PATH as W, type BappDrawerItem as a, type BappLikeConfig as b, type BappSlot as c, type BappTheme as d, LIKE_MAX_DAILY_CENTS as e, SLOT_IDS as f, isSlotId as g, isSameOriginPath as i, loadManifest as l, parseManifest as p, slotPath as s, validateManifest as v };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* bApp manifest: /.well-known/bapp.json. One file declares the app's five scoped slots, its drawer
|
|
3
|
+
* (Home + sections) and its like-to-fund config. The web bar draws from it; inside bWalletX the
|
|
4
|
+
* wallet's native dock reads the same file. Every path is same-origin: no URLs, no schemes.
|
|
5
|
+
*/
|
|
6
|
+
declare const SLOT_IDS: readonly ["wallet", "exchange", "b", "feed", "chat"];
|
|
7
|
+
type SlotId = (typeof SLOT_IDS)[number];
|
|
8
|
+
interface BappSlot {
|
|
9
|
+
/** Same-origin path, e.g. "/feed". Required when enabled, except for "b" (the agent). */
|
|
10
|
+
path?: string;
|
|
11
|
+
/** Optional rename ("Market"); the icon and position never change. */
|
|
12
|
+
label?: string;
|
|
13
|
+
/** false = shown greyed out and not clickable. Slots are never hidden. */
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
}
|
|
16
|
+
interface BappDrawerItem {
|
|
17
|
+
label: string;
|
|
18
|
+
path: string;
|
|
19
|
+
/** Optional same-origin icon path. */
|
|
20
|
+
icon?: string;
|
|
21
|
+
}
|
|
22
|
+
interface BappLikeConfig {
|
|
23
|
+
/** Which fields of a feed item hold the id, token (BSV-21 id / $TICKER), payee, title and media. */
|
|
24
|
+
fields: {
|
|
25
|
+
id: string;
|
|
26
|
+
token: string;
|
|
27
|
+
payee?: string;
|
|
28
|
+
title?: string;
|
|
29
|
+
media?: string;
|
|
30
|
+
};
|
|
31
|
+
/** Price of one Like in US cents. Default 1 (one PNEE). */
|
|
32
|
+
amountCents: number;
|
|
33
|
+
/** Pay in PNEE (the wallet's USD-cent token) when held, else BSV. Default "PNEE". */
|
|
34
|
+
currency: 'PNEE' | 'BSV';
|
|
35
|
+
/** Daily cap in US cents. Default 100 ($1), never more. */
|
|
36
|
+
dailyCapCents: number;
|
|
37
|
+
}
|
|
38
|
+
interface BappTheme {
|
|
39
|
+
/** Active/accent colour, #RRGGBB. Default #FFD24D. */
|
|
40
|
+
accent?: string;
|
|
41
|
+
}
|
|
42
|
+
interface BappManifest {
|
|
43
|
+
version: 1;
|
|
44
|
+
name: string;
|
|
45
|
+
/** Same-origin path to a square icon. */
|
|
46
|
+
icon: string;
|
|
47
|
+
/** The app's Home (first drawer item). Default "/". */
|
|
48
|
+
home: string;
|
|
49
|
+
theme?: BappTheme;
|
|
50
|
+
slots: Record<SlotId, BappSlot>;
|
|
51
|
+
drawer: BappDrawerItem[];
|
|
52
|
+
like?: BappLikeConfig;
|
|
53
|
+
}
|
|
54
|
+
type ValidationResult = {
|
|
55
|
+
ok: true;
|
|
56
|
+
manifest: BappManifest;
|
|
57
|
+
errors: [];
|
|
58
|
+
} | {
|
|
59
|
+
ok: false;
|
|
60
|
+
errors: string[];
|
|
61
|
+
manifest?: undefined;
|
|
62
|
+
};
|
|
63
|
+
declare const WELL_KNOWN_PATH = "/.well-known/bapp.json";
|
|
64
|
+
declare const LIKE_DEFAULT_CENTS = 1;
|
|
65
|
+
declare const LIKE_MAX_DAILY_CENTS = 100;
|
|
66
|
+
/**
|
|
67
|
+
* A same-origin path: starts with one "/", no "//" (protocol-relative), no backslashes, no control
|
|
68
|
+
* characters, no scheme. Query and hash are allowed.
|
|
69
|
+
*/
|
|
70
|
+
declare function isSameOriginPath(p: unknown): p is string;
|
|
71
|
+
/** Validate and normalise a parsed bapp.json. Never throws. */
|
|
72
|
+
declare function validateManifest(input: unknown): ValidationResult;
|
|
73
|
+
/** Same as validateManifest but throws with every error listed. */
|
|
74
|
+
declare function parseManifest(input: unknown): BappManifest;
|
|
75
|
+
/** Fetch and validate /.well-known/bapp.json (same origin). */
|
|
76
|
+
declare function loadManifest(path?: string, fetchImpl?: typeof fetch): Promise<BappManifest>;
|
|
77
|
+
/** The path a slot points at, or null when disabled / no path. */
|
|
78
|
+
declare function slotPath(m: BappManifest, slot: SlotId): string | null;
|
|
79
|
+
declare const isSlotId: (v: unknown) => v is SlotId;
|
|
80
|
+
|
|
81
|
+
export { type BappManifest as B, LIKE_DEFAULT_CENTS as L, type SlotId as S, type ValidationResult as V, WELL_KNOWN_PATH as W, type BappDrawerItem as a, type BappLikeConfig as b, type BappSlot as c, type BappTheme as d, LIKE_MAX_DAILY_CENTS as e, SLOT_IDS as f, isSlotId as g, isSameOriginPath as i, loadManifest as l, parseManifest as p, slotPath as s, validateManifest as v };
|