@bwalletx/connect 0.5.4 → 0.5.6
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 +28 -0
- package/README.md +76 -8
- package/dist/bwalletx-connect.global.js +92 -25
- package/dist/bwalletx-connect.global.js.map +1 -1
- package/dist/{wallets-CbzMtxrf.d.ts → choice-DCh-tgpT.d.cts} +112 -4
- package/dist/{wallets-CbzMtxrf.d.cts → choice-DCh-tgpT.d.ts} +112 -4
- package/dist/chunk-34DKBQNN.js +222 -0
- package/dist/chunk-34DKBQNN.js.map +1 -0
- package/dist/{chunk-QRXFL66W.js → chunk-A2WLGS25.js} +6 -4
- package/dist/chunk-A2WLGS25.js.map +1 -0
- package/dist/chunk-IFGOAROM.js +255 -0
- package/dist/chunk-IFGOAROM.js.map +1 -0
- package/dist/chunk-LS6AYEBO.js +1886 -0
- package/dist/chunk-LS6AYEBO.js.map +1 -0
- package/dist/element-D9Zl-x12.d.cts +46 -0
- package/dist/element-D9Zl-x12.d.ts +46 -0
- package/dist/element.cjs +1147 -61
- package/dist/element.cjs.map +1 -1
- package/dist/element.d.cts +23 -28
- package/dist/element.d.ts +23 -28
- package/dist/element.js +29 -2
- package/dist/element.js.map +1 -1
- package/dist/index.cjs +1469 -453
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +163 -14
- package/dist/index.d.ts +163 -14
- package/dist/index.js +100 -12
- package/dist/index.js.map +1 -1
- package/dist/next.cjs +5 -3
- package/dist/next.cjs.map +1 -1
- package/dist/next.js +1 -1
- package/dist/react.cjs +994 -183
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +75 -8
- package/dist/react.d.ts +75 -8
- package/dist/react.js +121 -40
- package/dist/react.js.map +1 -1
- package/dist/server.cjs +5 -3
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +8 -3
- package/dist/server.d.ts +8 -3
- package/dist/server.js +1 -1
- package/package.json +10 -9
- package/dist/chunk-EXRQJTXF.js +0 -910
- package/dist/chunk-EXRQJTXF.js.map +0 -1
- package/dist/chunk-QRXFL66W.js.map +0 -1
- package/dist/chunk-RIOHG5JH.js +0 -459
- package/dist/chunk-RIOHG5JH.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,53 +1,98 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BUTTON_TAG,
|
|
3
|
+
CONNECTED_KEY,
|
|
4
|
+
defineBwalletxButton,
|
|
5
|
+
dropLegacyConnectedKey,
|
|
6
|
+
getUrlFor,
|
|
7
|
+
handleLabel,
|
|
8
|
+
stateFor
|
|
9
|
+
} from "./chunk-34DKBQNN.js";
|
|
1
10
|
import {
|
|
2
11
|
BRC29_PROTOCOL,
|
|
3
12
|
PaymentError,
|
|
4
13
|
WALLET_THEME_META,
|
|
5
14
|
amountInSats,
|
|
6
|
-
brc100Option,
|
|
7
15
|
buyToken,
|
|
8
16
|
declareWalletTheme,
|
|
9
|
-
discoverWallets,
|
|
10
|
-
handcashAdapter,
|
|
11
17
|
isIdentityKeyHex,
|
|
12
18
|
isPaymail,
|
|
13
|
-
isTouchDevice,
|
|
14
|
-
pairingModal,
|
|
15
|
-
pairingOption,
|
|
16
19
|
pay,
|
|
17
|
-
pickWallet,
|
|
18
|
-
qrSvg,
|
|
19
20
|
resolvePaymailP2P,
|
|
21
|
+
runConnect,
|
|
20
22
|
tip
|
|
21
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-IFGOAROM.js";
|
|
22
24
|
import {
|
|
25
|
+
BAVATAR_URL,
|
|
23
26
|
BWALLETX_RDNS,
|
|
27
|
+
BWALLETX_TYPE,
|
|
24
28
|
DEFAULT_DISCOVER_MS,
|
|
29
|
+
DESKTOP_OPTION_ID,
|
|
25
30
|
GET_URL,
|
|
31
|
+
IDENTITY_HINT_KEY,
|
|
26
32
|
LOGIN_PROTOCOL,
|
|
33
|
+
MENU_CSS,
|
|
34
|
+
PAYMAIL_LOOKUP_URL,
|
|
35
|
+
PENDING_LABEL,
|
|
36
|
+
PENDING_LABEL_OTHER,
|
|
37
|
+
PENDING_NOTE,
|
|
27
38
|
RDNS_EXTENSION,
|
|
28
39
|
RDNS_MOBILE,
|
|
29
40
|
SIGNIN_CSS,
|
|
30
41
|
SIGNIN_TAG,
|
|
31
42
|
WEB_WALLET_URL,
|
|
43
|
+
accountLabel,
|
|
44
|
+
attemptFor,
|
|
45
|
+
autoChoice,
|
|
46
|
+
avatarUrlFor,
|
|
32
47
|
bindPrewarm,
|
|
48
|
+
brc100Option,
|
|
33
49
|
buildAuthorizeUrl,
|
|
50
|
+
challengeWantsIdentityKey,
|
|
51
|
+
chooseWallet,
|
|
52
|
+
chooserOrder,
|
|
34
53
|
clearPairing,
|
|
35
54
|
connectBwalletX,
|
|
55
|
+
cwiIsAnnounced,
|
|
56
|
+
decideWallet,
|
|
36
57
|
defineBwalletxSignin,
|
|
58
|
+
desktopOption,
|
|
37
59
|
discoverBwalletX,
|
|
60
|
+
discoverWallets,
|
|
38
61
|
findBwalletX,
|
|
62
|
+
handcashAdapter,
|
|
63
|
+
hasBwalletX,
|
|
39
64
|
inOrder,
|
|
65
|
+
isFramed,
|
|
66
|
+
isPresentBwalletX,
|
|
67
|
+
isTouchDevice,
|
|
68
|
+
isUserRejection,
|
|
69
|
+
lookupPaymail,
|
|
40
70
|
markSvg,
|
|
71
|
+
otherDetected,
|
|
72
|
+
outcomeOf,
|
|
41
73
|
pairBwalletX,
|
|
74
|
+
pairingModal,
|
|
75
|
+
pairingOption,
|
|
76
|
+
pickWallet,
|
|
42
77
|
prewarmBwalletX,
|
|
43
78
|
proveHoldings,
|
|
79
|
+
qrSvg,
|
|
80
|
+
rememberIdentity,
|
|
81
|
+
rememberedIdentity,
|
|
82
|
+
reportAttempt,
|
|
44
83
|
requestAccess,
|
|
45
84
|
restorePairing,
|
|
85
|
+
shortKey,
|
|
86
|
+
signInAndVerify,
|
|
87
|
+
signInErrorText,
|
|
46
88
|
signInWithBwalletX,
|
|
47
89
|
signinText,
|
|
90
|
+
substrateOf,
|
|
48
91
|
throwIfAccessError,
|
|
49
|
-
toAccessError
|
|
50
|
-
|
|
92
|
+
toAccessError,
|
|
93
|
+
waitIfLocked,
|
|
94
|
+
walletTypeOf
|
|
95
|
+
} from "./chunk-LS6AYEBO.js";
|
|
51
96
|
import {
|
|
52
97
|
ACCESS_ERROR_STATUS,
|
|
53
98
|
ACCESS_PROTOCOL,
|
|
@@ -107,12 +152,23 @@ export {
|
|
|
107
152
|
ACCESS_PROTOCOL,
|
|
108
153
|
ACCESS_VERSION,
|
|
109
154
|
AccessError,
|
|
155
|
+
BAVATAR_URL,
|
|
110
156
|
BRC29_PROTOCOL,
|
|
157
|
+
BUTTON_TAG,
|
|
111
158
|
BWALLETX_RDNS,
|
|
159
|
+
BWALLETX_TYPE,
|
|
160
|
+
CONNECTED_KEY,
|
|
112
161
|
DEFAULT_DISCOVER_MS,
|
|
162
|
+
DESKTOP_OPTION_ID,
|
|
113
163
|
GET_URL,
|
|
164
|
+
IDENTITY_HINT_KEY,
|
|
114
165
|
LOGIN_PROTOCOL,
|
|
115
166
|
LOGO_URL,
|
|
167
|
+
MENU_CSS,
|
|
168
|
+
PAYMAIL_LOOKUP_URL,
|
|
169
|
+
PENDING_LABEL,
|
|
170
|
+
PENDING_LABEL_OTHER,
|
|
171
|
+
PENDING_NOTE,
|
|
116
172
|
PROTOCOL_MEDIA,
|
|
117
173
|
PaymentError,
|
|
118
174
|
RDNS_EXTENSION,
|
|
@@ -122,25 +178,46 @@ export {
|
|
|
122
178
|
WALLET_THEME_META,
|
|
123
179
|
WEB_WALLET_URL,
|
|
124
180
|
accessErrorMessage,
|
|
181
|
+
accountLabel,
|
|
125
182
|
amountInSats,
|
|
183
|
+
attemptFor,
|
|
184
|
+
autoChoice,
|
|
185
|
+
avatarUrlFor,
|
|
126
186
|
bindPrewarm,
|
|
127
187
|
brc100Option,
|
|
128
188
|
buildAuthorizeUrl,
|
|
129
189
|
buyToken,
|
|
130
190
|
canonicalJson,
|
|
191
|
+
challengeWantsIdentityKey,
|
|
192
|
+
chooseWallet,
|
|
193
|
+
chooserOrder,
|
|
131
194
|
clearPairing,
|
|
132
195
|
connectBwalletX,
|
|
196
|
+
cwiIsAnnounced,
|
|
197
|
+
decideWallet,
|
|
133
198
|
declareWalletTheme,
|
|
199
|
+
defineBwalletxButton,
|
|
134
200
|
defineBwalletxSignin,
|
|
201
|
+
desktopOption,
|
|
135
202
|
discoverBwalletX,
|
|
136
203
|
discoverWallets,
|
|
204
|
+
dropLegacyConnectedKey,
|
|
137
205
|
findBwalletX,
|
|
206
|
+
getUrlFor,
|
|
138
207
|
handcashAdapter,
|
|
208
|
+
handleLabel,
|
|
209
|
+
hasBwalletX,
|
|
139
210
|
inOrder,
|
|
211
|
+
isFramed,
|
|
140
212
|
isIdentityKeyHex,
|
|
141
213
|
isPaymail,
|
|
214
|
+
isPresentBwalletX,
|
|
142
215
|
isTouchDevice,
|
|
216
|
+
isUserRejection,
|
|
217
|
+
lookupPaymail,
|
|
143
218
|
markSvg,
|
|
219
|
+
otherDetected,
|
|
220
|
+
outcomeOf,
|
|
144
221
|
pairBwalletX,
|
|
145
222
|
pairingModal,
|
|
146
223
|
pairingOption,
|
|
@@ -150,14 +227,25 @@ export {
|
|
|
150
227
|
protocolMediaUrl,
|
|
151
228
|
proveHoldings,
|
|
152
229
|
qrSvg,
|
|
230
|
+
rememberIdentity,
|
|
231
|
+
rememberedIdentity,
|
|
153
232
|
renderButton,
|
|
233
|
+
reportAttempt,
|
|
154
234
|
requestAccess,
|
|
155
235
|
resolvePaymailP2P,
|
|
156
236
|
restorePairing,
|
|
237
|
+
runConnect,
|
|
238
|
+
shortKey,
|
|
239
|
+
signInAndVerify,
|
|
240
|
+
signInErrorText,
|
|
157
241
|
signInWithBwalletX,
|
|
158
242
|
signinText,
|
|
243
|
+
stateFor,
|
|
244
|
+
substrateOf,
|
|
159
245
|
throwIfAccessError,
|
|
160
246
|
tip,
|
|
161
|
-
toAccessError
|
|
247
|
+
toAccessError,
|
|
248
|
+
waitIfLocked,
|
|
249
|
+
walletTypeOf
|
|
162
250
|
};
|
|
163
251
|
//# 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":[]}
|
package/dist/next.cjs
CHANGED
|
@@ -563,12 +563,14 @@ function randomNonce2() {
|
|
|
563
563
|
return btoa(s).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
564
564
|
}
|
|
565
565
|
async function createChallenge(opts) {
|
|
566
|
-
|
|
566
|
+
const given = opts.identityKey !== void 0 && opts.identityKey !== null && opts.identityKey !== "";
|
|
567
|
+
if (given && !isIdentityKey(opts.identityKey)) throw new Error("identityKey must be a compressed public key (66 hex chars)");
|
|
568
|
+
const boundKey = given ? opts.identityKey.toLowerCase() : "";
|
|
567
569
|
const origin = normalOrigin2(opts.origin);
|
|
568
570
|
const nonce = randomNonce2();
|
|
569
571
|
const expiresAt = Date.now() + CHALLENGE_LIFETIME_MS;
|
|
570
572
|
const message = loginMessage(origin, nonce, expiresAt);
|
|
571
|
-
await storeOrDefault(opts.store).put(nonce, { identityKey:
|
|
573
|
+
await storeOrDefault(opts.store).put(nonce, { identityKey: boundKey, origin, message, expiresAt });
|
|
572
574
|
return { nonce, message, protocolID: LOGIN_PROTOCOL, keyID: nonce, expiresAt };
|
|
573
575
|
}
|
|
574
576
|
async function verifySignIn(opts) {
|
|
@@ -584,7 +586,7 @@ async function verifySignIn(opts) {
|
|
|
584
586
|
if (c.origin !== origin) return null;
|
|
585
587
|
if (!isIdentityKey(opts.identityKey)) return null;
|
|
586
588
|
const identityKey = opts.identityKey.toLowerCase();
|
|
587
|
-
if (c.identityKey !== identityKey) return null;
|
|
589
|
+
if (c.identityKey && c.identityKey !== identityKey) return null;
|
|
588
590
|
const sig = opts.signature;
|
|
589
591
|
if (!Array.isArray(sig) || sig.length < 8 || sig.length > 80 || !sig.every((b) => Number.isInteger(b) && b >= 0 && b <= 255)) {
|
|
590
592
|
return null;
|