wallet-connect-button-react 1.1.7 → 1.1.9
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/dist/WalletConnectButton.d.ts +3 -2
- package/dist/index.esm.js +48 -32
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +48 -32
- package/dist/index.js.map +1 -1
- package/dist/nl-wallet-web.js +16 -16
- package/package.json +1 -1
|
@@ -8,7 +8,8 @@ export interface WalletConnectButtonProps {
|
|
|
8
8
|
clientId: string;
|
|
9
9
|
onSuccess: (attributes: AttributeData | undefined) => void;
|
|
10
10
|
apiKey?: string;
|
|
11
|
-
|
|
11
|
+
useLocalWcServer?: boolean;
|
|
12
|
+
business?: boolean;
|
|
12
13
|
lang?: string;
|
|
13
14
|
helpBaseUrl?: string;
|
|
14
15
|
issuance?: boolean;
|
|
@@ -30,5 +31,5 @@ declare global {
|
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
|
-
declare function WalletConnectButton({ label, clientId, onSuccess, apiKey,
|
|
34
|
+
declare function WalletConnectButton({ label, clientId, onSuccess, apiKey, useLocalWcServer, business, lang, helpBaseUrl, issuance }: WalletConnectButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
34
35
|
export default WalletConnectButton;
|
package/dist/index.esm.js
CHANGED
|
@@ -108,22 +108,39 @@ function useSearchParams() {
|
|
|
108
108
|
|
|
109
109
|
// Global cache to prevent duplicate requests
|
|
110
110
|
var credentialsCache = new Map();
|
|
111
|
-
function
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
function getDefaultHost(useLocalWcServer, business, issuance) {
|
|
112
|
+
// If useLocalWcServer is set, use local server
|
|
113
|
+
if (useLocalWcServer) {
|
|
114
|
+
if (business) {
|
|
115
|
+
return issuance ? 'http://localhost:4007' : 'http://bw.localhost:3021';
|
|
116
|
+
}
|
|
117
|
+
return issuance ? 'http://localhost:3007' : 'http://localhost:3021';
|
|
118
|
+
}
|
|
119
|
+
// Otherwise use remote servers
|
|
120
|
+
if (business) {
|
|
121
|
+
return issuance ? 'https://bw.issuance.wallet-connect.eu' : 'https://bw.wallet-connect.eu';
|
|
122
|
+
}
|
|
123
|
+
return issuance ? 'https://issuance.wallet-connect.eu' : 'https://wallet-connect.eu';
|
|
124
|
+
}
|
|
125
|
+
function constructURI(clientId, session_type, walletConnectHost, business) {
|
|
126
|
+
var request_uri = "".concat(walletConnectHost, "/disclosure/").concat(clientId, "/request_uri?session_type=").concat(session_type);
|
|
114
127
|
var request_uri_method = "post";
|
|
115
128
|
var client_id_uri = "".concat(clientId, ".example.com");
|
|
116
|
-
|
|
129
|
+
var deepLinkScheme = business
|
|
130
|
+
? 'businesswalletdebuginteraction://wallet.kvk.rijksoverheid.nl'
|
|
131
|
+
: 'walletdebuginteraction://wallet.edi.rijksoverheid.nl';
|
|
132
|
+
return "".concat(deepLinkScheme, "/disclosure_based_issuance?request_uri=").concat(encodeURIComponent(request_uri), "&request_uri_method=").concat(request_uri_method, "&client_id=").concat(client_id_uri);
|
|
117
133
|
}
|
|
118
134
|
function WalletConnectButton(_a) {
|
|
119
135
|
var _this = this;
|
|
120
|
-
var label = _a.label, clientId = _a.clientId, onSuccess = _a.onSuccess, apiKey = _a.apiKey,
|
|
121
|
-
var
|
|
122
|
-
var
|
|
123
|
-
var
|
|
136
|
+
var label = _a.label, clientId = _a.clientId, onSuccess = _a.onSuccess, apiKey = _a.apiKey, _b = _a.useLocalWcServer, useLocalWcServer = _b === void 0 ? false : _b, _c = _a.business, business = _c === void 0 ? false : _c, lang = _a.lang, helpBaseUrl = _a.helpBaseUrl, _d = _a.issuance, issuance = _d === void 0 ? false : _d;
|
|
137
|
+
var _e = useSearchParams(), searchParams = _e[0], setSearchParams = _e[1], removeSearchParam = _e[2];
|
|
138
|
+
var _f = useState(false), loading = _f[0], setLoading = _f[1];
|
|
139
|
+
var _g = useState(null), error = _g[0], setError = _g[1];
|
|
124
140
|
var buttonRef = useRef(null);
|
|
125
|
-
var
|
|
126
|
-
var
|
|
141
|
+
var walletConnectHost = getDefaultHost(useLocalWcServer, business, issuance);
|
|
142
|
+
var sameDeviceUl = constructURI(clientId, "same_device", walletConnectHost, business);
|
|
143
|
+
var crossDeviceUl = constructURI(clientId, "cross_device", walletConnectHost, business);
|
|
127
144
|
useEffect(function () {
|
|
128
145
|
// Dynamically import the web component
|
|
129
146
|
var loadWebComponent = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -171,7 +188,7 @@ function WalletConnectButton(_a) {
|
|
|
171
188
|
case 0:
|
|
172
189
|
if (!apiKey || !clientId)
|
|
173
190
|
return [2 /*return*/, []];
|
|
174
|
-
cacheKey = "".concat(clientId, "-").concat(walletConnectHost
|
|
191
|
+
cacheKey = "".concat(clientId, "-").concat(walletConnectHost);
|
|
175
192
|
cached = credentialsCache.get(cacheKey);
|
|
176
193
|
if (cached === null || cached === void 0 ? void 0 : cached.data) {
|
|
177
194
|
return [2 /*return*/, cached.data];
|
|
@@ -181,14 +198,13 @@ function WalletConnectButton(_a) {
|
|
|
181
198
|
case 1: return [2 /*return*/, _a.sent()];
|
|
182
199
|
case 2:
|
|
183
200
|
fetchPromise = (function () { return __awaiter(_this, void 0, void 0, function () {
|
|
184
|
-
var
|
|
201
|
+
var url, headers, response, credentials, error_2;
|
|
185
202
|
var _a, _b;
|
|
186
203
|
return __generator(this, function (_c) {
|
|
187
204
|
switch (_c.label) {
|
|
188
205
|
case 0:
|
|
189
206
|
_c.trys.push([0, 2, , 3]);
|
|
190
|
-
|
|
191
|
-
url = "".concat(baseUrl, "/api/client/").concat(clientId, "/requested-credentials");
|
|
207
|
+
url = "".concat(walletConnectHost, "/api/client/").concat(clientId, "/requested-credentials");
|
|
192
208
|
headers = { 'Authorization': "Bearer ".concat(apiKey) };
|
|
193
209
|
return [4 /*yield*/, axios.get(url, { headers: headers })];
|
|
194
210
|
case 1:
|
|
@@ -307,7 +323,7 @@ function WalletConnectButton(_a) {
|
|
|
307
323
|
if (!session_token)
|
|
308
324
|
return;
|
|
309
325
|
setLoading(true);
|
|
310
|
-
var baseUrl = apiKey ?
|
|
326
|
+
var baseUrl = apiKey ? walletConnectHost : "";
|
|
311
327
|
var url = baseUrl + "/api/disclosed-attributes?session_token=".concat(session_token, "&client_id=").concat(clientId);
|
|
312
328
|
if (nonce)
|
|
313
329
|
url = "".concat(url, "&nonce=").concat(nonce);
|
|
@@ -341,7 +357,7 @@ function WalletConnectButton(_a) {
|
|
|
341
357
|
if (error) {
|
|
342
358
|
return (jsx("div", { className: "attributes", children: jsxs("div", { className: "verification-card", children: [jsx("h2", { children: "Error" }), jsxs("p", { children: ["An error occurred while verifying your attributes: ", error] })] }) }));
|
|
343
359
|
}
|
|
344
|
-
return (jsx("nl-wallet-button", { ref: buttonRef, text: label, usecase: issuance ? "" : clientId, "start-url": "".concat(walletConnectHost
|
|
360
|
+
return (jsx("nl-wallet-button", { ref: buttonRef, text: label, usecase: issuance ? "" : clientId, "start-url": "".concat(walletConnectHost, "/api/create-session?lang=en&return_url=").concat(encodeURIComponent(window.location.href)), lang: lang || "nl", "same-device-ul": sameDeviceUl, "cross-device-ul": crossDeviceUl, "help-base-url": helpBaseUrl, onClick: handleButtonClick }));
|
|
345
361
|
}
|
|
346
362
|
|
|
347
363
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
@@ -5633,8 +5649,8 @@ const {
|
|
|
5633
5649
|
return (s) => t[s];
|
|
5634
5650
|
}, pu = {
|
|
5635
5651
|
en: {
|
|
5636
|
-
wallet_button_text: "Login with
|
|
5637
|
-
modal_header: "
|
|
5652
|
+
wallet_button_text: "Login with Wallet",
|
|
5653
|
+
modal_header: "Wallet",
|
|
5638
5654
|
need_help: "Need help?",
|
|
5639
5655
|
stop: "Stop",
|
|
5640
5656
|
retry: "Try again",
|
|
@@ -5643,7 +5659,7 @@ const {
|
|
|
5643
5659
|
no: "No",
|
|
5644
5660
|
confirm_stop_title: "Are you sure you want to stop?",
|
|
5645
5661
|
confirm_stop_body: "If you stop now, no data will be shared.",
|
|
5646
|
-
device_choice_title: "Which device is your
|
|
5662
|
+
device_choice_title: "Which device is your Wallet is installed?",
|
|
5647
5663
|
device_choice_same_device: "On this device",
|
|
5648
5664
|
device_choice_cross_device: "On another device",
|
|
5649
5665
|
expired_title: "Sorry, time is over",
|
|
@@ -5654,19 +5670,19 @@ const {
|
|
|
5654
5670
|
cancelled_body: "Because you have stopped, no data has been shared.",
|
|
5655
5671
|
network_title: "Sorry, no internet connection",
|
|
5656
5672
|
network_body: "Your internet connection seems to be down or too slow. Check your connection and try again.",
|
|
5657
|
-
help_title: "No
|
|
5658
|
-
help_to_website: "To
|
|
5659
|
-
in_progress_title: "Follow the steps in your
|
|
5673
|
+
help_title: "No Wallet App yet? Or need help?",
|
|
5674
|
+
help_to_website: "To Wallet website",
|
|
5675
|
+
in_progress_title: "Follow the steps in your Wallet app",
|
|
5660
5676
|
loading_title: "Please wait",
|
|
5661
5677
|
loading_body: "Your request is being retrieved",
|
|
5662
|
-
qr_code_title: "Scan the QR code with your
|
|
5678
|
+
qr_code_title: "Scan the QR code with your Wallet app",
|
|
5663
5679
|
qr_code_label: "QR code",
|
|
5664
5680
|
success_title: "Success!",
|
|
5665
5681
|
success_body: "Close this page and continue in the new opened tab."
|
|
5666
5682
|
},
|
|
5667
5683
|
nl: {
|
|
5668
|
-
wallet_button_text: "Inloggen met
|
|
5669
|
-
modal_header: "
|
|
5684
|
+
wallet_button_text: "Inloggen met Wallet",
|
|
5685
|
+
modal_header: "Wallet",
|
|
5670
5686
|
need_help: "Hulp nodig?",
|
|
5671
5687
|
stop: "Stoppen",
|
|
5672
5688
|
retry: "Probeer opnieuw",
|
|
@@ -5675,7 +5691,7 @@ const {
|
|
|
5675
5691
|
no: "Nee",
|
|
5676
5692
|
confirm_stop_title: "Weet je zeker dat je wilt stoppen?",
|
|
5677
5693
|
confirm_stop_body: "Als je stopt worden er geen gegevens gedeeld.",
|
|
5678
|
-
device_choice_title: "Op welk apparaat staat je
|
|
5694
|
+
device_choice_title: "Op welk apparaat staat je Wallet app?",
|
|
5679
5695
|
device_choice_same_device: "Op dit apparaat",
|
|
5680
5696
|
device_choice_cross_device: "Op een ander apparaat",
|
|
5681
5697
|
expired_title: "Sorry, de tijd is voorbij",
|
|
@@ -5686,12 +5702,12 @@ const {
|
|
|
5686
5702
|
cancelled_body: "Omdat je bent gestopt zijn er geen gegevens gedeeld.",
|
|
5687
5703
|
network_title: "Sorry, geen internet",
|
|
5688
5704
|
network_body: "Je verbinding met het internet lijkt niet te werken of is te traag. Controleer je verbinding en probeer het opnieuw.",
|
|
5689
|
-
help_title: "Nog geen
|
|
5690
|
-
help_to_website: "Naar
|
|
5691
|
-
in_progress_title: "Volg de stappen in de
|
|
5705
|
+
help_title: "Nog geen Wallet app? Of hulp nodig?",
|
|
5706
|
+
help_to_website: "Naar Wallet website",
|
|
5707
|
+
in_progress_title: "Volg de stappen in de Wallet app",
|
|
5692
5708
|
loading_title: "Even geduld",
|
|
5693
5709
|
loading_body: "De gegevens worden opgehaald",
|
|
5694
|
-
qr_code_title: "Scan de QR-code met je
|
|
5710
|
+
qr_code_title: "Scan de QR-code met je Wallet app",
|
|
5695
5711
|
qr_code_label: "QR code",
|
|
5696
5712
|
success_title: "Gelukt!",
|
|
5697
5713
|
success_body: "Sluit deze pagina en ga verder in het nieuw geopende tabblad."
|
|
@@ -7250,7 +7266,7 @@ const tf = /* @__PURE__ */ ai(qu, [["render", ef]]), sf = {
|
|
|
7250
7266
|
x("aside", {
|
|
7251
7267
|
"aria-modal": "true",
|
|
7252
7268
|
role: "dialog",
|
|
7253
|
-
"aria-label": "
|
|
7269
|
+
"aria-label": "Wallet",
|
|
7254
7270
|
class: ut(["modal", [i.value.kind, i.value.kind === "success" && i.value.session.sessionType]]),
|
|
7255
7271
|
"data-testid": "wallet_modal"
|
|
7256
7272
|
}, [
|
|
@@ -7305,7 +7321,7 @@ const tf = /* @__PURE__ */ ai(qu, [["render", ef]]), sf = {
|
|
|
7305
7321
|
x("aside", {
|
|
7306
7322
|
"aria-modal": "true",
|
|
7307
7323
|
role: "dialog",
|
|
7308
|
-
"aria-label": "
|
|
7324
|
+
"aria-label": "Wallet",
|
|
7309
7325
|
class: ut(["modal", [o.value.kind, o.value.kind === "success" && o.value.session.sessionType]]),
|
|
7310
7326
|
"data-testid": "wallet_modal"
|
|
7311
7327
|
}, [
|