wallet-connect-button-react 1.0.4 → 1.0.5

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/README.md CHANGED
@@ -1,5 +1,50 @@
1
1
  # wallet-connect-button-react
2
2
 
3
- A React component for wallet connection functionality.
3
+ A React component for NL Wallet integration.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install wallet-connect-button-react
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ 1. Import the component in your React app:
14
+
15
+ ```typescript
16
+ import { WalletConnectButton } from 'wallet-connect-button-react';
17
+ ```
18
+
19
+ 2. Use the component in your JSX:
20
+
21
+ ```jsx
22
+ <WalletConnectButton
23
+ clientId="your-client-id"
24
+ apiKey="your-api-key"
25
+ walletConnectHost="https://wallet-connect.eu"
26
+ onSuccess={(attributes) => console.log('Success:', attributes)}
27
+ >
28
+ Connect Wallet
29
+ </WalletConnectButton>
30
+ ```
31
+
32
+ 3. Handle the success callback in your component:
33
+
34
+ ```typescript
35
+ const handleWalletSuccess = (attributes: any) => {
36
+ console.log('Wallet connected successfully:', attributes);
37
+ };
38
+ ```
39
+
40
+ ## API
41
+
42
+ ### Props
43
+
44
+ - `clientId: string` - Required. Your client ID for wallet connection
45
+ - `onSuccess: (attributes: AttributeData | undefined) => void` - Required. Callback function called when wallet connection succeeds
46
+ - `apiKey?: string` - Optional. API key for authentication
47
+ - `walletConnectHost?: string` - Optional. Custom wallet connect host URL (defaults to https://wallet-connect.eu)
48
+ - `children?: React.ReactNode` - Optional. Custom button content
4
49
 
5
50
  For further explanation and documentation, visit: https://wallet-connect.eu
@@ -0,0 +1,28 @@
1
+ import React from "react";
2
+ interface AttributeData {
3
+ age_over_18?: boolean;
4
+ [key: string]: any;
5
+ }
6
+ export interface WalletConnectButtonProps {
7
+ children?: React.ReactNode;
8
+ clientId: string;
9
+ onSuccess: (attributes: AttributeData | undefined) => void;
10
+ apiKey?: string;
11
+ walletConnectHost?: string;
12
+ lang?: string;
13
+ }
14
+ declare global {
15
+ namespace JSX {
16
+ interface IntrinsicElements {
17
+ 'nl-wallet-button': {
18
+ ref?: React.RefObject<HTMLElement>;
19
+ text?: React.ReactNode;
20
+ usecase?: string;
21
+ 'start-url'?: string;
22
+ lang?: string;
23
+ };
24
+ }
25
+ }
26
+ }
27
+ declare function WalletConnectButton({ children, clientId, onSuccess, apiKey, walletConnectHost, lang }: WalletConnectButtonProps): import("react/jsx-runtime").JSX.Element;
28
+ export default WalletConnectButton;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { default as NLWalletButton } from './NLWalletButton';
2
- export { default } from './NLWalletButton';
3
- export type { NLWalletButtonProps } from './NLWalletButton';
1
+ export { default as WalletConnectButton } from './WalletConnectButton';
2
+ export { default } from './WalletConnectButton';
3
+ export type { WalletConnectButtonProps } from './WalletConnectButton';
package/dist/index.esm.js CHANGED
@@ -526,9 +526,9 @@ function useSearchParams() {
526
526
  return [searchParams, setSearchParams, removeSearchParam];
527
527
  }
528
528
 
529
- function NLWalletButton(_a) {
529
+ function WalletConnectButton(_a) {
530
530
  var _this = this;
531
- var children = _a.children, clientId = _a.clientId, onSuccess = _a.onSuccess, apiKey = _a.apiKey, walletConnectHost = _a.walletConnectHost;
531
+ var children = _a.children, clientId = _a.clientId, onSuccess = _a.onSuccess, apiKey = _a.apiKey, walletConnectHost = _a.walletConnectHost, lang = _a.lang;
532
532
  var _b = useSearchParams(), searchParams = _b[0], setSearchParams = _b[1], removeSearchParam = _b[2];
533
533
  var _c = useState(false), loading = _c[0], setLoading = _c[1];
534
534
  var _d = useState(null), error = _d[0], setError = _d[1];
@@ -592,29 +592,10 @@ function NLWalletButton(_a) {
592
592
  if (!session_token)
593
593
  return;
594
594
  setLoading(true);
595
- var baseUrl = walletConnectHost || "https://wallet-connect.eu";
596
- var url = baseUrl + "/disclosed-attributes?session_token=".concat(session_token, "&client_id=").concat(clientId);
595
+ var baseUrl = apiKey ? (walletConnectHost || "https://wallet-connect.eu") : "";
596
+ var url = baseUrl + "/api/disclosed-attributes?session_token=".concat(session_token, "&client_id=").concat(clientId);
597
597
  if (nonce)
598
598
  url = "".concat(url, "&nonce=").concat(nonce);
599
- // Example response structure
600
- // {
601
- // "attributes": {
602
- // "urn:eudi:pid:nl:1": {
603
- // "attributes": {
604
- // "urn:eudi:pid:nl:1": {
605
- // "age_over_18": true
606
- // }
607
- // },
608
- // "issuerUri": "https://cert.issuer.example.com/",
609
- // "ca": "ca.issuer.example.com",
610
- // "validityInfo": {
611
- // "signed": "2025-07-22T12:08:12Z",
612
- // "validFrom": "2025-07-22T00:00:00Z",
613
- // "validUntil": "2026-07-22T00:00:00Z"
614
- // }
615
- // }
616
- // }
617
- // }
618
599
  var headers = apiKey ? { 'Authorization': "Bearer ".concat(apiKey) } : {};
619
600
  axios
620
601
  .get(url, { headers: headers })
@@ -639,7 +620,7 @@ function NLWalletButton(_a) {
639
620
  if (error) {
640
621
  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] })] }) }));
641
622
  }
642
- return (jsxRuntimeExports.jsx("nl-wallet-button", { ref: buttonRef, text: children, usecase: clientId, "start-url": "".concat(walletConnectHost || "https://wallet-connect.eu", "/create-session?lang=en&return_url=").concat(encodeURIComponent(window.location.href)), lang: "nl" }));
623
+ return (jsxRuntimeExports.jsx("nl-wallet-button", { ref: buttonRef, text: children, usecase: clientId, "start-url": "".concat(walletConnectHost || "https://wallet-connect.eu", "/api/create-session?lang=en&return_url=").concat(encodeURIComponent(window.location.href)), lang: lang || "nl" }));
643
624
  }
644
625
 
645
626
  var nlWalletWeb$1 = {};
@@ -7718,5 +7699,5 @@ var nlWalletWeb = /*#__PURE__*/_mergeNamespaces({
7718
7699
  default: nlWalletWeb$1
7719
7700
  }, [nlWalletWeb$1]);
7720
7701
 
7721
- export { NLWalletButton, NLWalletButton as default };
7702
+ export { WalletConnectButton, WalletConnectButton as default };
7722
7703
  //# sourceMappingURL=index.esm.js.map