@bwalletx/connect 0.3.0 → 0.5.0
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/CHANGELOG.md +34 -0
- package/README.md +145 -4
- package/assets/protocol/401.jpg +0 -0
- package/assets/protocol/401.mp4 +0 -0
- package/assets/protocol/402.jpg +0 -0
- package/assets/protocol/402.mp4 +0 -0
- package/assets/protocol/403.jpg +0 -0
- package/assets/protocol/403.mp4 +0 -0
- package/dist/access-Z6xQwKVF.d.cts +118 -0
- package/dist/access-Z6xQwKVF.d.ts +118 -0
- package/dist/bwalletx-connect.global.js +41 -3
- package/dist/bwalletx-connect.global.js.map +1 -1
- package/dist/{chunk-NNMUSWPG.js → chunk-CVLXFNAG.js} +123 -1
- package/dist/chunk-CVLXFNAG.js.map +1 -0
- package/dist/chunk-GF6GUDZL.js +404 -0
- package/dist/chunk-GF6GUDZL.js.map +1 -0
- package/dist/chunk-MWD4BCO5.js +182 -0
- package/dist/chunk-MWD4BCO5.js.map +1 -0
- package/dist/chunk-QRXFL66W.js +652 -0
- package/dist/chunk-QRXFL66W.js.map +1 -0
- package/dist/element.cjs +209 -0
- package/dist/element.cjs.map +1 -1
- package/dist/element.js +2 -1
- package/dist/element.js.map +1 -1
- package/dist/index.cjs +706 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +66 -62
- package/dist/index.d.ts +66 -62
- package/dist/index.js +63 -3
- package/dist/index.js.map +1 -1
- package/dist/next.cjs +783 -0
- package/dist/next.cjs.map +1 -0
- package/dist/next.d.cts +98 -0
- package/dist/next.d.ts +98 -0
- package/dist/next.js +198 -0
- package/dist/next.js.map +1 -0
- package/dist/react.cjs +795 -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 +177 -4
- package/dist/react.js.map +1 -1
- package/dist/server.cjs +742 -10
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +314 -2
- package/dist/server.d.ts +314 -2
- package/dist/server.js +82 -107
- package/dist/server.js.map +1 -1
- package/dist/wallets-VOKIKBbO.d.cts +250 -0
- package/dist/wallets-VOKIKBbO.d.ts +250 -0
- package/package.json +32 -6
- package/dist/chunk-NNMUSWPG.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { WalletInterface, WalletProtocol } from '@bsv/sdk';
|
|
2
|
+
import { f as PairingOptions, W as WalletOption } from './wallets-VOKIKBbO.cjs';
|
|
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.cjs';
|
|
2
4
|
export { AuthorizeParams, GET_URL, SIGNIN_CSS, SIGNIN_TAG, SigninBrand, SigninLabel, SigninSize, SigninTheme, WEB_WALLET_URL, buildAuthorizeUrl, defineBwalletxSignin, markSvg, signinText } from './element.cjs';
|
|
5
|
+
import { b as AccessResponse, H as HoldingProof, A as AccessError } from './access-Z6xQwKVF.cjs';
|
|
6
|
+
export { c as ACCESS_ERROR_STATUS, d as ACCESS_PROTOCOL, e as ACCESS_VERSION, f as AccessChallenge, g as AccessErrorBody, h as AccessErrorCode, i as AccessKind, a as AccessRequirement, P as PROTOCOL_MEDIA, T as TokenRequirement, j as accessErrorMessage, k as canonicalJson, p as protocolMediaUrl } from './access-Z6xQwKVF.cjs';
|
|
3
7
|
|
|
4
8
|
/** Ids bWalletX announces in BRC-100 wallet discovery. */
|
|
5
9
|
declare const RDNS_EXTENSION = "com.bwalletx.extension";
|
|
@@ -24,67 +28,6 @@ declare function discoverBwalletX(ms?: number): Promise<FoundWallet | null>;
|
|
|
24
28
|
*/
|
|
25
29
|
declare function findBwalletX(ms?: number): Promise<WalletInterface | null>;
|
|
26
30
|
|
|
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
31
|
/** Security level 2, a protocol name used for nothing else. */
|
|
89
32
|
declare const LOGIN_PROTOCOL: WalletProtocol;
|
|
90
33
|
/** What your server's challenge route returns (createChallenge from '@bwalletx/connect/server'). */
|
|
@@ -146,4 +89,65 @@ declare function renderButton(el: HTMLElement | string, opts?: ButtonOptions): H
|
|
|
146
89
|
*/
|
|
147
90
|
declare function inOrder<T>(handle: (frame: T) => Promise<void> | void, onError?: (e: unknown) => void): (frame: T) => Promise<void>;
|
|
148
91
|
|
|
149
|
-
|
|
92
|
+
/** An SVG QR code for `text` (error correction M). */
|
|
93
|
+
declare function qrSvg(text: string): string;
|
|
94
|
+
interface PairingModalOptions {
|
|
95
|
+
title?: string;
|
|
96
|
+
/** Called when the user closes the modal (the pairing is then aborted). */
|
|
97
|
+
onCancel?: () => void;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* PairingOptions that show a QR modal. Pass to signInWithBwalletX({ pairing: pairingModal() }) or
|
|
101
|
+
* connectBwalletX. The modal opens when the link is ready and shows the match code. Call `close()`
|
|
102
|
+
* once pairing settles (useBwalletX does this for you); Cancel aborts the pairing.
|
|
103
|
+
*/
|
|
104
|
+
declare function pairingModal(o?: PairingModalOptions): PairingOptions & {
|
|
105
|
+
close(): void;
|
|
106
|
+
};
|
|
107
|
+
/** Show the picker; resolves with the chosen option, or null if closed. */
|
|
108
|
+
declare function pickWallet(options: WalletOption[], o?: {
|
|
109
|
+
title?: string;
|
|
110
|
+
}): Promise<WalletOption | null>;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Browser side of the access protocol: ask the wallet to sign the site's challenge and prove the
|
|
114
|
+
* keys holding the required token, using standard BRC-100 calls only (so any BRC-100 wallet works).
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
/** The challenge route's answer (createAccessChallenge). */
|
|
118
|
+
interface AccessChallengeLike {
|
|
119
|
+
challenge: string;
|
|
120
|
+
}
|
|
121
|
+
interface RequestAccessOptions {
|
|
122
|
+
/** Ask your server for a challenge. Gets the wallet's identity key. */
|
|
123
|
+
challenge: (identityKey: string) => Promise<AccessChallengeLike>;
|
|
124
|
+
/** Post the signed response to your server. Throw AccessError (or return an error body) to refuse. */
|
|
125
|
+
verify?: (response: AccessResponse) => Promise<unknown>;
|
|
126
|
+
wallet?: WalletInterface;
|
|
127
|
+
pairing?: SignInOptions['pairing'];
|
|
128
|
+
discoverMs?: number;
|
|
129
|
+
/** Basket holding BSV-21 outputs. Default 'bsv21' (bWalletX, 1Sat wallets). */
|
|
130
|
+
tokenBasket?: string;
|
|
131
|
+
}
|
|
132
|
+
interface RequestAccessResult {
|
|
133
|
+
response: AccessResponse;
|
|
134
|
+
/** Whatever `verify` returned. */
|
|
135
|
+
verified?: unknown;
|
|
136
|
+
wallet: WalletInterface;
|
|
137
|
+
}
|
|
138
|
+
/** Map a wallet / fetch failure to a protocol error. */
|
|
139
|
+
declare function toAccessError(e: unknown): AccessError;
|
|
140
|
+
/** Read an AccessErrorBody from a server answer and throw it as AccessError. */
|
|
141
|
+
declare function throwIfAccessError(body: unknown): void;
|
|
142
|
+
/**
|
|
143
|
+
* Sign the challenge with every key that locks an output of `tokenId` in the wallet's token basket.
|
|
144
|
+
* Outputs whose derivation can't be reproduced are skipped (the server counts only what is proven).
|
|
145
|
+
*/
|
|
146
|
+
declare function proveHoldings(wallet: WalletInterface, challenge: string, tokenId: string, basket?: string): Promise<HoldingProof[]>;
|
|
147
|
+
/**
|
|
148
|
+
* Run the whole flow: find the wallet, get a challenge, sign it, prove holdings, post to verify.
|
|
149
|
+
* Throws AccessError with a protocol code on every failure.
|
|
150
|
+
*/
|
|
151
|
+
declare function requestAccess(o: RequestAccessOptions): Promise<RequestAccessResult>;
|
|
152
|
+
|
|
153
|
+
export { type AccessChallengeLike, AccessError, AccessResponse, BWALLETX_RDNS, type ButtonOptions, type Challenge, type FoundBy, type FoundWallet, HoldingProof, LOGIN_PROTOCOL, LOGO_URL, type PairingModalOptions, PairingOptions, RDNS_EXTENSION, RDNS_MOBILE, type RequestAccessOptions, type RequestAccessResult, type SignInMethod, type SignInOptions, type SignInResult, WalletOption, connectBwalletX, discoverBwalletX, findBwalletX, inOrder, pairingModal, pickWallet, proveHoldings, qrSvg, renderButton, requestAccess, signInWithBwalletX, throwIfAccessError, toAccessError };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
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';
|
|
5
|
+
import { b as AccessResponse, H as HoldingProof, A as AccessError } from './access-Z6xQwKVF.js';
|
|
6
|
+
export { c as ACCESS_ERROR_STATUS, d as ACCESS_PROTOCOL, e as ACCESS_VERSION, f as AccessChallenge, g as AccessErrorBody, h as AccessErrorCode, i as AccessKind, a as AccessRequirement, P as PROTOCOL_MEDIA, T as TokenRequirement, j as accessErrorMessage, k as canonicalJson, p as protocolMediaUrl } from './access-Z6xQwKVF.js';
|
|
3
7
|
|
|
4
8
|
/** Ids bWalletX announces in BRC-100 wallet discovery. */
|
|
5
9
|
declare const RDNS_EXTENSION = "com.bwalletx.extension";
|
|
@@ -24,67 +28,6 @@ declare function discoverBwalletX(ms?: number): Promise<FoundWallet | null>;
|
|
|
24
28
|
*/
|
|
25
29
|
declare function findBwalletX(ms?: number): Promise<WalletInterface | null>;
|
|
26
30
|
|
|
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
31
|
/** Security level 2, a protocol name used for nothing else. */
|
|
89
32
|
declare const LOGIN_PROTOCOL: WalletProtocol;
|
|
90
33
|
/** What your server's challenge route returns (createChallenge from '@bwalletx/connect/server'). */
|
|
@@ -146,4 +89,65 @@ declare function renderButton(el: HTMLElement | string, opts?: ButtonOptions): H
|
|
|
146
89
|
*/
|
|
147
90
|
declare function inOrder<T>(handle: (frame: T) => Promise<void> | void, onError?: (e: unknown) => void): (frame: T) => Promise<void>;
|
|
148
91
|
|
|
149
|
-
|
|
92
|
+
/** An SVG QR code for `text` (error correction M). */
|
|
93
|
+
declare function qrSvg(text: string): string;
|
|
94
|
+
interface PairingModalOptions {
|
|
95
|
+
title?: string;
|
|
96
|
+
/** Called when the user closes the modal (the pairing is then aborted). */
|
|
97
|
+
onCancel?: () => void;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* PairingOptions that show a QR modal. Pass to signInWithBwalletX({ pairing: pairingModal() }) or
|
|
101
|
+
* connectBwalletX. The modal opens when the link is ready and shows the match code. Call `close()`
|
|
102
|
+
* once pairing settles (useBwalletX does this for you); Cancel aborts the pairing.
|
|
103
|
+
*/
|
|
104
|
+
declare function pairingModal(o?: PairingModalOptions): PairingOptions & {
|
|
105
|
+
close(): void;
|
|
106
|
+
};
|
|
107
|
+
/** Show the picker; resolves with the chosen option, or null if closed. */
|
|
108
|
+
declare function pickWallet(options: WalletOption[], o?: {
|
|
109
|
+
title?: string;
|
|
110
|
+
}): Promise<WalletOption | null>;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Browser side of the access protocol: ask the wallet to sign the site's challenge and prove the
|
|
114
|
+
* keys holding the required token, using standard BRC-100 calls only (so any BRC-100 wallet works).
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
/** The challenge route's answer (createAccessChallenge). */
|
|
118
|
+
interface AccessChallengeLike {
|
|
119
|
+
challenge: string;
|
|
120
|
+
}
|
|
121
|
+
interface RequestAccessOptions {
|
|
122
|
+
/** Ask your server for a challenge. Gets the wallet's identity key. */
|
|
123
|
+
challenge: (identityKey: string) => Promise<AccessChallengeLike>;
|
|
124
|
+
/** Post the signed response to your server. Throw AccessError (or return an error body) to refuse. */
|
|
125
|
+
verify?: (response: AccessResponse) => Promise<unknown>;
|
|
126
|
+
wallet?: WalletInterface;
|
|
127
|
+
pairing?: SignInOptions['pairing'];
|
|
128
|
+
discoverMs?: number;
|
|
129
|
+
/** Basket holding BSV-21 outputs. Default 'bsv21' (bWalletX, 1Sat wallets). */
|
|
130
|
+
tokenBasket?: string;
|
|
131
|
+
}
|
|
132
|
+
interface RequestAccessResult {
|
|
133
|
+
response: AccessResponse;
|
|
134
|
+
/** Whatever `verify` returned. */
|
|
135
|
+
verified?: unknown;
|
|
136
|
+
wallet: WalletInterface;
|
|
137
|
+
}
|
|
138
|
+
/** Map a wallet / fetch failure to a protocol error. */
|
|
139
|
+
declare function toAccessError(e: unknown): AccessError;
|
|
140
|
+
/** Read an AccessErrorBody from a server answer and throw it as AccessError. */
|
|
141
|
+
declare function throwIfAccessError(body: unknown): void;
|
|
142
|
+
/**
|
|
143
|
+
* Sign the challenge with every key that locks an output of `tokenId` in the wallet's token basket.
|
|
144
|
+
* Outputs whose derivation can't be reproduced are skipped (the server counts only what is proven).
|
|
145
|
+
*/
|
|
146
|
+
declare function proveHoldings(wallet: WalletInterface, challenge: string, tokenId: string, basket?: string): Promise<HoldingProof[]>;
|
|
147
|
+
/**
|
|
148
|
+
* Run the whole flow: find the wallet, get a challenge, sign it, prove holdings, post to verify.
|
|
149
|
+
* Throws AccessError with a protocol code on every failure.
|
|
150
|
+
*/
|
|
151
|
+
declare function requestAccess(o: RequestAccessOptions): Promise<RequestAccessResult>;
|
|
152
|
+
|
|
153
|
+
export { type AccessChallengeLike, AccessError, AccessResponse, BWALLETX_RDNS, type ButtonOptions, type Challenge, type FoundBy, type FoundWallet, HoldingProof, LOGIN_PROTOCOL, LOGO_URL, type PairingModalOptions, PairingOptions, RDNS_EXTENSION, RDNS_MOBILE, type RequestAccessOptions, type RequestAccessResult, type SignInMethod, type SignInOptions, type SignInResult, WalletOption, connectBwalletX, discoverBwalletX, findBwalletX, inOrder, pairingModal, pickWallet, proveHoldings, qrSvg, renderButton, requestAccess, signInWithBwalletX, throwIfAccessError, toAccessError };
|
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-GF6GUDZL.js";
|
|
1
19
|
import {
|
|
2
20
|
BWALLETX_RDNS,
|
|
3
21
|
GET_URL,
|
|
@@ -16,10 +34,24 @@ import {
|
|
|
16
34
|
inOrder,
|
|
17
35
|
markSvg,
|
|
18
36
|
pairBwalletX,
|
|
37
|
+
proveHoldings,
|
|
38
|
+
requestAccess,
|
|
19
39
|
restorePairing,
|
|
20
40
|
signInWithBwalletX,
|
|
21
|
-
signinText
|
|
22
|
-
|
|
41
|
+
signinText,
|
|
42
|
+
throwIfAccessError,
|
|
43
|
+
toAccessError
|
|
44
|
+
} from "./chunk-CVLXFNAG.js";
|
|
45
|
+
import {
|
|
46
|
+
ACCESS_ERROR_STATUS,
|
|
47
|
+
ACCESS_PROTOCOL,
|
|
48
|
+
ACCESS_VERSION,
|
|
49
|
+
AccessError,
|
|
50
|
+
PROTOCOL_MEDIA,
|
|
51
|
+
accessErrorMessage,
|
|
52
|
+
canonicalJson,
|
|
53
|
+
protocolMediaUrl
|
|
54
|
+
} from "./chunk-MWD4BCO5.js";
|
|
23
55
|
|
|
24
56
|
// src/button.ts
|
|
25
57
|
var CSS = `
|
|
@@ -65,27 +97,55 @@ function renderButton(el, opts = {}) {
|
|
|
65
97
|
return b;
|
|
66
98
|
}
|
|
67
99
|
export {
|
|
100
|
+
ACCESS_ERROR_STATUS,
|
|
101
|
+
ACCESS_PROTOCOL,
|
|
102
|
+
ACCESS_VERSION,
|
|
103
|
+
AccessError,
|
|
104
|
+
BRC29_PROTOCOL,
|
|
68
105
|
BWALLETX_RDNS,
|
|
69
106
|
GET_URL,
|
|
70
107
|
LOGIN_PROTOCOL,
|
|
71
108
|
LOGO_URL,
|
|
109
|
+
PROTOCOL_MEDIA,
|
|
110
|
+
PaymentError,
|
|
72
111
|
RDNS_EXTENSION,
|
|
73
112
|
RDNS_MOBILE,
|
|
74
113
|
SIGNIN_CSS,
|
|
75
114
|
SIGNIN_TAG,
|
|
76
115
|
WEB_WALLET_URL,
|
|
116
|
+
accessErrorMessage,
|
|
117
|
+
amountInSats,
|
|
118
|
+
brc100Option,
|
|
77
119
|
buildAuthorizeUrl,
|
|
120
|
+
buyToken,
|
|
121
|
+
canonicalJson,
|
|
78
122
|
clearPairing,
|
|
79
123
|
connectBwalletX,
|
|
80
124
|
defineBwalletxSignin,
|
|
81
125
|
discoverBwalletX,
|
|
126
|
+
discoverWallets,
|
|
82
127
|
findBwalletX,
|
|
128
|
+
handcashAdapter,
|
|
83
129
|
inOrder,
|
|
130
|
+
isIdentityKeyHex,
|
|
131
|
+
isPaymail,
|
|
84
132
|
markSvg,
|
|
85
133
|
pairBwalletX,
|
|
134
|
+
pairingModal,
|
|
135
|
+
pairingOption,
|
|
136
|
+
pay,
|
|
137
|
+
pickWallet,
|
|
138
|
+
protocolMediaUrl,
|
|
139
|
+
proveHoldings,
|
|
140
|
+
qrSvg,
|
|
86
141
|
renderButton,
|
|
142
|
+
requestAccess,
|
|
143
|
+
resolvePaymailP2P,
|
|
87
144
|
restorePairing,
|
|
88
145
|
signInWithBwalletX,
|
|
89
|
-
signinText
|
|
146
|
+
signinText,
|
|
147
|
+
throwIfAccessError,
|
|
148
|
+
tip,
|
|
149
|
+
toAccessError
|
|
90
150
|
};
|
|
91
151
|
//# 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":[]}
|