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/index.js CHANGED
@@ -112,22 +112,39 @@ function useSearchParams() {
112
112
 
113
113
  // Global cache to prevent duplicate requests
114
114
  var credentialsCache = new Map();
115
- function constructURI(clientId, session_type, walletConnectHost) {
116
- var baseHost = walletConnectHost || "https://issuance.wallet-connect.eu";
117
- var request_uri = "".concat(baseHost, "/disclosure/").concat(clientId, "/request_uri?session_type=").concat(session_type);
115
+ function getDefaultHost(useLocalWcServer, business, issuance) {
116
+ // If useLocalWcServer is set, use local server
117
+ if (useLocalWcServer) {
118
+ if (business) {
119
+ return issuance ? 'http://localhost:4007' : 'http://bw.localhost:3021';
120
+ }
121
+ return issuance ? 'http://localhost:3007' : 'http://localhost:3021';
122
+ }
123
+ // Otherwise use remote servers
124
+ if (business) {
125
+ return issuance ? 'https://bw.issuance.wallet-connect.eu' : 'https://bw.wallet-connect.eu';
126
+ }
127
+ return issuance ? 'https://issuance.wallet-connect.eu' : 'https://wallet-connect.eu';
128
+ }
129
+ function constructURI(clientId, session_type, walletConnectHost, business) {
130
+ var request_uri = "".concat(walletConnectHost, "/disclosure/").concat(clientId, "/request_uri?session_type=").concat(session_type);
118
131
  var request_uri_method = "post";
119
132
  var client_id_uri = "".concat(clientId, ".example.com");
120
- return "walletdebuginteraction://wallet.edi.rijksoverheid.nl/disclosure_based_issuance?request_uri=".concat(encodeURIComponent(request_uri), "&request_uri_method=").concat(request_uri_method, "&client_id=").concat(client_id_uri);
133
+ var deepLinkScheme = business
134
+ ? 'businesswalletdebuginteraction://wallet.kvk.rijksoverheid.nl'
135
+ : 'walletdebuginteraction://wallet.edi.rijksoverheid.nl';
136
+ 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);
121
137
  }
122
138
  function WalletConnectButton(_a) {
123
139
  var _this = this;
124
- var label = _a.label, clientId = _a.clientId, onSuccess = _a.onSuccess, apiKey = _a.apiKey, walletConnectHost = _a.walletConnectHost, lang = _a.lang, helpBaseUrl = _a.helpBaseUrl, issuance = _a.issuance;
125
- var _b = useSearchParams(), searchParams = _b[0], setSearchParams = _b[1], removeSearchParam = _b[2];
126
- var _c = react.useState(false), loading = _c[0], setLoading = _c[1];
127
- var _d = react.useState(null), error = _d[0], setError = _d[1];
140
+ 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;
141
+ var _e = useSearchParams(), searchParams = _e[0], setSearchParams = _e[1], removeSearchParam = _e[2];
142
+ var _f = react.useState(false), loading = _f[0], setLoading = _f[1];
143
+ var _g = react.useState(null), error = _g[0], setError = _g[1];
128
144
  var buttonRef = react.useRef(null);
129
- var sameDeviceUl = constructURI(clientId, "same_device", walletConnectHost);
130
- var crossDeviceUl = constructURI(clientId, "cross_device", walletConnectHost);
145
+ var walletConnectHost = getDefaultHost(useLocalWcServer, business, issuance);
146
+ var sameDeviceUl = constructURI(clientId, "same_device", walletConnectHost, business);
147
+ var crossDeviceUl = constructURI(clientId, "cross_device", walletConnectHost, business);
131
148
  react.useEffect(function () {
132
149
  // Dynamically import the web component
133
150
  var loadWebComponent = function () { return __awaiter(_this, void 0, void 0, function () {
@@ -175,7 +192,7 @@ function WalletConnectButton(_a) {
175
192
  case 0:
176
193
  if (!apiKey || !clientId)
177
194
  return [2 /*return*/, []];
178
- cacheKey = "".concat(clientId, "-").concat(walletConnectHost || "default");
195
+ cacheKey = "".concat(clientId, "-").concat(walletConnectHost);
179
196
  cached = credentialsCache.get(cacheKey);
180
197
  if (cached === null || cached === void 0 ? void 0 : cached.data) {
181
198
  return [2 /*return*/, cached.data];
@@ -185,14 +202,13 @@ function WalletConnectButton(_a) {
185
202
  case 1: return [2 /*return*/, _a.sent()];
186
203
  case 2:
187
204
  fetchPromise = (function () { return __awaiter(_this, void 0, void 0, function () {
188
- var baseUrl, url, headers, response, credentials, error_2;
205
+ var url, headers, response, credentials, error_2;
189
206
  var _a, _b;
190
207
  return __generator(this, function (_c) {
191
208
  switch (_c.label) {
192
209
  case 0:
193
210
  _c.trys.push([0, 2, , 3]);
194
- baseUrl = walletConnectHost || "https://wallet-connect.eu";
195
- url = "".concat(baseUrl, "/api/client/").concat(clientId, "/requested-credentials");
211
+ url = "".concat(walletConnectHost, "/api/client/").concat(clientId, "/requested-credentials");
196
212
  headers = { 'Authorization': "Bearer ".concat(apiKey) };
197
213
  return [4 /*yield*/, axios.get(url, { headers: headers })];
198
214
  case 1:
@@ -311,7 +327,7 @@ function WalletConnectButton(_a) {
311
327
  if (!session_token)
312
328
  return;
313
329
  setLoading(true);
314
- var baseUrl = apiKey ? (walletConnectHost || "https://wallet-connect.eu") : "";
330
+ var baseUrl = apiKey ? walletConnectHost : "";
315
331
  var url = baseUrl + "/api/disclosed-attributes?session_token=".concat(session_token, "&client_id=").concat(clientId);
316
332
  if (nonce)
317
333
  url = "".concat(url, "&nonce=").concat(nonce);
@@ -345,7 +361,7 @@ function WalletConnectButton(_a) {
345
361
  if (error) {
346
362
  return (jsxRuntime.jsx("div", { className: "attributes", children: jsxRuntime.jsxs("div", { className: "verification-card", children: [jsxRuntime.jsx("h2", { children: "Error" }), jsxRuntime.jsxs("p", { children: ["An error occurred while verifying your attributes: ", error] })] }) }));
347
363
  }
348
- return (jsxRuntime.jsx("nl-wallet-button", { ref: buttonRef, text: label, usecase: issuance ? "" : clientId, "start-url": "".concat(walletConnectHost || "https://wallet-connect.eu", "/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 }));
364
+ return (jsxRuntime.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 }));
349
365
  }
350
366
 
351
367
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
@@ -5637,8 +5653,8 @@ const {
5637
5653
  return (s) => t[s];
5638
5654
  }, pu = {
5639
5655
  en: {
5640
- wallet_button_text: "Login with NL Wallet",
5641
- modal_header: "NL Wallet",
5656
+ wallet_button_text: "Login with Wallet",
5657
+ modal_header: "Wallet",
5642
5658
  need_help: "Need help?",
5643
5659
  stop: "Stop",
5644
5660
  retry: "Try again",
@@ -5647,7 +5663,7 @@ const {
5647
5663
  no: "No",
5648
5664
  confirm_stop_title: "Are you sure you want to stop?",
5649
5665
  confirm_stop_body: "If you stop now, no data will be shared.",
5650
- device_choice_title: "Which device is your NL Wallet is installed?",
5666
+ device_choice_title: "Which device is your Wallet is installed?",
5651
5667
  device_choice_same_device: "On this device",
5652
5668
  device_choice_cross_device: "On another device",
5653
5669
  expired_title: "Sorry, time is over",
@@ -5658,19 +5674,19 @@ const {
5658
5674
  cancelled_body: "Because you have stopped, no data has been shared.",
5659
5675
  network_title: "Sorry, no internet connection",
5660
5676
  network_body: "Your internet connection seems to be down or too slow. Check your connection and try again.",
5661
- help_title: "No NL Wallet App yet? Or need help?",
5662
- help_to_website: "To NL Wallet website",
5663
- in_progress_title: "Follow the steps in your NL Wallet app",
5677
+ help_title: "No Wallet App yet? Or need help?",
5678
+ help_to_website: "To Wallet website",
5679
+ in_progress_title: "Follow the steps in your Wallet app",
5664
5680
  loading_title: "Please wait",
5665
5681
  loading_body: "Your request is being retrieved",
5666
- qr_code_title: "Scan the QR code with your NL Wallet app",
5682
+ qr_code_title: "Scan the QR code with your Wallet app",
5667
5683
  qr_code_label: "QR code",
5668
5684
  success_title: "Success!",
5669
5685
  success_body: "Close this page and continue in the new opened tab."
5670
5686
  },
5671
5687
  nl: {
5672
- wallet_button_text: "Inloggen met NL Wallet",
5673
- modal_header: "NL Wallet",
5688
+ wallet_button_text: "Inloggen met Wallet",
5689
+ modal_header: "Wallet",
5674
5690
  need_help: "Hulp nodig?",
5675
5691
  stop: "Stoppen",
5676
5692
  retry: "Probeer opnieuw",
@@ -5679,7 +5695,7 @@ const {
5679
5695
  no: "Nee",
5680
5696
  confirm_stop_title: "Weet je zeker dat je wilt stoppen?",
5681
5697
  confirm_stop_body: "Als je stopt worden er geen gegevens gedeeld.",
5682
- device_choice_title: "Op welk apparaat staat je NL Wallet app?",
5698
+ device_choice_title: "Op welk apparaat staat je Wallet app?",
5683
5699
  device_choice_same_device: "Op dit apparaat",
5684
5700
  device_choice_cross_device: "Op een ander apparaat",
5685
5701
  expired_title: "Sorry, de tijd is voorbij",
@@ -5690,12 +5706,12 @@ const {
5690
5706
  cancelled_body: "Omdat je bent gestopt zijn er geen gegevens gedeeld.",
5691
5707
  network_title: "Sorry, geen internet",
5692
5708
  network_body: "Je verbinding met het internet lijkt niet te werken of is te traag. Controleer je verbinding en probeer het opnieuw.",
5693
- help_title: "Nog geen NL Wallet app? Of hulp nodig?",
5694
- help_to_website: "Naar NL Wallet website",
5695
- in_progress_title: "Volg de stappen in de NL Wallet app",
5709
+ help_title: "Nog geen Wallet app? Of hulp nodig?",
5710
+ help_to_website: "Naar Wallet website",
5711
+ in_progress_title: "Volg de stappen in de Wallet app",
5696
5712
  loading_title: "Even geduld",
5697
5713
  loading_body: "De gegevens worden opgehaald",
5698
- qr_code_title: "Scan de QR-code met je NL Wallet app",
5714
+ qr_code_title: "Scan de QR-code met je Wallet app",
5699
5715
  qr_code_label: "QR code",
5700
5716
  success_title: "Gelukt!",
5701
5717
  success_body: "Sluit deze pagina en ga verder in het nieuw geopende tabblad."
@@ -7254,7 +7270,7 @@ const tf = /* @__PURE__ */ ai(qu, [["render", ef]]), sf = {
7254
7270
  x("aside", {
7255
7271
  "aria-modal": "true",
7256
7272
  role: "dialog",
7257
- "aria-label": "NL Wallet",
7273
+ "aria-label": "Wallet",
7258
7274
  class: ut(["modal", [i.value.kind, i.value.kind === "success" && i.value.session.sessionType]]),
7259
7275
  "data-testid": "wallet_modal"
7260
7276
  }, [
@@ -7309,7 +7325,7 @@ const tf = /* @__PURE__ */ ai(qu, [["render", ef]]), sf = {
7309
7325
  x("aside", {
7310
7326
  "aria-modal": "true",
7311
7327
  role: "dialog",
7312
- "aria-label": "NL Wallet",
7328
+ "aria-label": "Wallet",
7313
7329
  class: ut(["modal", [o.value.kind, o.value.kind === "success" && o.value.session.sessionType]]),
7314
7330
  "data-testid": "wallet_modal"
7315
7331
  }, [