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