wallet-connect-button-react 1.1.5 → 1.1.7

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.
@@ -25,6 +25,7 @@ declare global {
25
25
  'same-device-ul'?: string;
26
26
  'cross-device-ul'?: string;
27
27
  'help-base-url'?: string;
28
+ onClick?: (event: Event) => void;
28
29
  };
29
30
  }
30
31
  }
package/dist/index.esm.js CHANGED
@@ -1,4 +1,5 @@
1
- import require$$0, { useState, useCallback, useEffect, useRef } from 'react';
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { useState, useCallback, useEffect, useRef } from 'react';
2
3
  import axios from 'axios';
3
4
 
4
5
  function _mergeNamespaces(n, m) {
@@ -76,427 +77,6 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
76
77
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
77
78
  };
78
79
 
79
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
80
-
81
- var jsxRuntime = {exports: {}};
82
-
83
- var reactJsxRuntime_production = {};
84
-
85
- /**
86
- * @license React
87
- * react-jsx-runtime.production.js
88
- *
89
- * Copyright (c) Meta Platforms, Inc. and affiliates.
90
- *
91
- * This source code is licensed under the MIT license found in the
92
- * LICENSE file in the root directory of this source tree.
93
- */
94
-
95
- var hasRequiredReactJsxRuntime_production;
96
-
97
- function requireReactJsxRuntime_production () {
98
- if (hasRequiredReactJsxRuntime_production) return reactJsxRuntime_production;
99
- hasRequiredReactJsxRuntime_production = 1;
100
- var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
101
- REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
102
- function jsxProd(type, config, maybeKey) {
103
- var key = null;
104
- void 0 !== maybeKey && (key = "" + maybeKey);
105
- void 0 !== config.key && (key = "" + config.key);
106
- if ("key" in config) {
107
- maybeKey = {};
108
- for (var propName in config)
109
- "key" !== propName && (maybeKey[propName] = config[propName]);
110
- } else maybeKey = config;
111
- config = maybeKey.ref;
112
- return {
113
- $$typeof: REACT_ELEMENT_TYPE,
114
- type: type,
115
- key: key,
116
- ref: void 0 !== config ? config : null,
117
- props: maybeKey
118
- };
119
- }
120
- reactJsxRuntime_production.Fragment = REACT_FRAGMENT_TYPE;
121
- reactJsxRuntime_production.jsx = jsxProd;
122
- reactJsxRuntime_production.jsxs = jsxProd;
123
- return reactJsxRuntime_production;
124
- }
125
-
126
- var reactJsxRuntime_development = {};
127
-
128
- /**
129
- * @license React
130
- * react-jsx-runtime.development.js
131
- *
132
- * Copyright (c) Meta Platforms, Inc. and affiliates.
133
- *
134
- * This source code is licensed under the MIT license found in the
135
- * LICENSE file in the root directory of this source tree.
136
- */
137
-
138
- var hasRequiredReactJsxRuntime_development;
139
-
140
- function requireReactJsxRuntime_development () {
141
- if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
142
- hasRequiredReactJsxRuntime_development = 1;
143
- "production" !== process.env.NODE_ENV &&
144
- (function () {
145
- function getComponentNameFromType(type) {
146
- if (null == type) return null;
147
- if ("function" === typeof type)
148
- return type.$$typeof === REACT_CLIENT_REFERENCE
149
- ? null
150
- : type.displayName || type.name || null;
151
- if ("string" === typeof type) return type;
152
- switch (type) {
153
- case REACT_FRAGMENT_TYPE:
154
- return "Fragment";
155
- case REACT_PROFILER_TYPE:
156
- return "Profiler";
157
- case REACT_STRICT_MODE_TYPE:
158
- return "StrictMode";
159
- case REACT_SUSPENSE_TYPE:
160
- return "Suspense";
161
- case REACT_SUSPENSE_LIST_TYPE:
162
- return "SuspenseList";
163
- case REACT_ACTIVITY_TYPE:
164
- return "Activity";
165
- }
166
- if ("object" === typeof type)
167
- switch (
168
- ("number" === typeof type.tag &&
169
- console.error(
170
- "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
171
- ),
172
- type.$$typeof)
173
- ) {
174
- case REACT_PORTAL_TYPE:
175
- return "Portal";
176
- case REACT_CONTEXT_TYPE:
177
- return (type.displayName || "Context") + ".Provider";
178
- case REACT_CONSUMER_TYPE:
179
- return (type._context.displayName || "Context") + ".Consumer";
180
- case REACT_FORWARD_REF_TYPE:
181
- var innerType = type.render;
182
- type = type.displayName;
183
- type ||
184
- ((type = innerType.displayName || innerType.name || ""),
185
- (type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef"));
186
- return type;
187
- case REACT_MEMO_TYPE:
188
- return (
189
- (innerType = type.displayName || null),
190
- null !== innerType
191
- ? innerType
192
- : getComponentNameFromType(type.type) || "Memo"
193
- );
194
- case REACT_LAZY_TYPE:
195
- innerType = type._payload;
196
- type = type._init;
197
- try {
198
- return getComponentNameFromType(type(innerType));
199
- } catch (x) {}
200
- }
201
- return null;
202
- }
203
- function testStringCoercion(value) {
204
- return "" + value;
205
- }
206
- function checkKeyStringCoercion(value) {
207
- try {
208
- testStringCoercion(value);
209
- var JSCompiler_inline_result = !1;
210
- } catch (e) {
211
- JSCompiler_inline_result = true;
212
- }
213
- if (JSCompiler_inline_result) {
214
- JSCompiler_inline_result = console;
215
- var JSCompiler_temp_const = JSCompiler_inline_result.error;
216
- var JSCompiler_inline_result$jscomp$0 =
217
- ("function" === typeof Symbol &&
218
- Symbol.toStringTag &&
219
- value[Symbol.toStringTag]) ||
220
- value.constructor.name ||
221
- "Object";
222
- JSCompiler_temp_const.call(
223
- JSCompiler_inline_result,
224
- "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
225
- JSCompiler_inline_result$jscomp$0
226
- );
227
- return testStringCoercion(value);
228
- }
229
- }
230
- function getTaskName(type) {
231
- if (type === REACT_FRAGMENT_TYPE) return "<>";
232
- if (
233
- "object" === typeof type &&
234
- null !== type &&
235
- type.$$typeof === REACT_LAZY_TYPE
236
- )
237
- return "<...>";
238
- try {
239
- var name = getComponentNameFromType(type);
240
- return name ? "<" + name + ">" : "<...>";
241
- } catch (x) {
242
- return "<...>";
243
- }
244
- }
245
- function getOwner() {
246
- var dispatcher = ReactSharedInternals.A;
247
- return null === dispatcher ? null : dispatcher.getOwner();
248
- }
249
- function UnknownOwner() {
250
- return Error("react-stack-top-frame");
251
- }
252
- function hasValidKey(config) {
253
- if (hasOwnProperty.call(config, "key")) {
254
- var getter = Object.getOwnPropertyDescriptor(config, "key").get;
255
- if (getter && getter.isReactWarning) return false;
256
- }
257
- return void 0 !== config.key;
258
- }
259
- function defineKeyPropWarningGetter(props, displayName) {
260
- function warnAboutAccessingKey() {
261
- specialPropKeyWarningShown ||
262
- ((specialPropKeyWarningShown = true),
263
- console.error(
264
- "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
265
- displayName
266
- ));
267
- }
268
- warnAboutAccessingKey.isReactWarning = true;
269
- Object.defineProperty(props, "key", {
270
- get: warnAboutAccessingKey,
271
- configurable: true
272
- });
273
- }
274
- function elementRefGetterWithDeprecationWarning() {
275
- var componentName = getComponentNameFromType(this.type);
276
- didWarnAboutElementRef[componentName] ||
277
- ((didWarnAboutElementRef[componentName] = true),
278
- console.error(
279
- "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
280
- ));
281
- componentName = this.props.ref;
282
- return void 0 !== componentName ? componentName : null;
283
- }
284
- function ReactElement(
285
- type,
286
- key,
287
- self,
288
- source,
289
- owner,
290
- props,
291
- debugStack,
292
- debugTask
293
- ) {
294
- self = props.ref;
295
- type = {
296
- $$typeof: REACT_ELEMENT_TYPE,
297
- type: type,
298
- key: key,
299
- props: props,
300
- _owner: owner
301
- };
302
- null !== (void 0 !== self ? self : null)
303
- ? Object.defineProperty(type, "ref", {
304
- enumerable: false,
305
- get: elementRefGetterWithDeprecationWarning
306
- })
307
- : Object.defineProperty(type, "ref", { enumerable: false, value: null });
308
- type._store = {};
309
- Object.defineProperty(type._store, "validated", {
310
- configurable: false,
311
- enumerable: false,
312
- writable: true,
313
- value: 0
314
- });
315
- Object.defineProperty(type, "_debugInfo", {
316
- configurable: false,
317
- enumerable: false,
318
- writable: true,
319
- value: null
320
- });
321
- Object.defineProperty(type, "_debugStack", {
322
- configurable: false,
323
- enumerable: false,
324
- writable: true,
325
- value: debugStack
326
- });
327
- Object.defineProperty(type, "_debugTask", {
328
- configurable: false,
329
- enumerable: false,
330
- writable: true,
331
- value: debugTask
332
- });
333
- Object.freeze && (Object.freeze(type.props), Object.freeze(type));
334
- return type;
335
- }
336
- function jsxDEVImpl(
337
- type,
338
- config,
339
- maybeKey,
340
- isStaticChildren,
341
- source,
342
- self,
343
- debugStack,
344
- debugTask
345
- ) {
346
- var children = config.children;
347
- if (void 0 !== children)
348
- if (isStaticChildren)
349
- if (isArrayImpl(children)) {
350
- for (
351
- isStaticChildren = 0;
352
- isStaticChildren < children.length;
353
- isStaticChildren++
354
- )
355
- validateChildKeys(children[isStaticChildren]);
356
- Object.freeze && Object.freeze(children);
357
- } else
358
- console.error(
359
- "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
360
- );
361
- else validateChildKeys(children);
362
- if (hasOwnProperty.call(config, "key")) {
363
- children = getComponentNameFromType(type);
364
- var keys = Object.keys(config).filter(function (k) {
365
- return "key" !== k;
366
- });
367
- isStaticChildren =
368
- 0 < keys.length
369
- ? "{key: someKey, " + keys.join(": ..., ") + ": ...}"
370
- : "{key: someKey}";
371
- didWarnAboutKeySpread[children + isStaticChildren] ||
372
- ((keys =
373
- 0 < keys.length ? "{" + keys.join(": ..., ") + ": ...}" : "{}"),
374
- console.error(
375
- 'A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',
376
- isStaticChildren,
377
- children,
378
- keys,
379
- children
380
- ),
381
- (didWarnAboutKeySpread[children + isStaticChildren] = true));
382
- }
383
- children = null;
384
- void 0 !== maybeKey &&
385
- (checkKeyStringCoercion(maybeKey), (children = "" + maybeKey));
386
- hasValidKey(config) &&
387
- (checkKeyStringCoercion(config.key), (children = "" + config.key));
388
- if ("key" in config) {
389
- maybeKey = {};
390
- for (var propName in config)
391
- "key" !== propName && (maybeKey[propName] = config[propName]);
392
- } else maybeKey = config;
393
- children &&
394
- defineKeyPropWarningGetter(
395
- maybeKey,
396
- "function" === typeof type
397
- ? type.displayName || type.name || "Unknown"
398
- : type
399
- );
400
- return ReactElement(
401
- type,
402
- children,
403
- self,
404
- source,
405
- getOwner(),
406
- maybeKey,
407
- debugStack,
408
- debugTask
409
- );
410
- }
411
- function validateChildKeys(node) {
412
- "object" === typeof node &&
413
- null !== node &&
414
- node.$$typeof === REACT_ELEMENT_TYPE &&
415
- node._store &&
416
- (node._store.validated = 1);
417
- }
418
- var React = require$$0,
419
- REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
420
- REACT_PORTAL_TYPE = Symbol.for("react.portal"),
421
- REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
422
- REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
423
- REACT_PROFILER_TYPE = Symbol.for("react.profiler");
424
- var REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
425
- REACT_CONTEXT_TYPE = Symbol.for("react.context"),
426
- REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
427
- REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
428
- REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
429
- REACT_MEMO_TYPE = Symbol.for("react.memo"),
430
- REACT_LAZY_TYPE = Symbol.for("react.lazy"),
431
- REACT_ACTIVITY_TYPE = Symbol.for("react.activity"),
432
- REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"),
433
- ReactSharedInternals =
434
- React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
435
- hasOwnProperty = Object.prototype.hasOwnProperty,
436
- isArrayImpl = Array.isArray,
437
- createTask = console.createTask
438
- ? console.createTask
439
- : function () {
440
- return null;
441
- };
442
- React = {
443
- "react-stack-bottom-frame": function (callStackForError) {
444
- return callStackForError();
445
- }
446
- };
447
- var specialPropKeyWarningShown;
448
- var didWarnAboutElementRef = {};
449
- var unknownOwnerDebugStack = React["react-stack-bottom-frame"].bind(
450
- React,
451
- UnknownOwner
452
- )();
453
- var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
454
- var didWarnAboutKeySpread = {};
455
- reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
456
- reactJsxRuntime_development.jsx = function (type, config, maybeKey, source, self) {
457
- var trackActualOwner =
458
- 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
459
- return jsxDEVImpl(
460
- type,
461
- config,
462
- maybeKey,
463
- false,
464
- source,
465
- self,
466
- trackActualOwner
467
- ? Error("react-stack-top-frame")
468
- : unknownOwnerDebugStack,
469
- trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
470
- );
471
- };
472
- reactJsxRuntime_development.jsxs = function (type, config, maybeKey, source, self) {
473
- var trackActualOwner =
474
- 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
475
- return jsxDEVImpl(
476
- type,
477
- config,
478
- maybeKey,
479
- true,
480
- source,
481
- self,
482
- trackActualOwner
483
- ? Error("react-stack-top-frame")
484
- : unknownOwnerDebugStack,
485
- trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
486
- );
487
- };
488
- })();
489
- return reactJsxRuntime_development;
490
- }
491
-
492
- if (process.env.NODE_ENV === 'production') {
493
- jsxRuntime.exports = requireReactJsxRuntime_production();
494
- } else {
495
- jsxRuntime.exports = requireReactJsxRuntime_development();
496
- }
497
-
498
- var jsxRuntimeExports = jsxRuntime.exports;
499
-
500
80
  function useSearchParams() {
501
81
  var _a = useState(function () {
502
82
  return new URLSearchParams(window.location.search);
@@ -526,8 +106,11 @@ function useSearchParams() {
526
106
  return [searchParams, setSearchParams, removeSearchParam];
527
107
  }
528
108
 
529
- function constructURI(clientId, session_type) {
530
- var request_uri = "https://issuance.wallet-connect.eu/disclosure/".concat(clientId, "/request_uri?session_type=").concat(session_type);
109
+ // Global cache to prevent duplicate requests
110
+ var credentialsCache = new Map();
111
+ function constructURI(clientId, session_type, walletConnectHost) {
112
+ var baseHost = walletConnectHost || "https://issuance.wallet-connect.eu";
113
+ var request_uri = "".concat(baseHost, "/disclosure/").concat(clientId, "/request_uri?session_type=").concat(session_type);
531
114
  var request_uri_method = "post";
532
115
  var client_id_uri = "".concat(clientId, ".example.com");
533
116
  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);
@@ -539,8 +122,8 @@ function WalletConnectButton(_a) {
539
122
  var _c = useState(false), loading = _c[0], setLoading = _c[1];
540
123
  var _d = useState(null), error = _d[0], setError = _d[1];
541
124
  var buttonRef = useRef(null);
542
- var sameDeviceUl = constructURI(clientId, "same_device");
543
- var crossDeviceUl = constructURI(clientId, "cross_device");
125
+ var sameDeviceUl = constructURI(clientId, "same_device", walletConnectHost);
126
+ var crossDeviceUl = constructURI(clientId, "cross_device", walletConnectHost);
544
127
  useEffect(function () {
545
128
  // Dynamically import the web component
546
129
  var loadWebComponent = function () { return __awaiter(_this, void 0, void 0, function () {
@@ -557,6 +140,8 @@ function WalletConnectButton(_a) {
557
140
  if (button) {
558
141
  button.addEventListener("success", handleSuccess);
559
142
  button.addEventListener("failed", handleFailed);
143
+ // Add click listener directly to the element
144
+ button.addEventListener("click", handleButtonClick);
560
145
  }
561
146
  return [3 /*break*/, 3];
562
147
  case 2:
@@ -574,9 +159,131 @@ function WalletConnectButton(_a) {
574
159
  if (button) {
575
160
  button.removeEventListener("success", handleSuccess);
576
161
  button.removeEventListener("failed", handleFailed);
162
+ button.removeEventListener("click", handleButtonClick);
577
163
  }
578
164
  };
579
165
  }, []);
166
+ var fetchRequestedCredentials = function () { return __awaiter(_this, void 0, void 0, function () {
167
+ var cacheKey, cached, fetchPromise;
168
+ var _this = this;
169
+ return __generator(this, function (_a) {
170
+ switch (_a.label) {
171
+ case 0:
172
+ if (!apiKey || !clientId)
173
+ return [2 /*return*/, []];
174
+ cacheKey = "".concat(clientId, "-").concat(walletConnectHost || "default");
175
+ cached = credentialsCache.get(cacheKey);
176
+ if (cached === null || cached === void 0 ? void 0 : cached.data) {
177
+ return [2 /*return*/, cached.data];
178
+ }
179
+ if (!(cached === null || cached === void 0 ? void 0 : cached.promise)) return [3 /*break*/, 2];
180
+ return [4 /*yield*/, cached.promise];
181
+ case 1: return [2 /*return*/, _a.sent()];
182
+ case 2:
183
+ fetchPromise = (function () { return __awaiter(_this, void 0, void 0, function () {
184
+ var baseUrl, url, headers, response, credentials, error_2;
185
+ var _a, _b;
186
+ return __generator(this, function (_c) {
187
+ switch (_c.label) {
188
+ case 0:
189
+ _c.trys.push([0, 2, , 3]);
190
+ baseUrl = walletConnectHost || "https://wallet-connect.eu";
191
+ url = "".concat(baseUrl, "/api/client/").concat(clientId, "/requested-credentials");
192
+ headers = { 'Authorization': "Bearer ".concat(apiKey) };
193
+ return [4 /*yield*/, axios.get(url, { headers: headers })];
194
+ case 1:
195
+ response = _c.sent();
196
+ credentials = ((_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.requestedCredentials) || [];
197
+ // Cache the result
198
+ credentialsCache.set(cacheKey, { data: credentials });
199
+ return [2 /*return*/, credentials];
200
+ case 2:
201
+ error_2 = _c.sent();
202
+ // Remove failed request from cache
203
+ credentialsCache.delete(cacheKey);
204
+ throw error_2;
205
+ case 3: return [2 /*return*/];
206
+ }
207
+ });
208
+ }); })();
209
+ // Cache the promise to prevent duplicate requests
210
+ credentialsCache.set(cacheKey, { promise: fetchPromise });
211
+ return [4 /*yield*/, fetchPromise];
212
+ case 3: return [2 /*return*/, _a.sent()];
213
+ }
214
+ });
215
+ }); };
216
+ var injectCredentialsIntoShadowDOM = function (credentials, retryCount) {
217
+ if (retryCount === void 0) { retryCount = 0; }
218
+ var maxRetries = 10;
219
+ var walletButton = buttonRef.current;
220
+ if (!walletButton || !walletButton.shadowRoot) {
221
+ return;
222
+ }
223
+ // Remove any existing credential info
224
+ var existingCredentials = walletButton.shadowRoot.querySelector('.required-credentials');
225
+ if (existingCredentials) {
226
+ existingCredentials.remove();
227
+ }
228
+ if (credentials.length === 0)
229
+ return;
230
+ // Look for the modal and website section
231
+ var modal = walletButton.shadowRoot.querySelector('.modal');
232
+ if (!modal) {
233
+ // Retry if modal not found yet
234
+ if (retryCount < maxRetries) {
235
+ setTimeout(function () {
236
+ injectCredentialsIntoShadowDOM(credentials, retryCount + 1);
237
+ }, 200);
238
+ return;
239
+ }
240
+ return;
241
+ }
242
+ var websiteSection = modal.querySelector('.website');
243
+ // Determine language and translations
244
+ var isNL = lang === 'nl';
245
+ var headerText = isNL ? 'Benodigde Attestaties:' : 'Required Credentials:';
246
+ var getLinkText = isNL ? '→ Verkrijg attestatie' : '→ Get credential';
247
+ // Create credential info element
248
+ var credentialsDiv = document.createElement('div');
249
+ credentialsDiv.className = 'required-credentials';
250
+ credentialsDiv.innerHTML = "\n <div style=\"\n background: #f8f9fa;\n border: 1px solid #e9ecef;\n border-radius: 6px;\n padding: 12px;\n font-family: inherit;\n font-size: 13px;\n line-height: 1.4;\n \">\n <div style=\"margin: 0 0 8px 0; color: #212529; font-size: 14px; font-weight: 600;\">".concat(headerText, "</div>\n ").concat(credentials.map(function (credential) {
251
+ var credentialName = isNL ? credential.credentialName.nl : credential.credentialName.en;
252
+ return "\n <div style=\"margin-bottom: 6px; display: flex; align-items: center; flex-wrap: wrap; gap: 8px;\">\n <span style=\"color: #495057; font-weight: 500;\">".concat(credentialName, "</span>\n ").concat(credential.websiteUrl ? "\n <a href=\"".concat(credential.websiteUrl, "\" target=\"_blank\" rel=\"noopener noreferrer\" style=\"\n color: #0066cc;\n text-decoration: none;\n font-size: 12px;\n white-space: nowrap;\n \">").concat(getLinkText, "</a>\n ") : '', "\n </div>\n ");
253
+ }).join(''), "\n </div>\n ");
254
+ // Insert the credentials div after the website section
255
+ if (websiteSection) {
256
+ websiteSection.insertAdjacentElement('afterend', credentialsDiv);
257
+ }
258
+ else {
259
+ // Fallback: insert at the beginning of modal
260
+ modal.insertBefore(credentialsDiv, modal.firstChild);
261
+ }
262
+ };
263
+ var handleButtonClick = function (_event) { return __awaiter(_this, void 0, void 0, function () {
264
+ var credentials_1, error_3;
265
+ return __generator(this, function (_a) {
266
+ switch (_a.label) {
267
+ case 0:
268
+ _a.trys.push([0, 2, , 3]);
269
+ return [4 /*yield*/, fetchRequestedCredentials()];
270
+ case 1:
271
+ credentials_1 = _a.sent();
272
+ if (credentials_1 && credentials_1.length > 0) {
273
+ // Inject credentials into the shadow DOM with multiple attempts
274
+ setTimeout(function () {
275
+ injectCredentialsIntoShadowDOM(credentials_1);
276
+ }, 100);
277
+ }
278
+ return [3 /*break*/, 3];
279
+ case 2:
280
+ error_3 = _a.sent();
281
+ console.error('Failed to fetch credentials:', error_3);
282
+ return [3 /*break*/, 3];
283
+ case 3: return [2 /*return*/];
284
+ }
285
+ });
286
+ }); };
580
287
  // Function to handle the 'success' event
581
288
  var handleSuccess = function (e) {
582
289
  var customEvent = e;
@@ -629,14 +336,16 @@ function WalletConnectButton(_a) {
629
336
  });
630
337
  }, [searchParams, onSuccess]);
631
338
  if (loading) {
632
- return (jsxRuntimeExports.jsx("div", { className: "attributes", children: jsxRuntimeExports.jsxs("div", { className: "verification-card", children: [jsxRuntimeExports.jsx("h2", { children: "Checking attributes..." }), jsxRuntimeExports.jsx("p", { children: "Please wait while we verify your attributes." })] }) }));
339
+ return (jsx("div", { className: "attributes", children: jsxs("div", { className: "verification-card", children: [jsx("h2", { children: "Checking attributes..." }), jsx("p", { children: "Please wait while we verify your attributes." })] }) }));
633
340
  }
634
341
  if (error) {
635
- return (jsxRuntimeExports.jsx("div", { className: "attributes", children: jsxRuntimeExports.jsxs("div", { className: "verification-card", children: [jsxRuntimeExports.jsx("h2", { children: "Error" }), jsxRuntimeExports.jsxs("p", { children: ["An error occurred while verifying your attributes: ", error] })] }) }));
342
+ 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] })] }) }));
636
343
  }
637
- return (jsxRuntimeExports.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 }));
344
+ return (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 }));
638
345
  }
639
346
 
347
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
348
+
640
349
  var nlWalletWeb$1 = {};
641
350
 
642
351
  var di = Object.defineProperty;