wallet-connect-button-vue 1.0.12 → 1.0.13
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.esm.js +43 -19
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +43 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -49,7 +49,8 @@ const _sfc_main = {
|
|
|
49
49
|
clientId: { type: String, required: true },
|
|
50
50
|
onSuccess: { type: Function, required: false },
|
|
51
51
|
apiKey: { type: String, required: false },
|
|
52
|
-
|
|
52
|
+
useLocalWcServer: { type: Boolean, required: false, default: false },
|
|
53
|
+
business: { type: Boolean, required: false, default: false },
|
|
53
54
|
lang: { type: String, required: false, default: 'nl' },
|
|
54
55
|
helpBaseUrl: { type: String, required: false },
|
|
55
56
|
issuance: { type: Boolean, required: false }
|
|
@@ -65,19 +66,42 @@ const loading = ref(false);
|
|
|
65
66
|
const error = ref(null);
|
|
66
67
|
const buttonRef = ref(null);
|
|
67
68
|
|
|
69
|
+
const getDefaultHost = () => {
|
|
70
|
+
// If useLocalWcServer is set, use local server
|
|
71
|
+
if (props.useLocalWcServer) {
|
|
72
|
+
if (props.business) {
|
|
73
|
+
return props.issuance ? 'http://localhost:4007' : 'http://bw.localhost:3021';
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return props.issuance ? 'http://localhost:3007' : 'http://localhost:3021';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Otherwise use remote servers
|
|
80
|
+
if (props.business) {
|
|
81
|
+
return props.issuance ? 'https://bw.issuance.wallet-connect.eu' : 'https://bw.wallet-connect.eu';
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return props.issuance ? 'https://issuance.wallet-connect.eu' : 'https://wallet-connect.eu';
|
|
85
|
+
};
|
|
86
|
+
|
|
68
87
|
const startUrl = computed(() => {
|
|
69
|
-
const baseUrl =
|
|
88
|
+
const baseUrl = getDefaultHost();
|
|
70
89
|
const returnUrl = typeof window !== 'undefined' ? window.location.href : '';
|
|
71
90
|
return `${baseUrl}/api/create-session?lang=en&return_url=${encodeURIComponent(returnUrl)}`;
|
|
72
91
|
});
|
|
73
92
|
|
|
74
93
|
const constructURI = (session_type) => {
|
|
75
|
-
const
|
|
76
|
-
const request_uri = `${baseHost}/disclosure/${props.clientId}/request_uri?session_type=${session_type}`;
|
|
94
|
+
const request_uri = `${getDefaultHost()}/disclosure/${props.clientId}/request_uri?session_type=${session_type}`;
|
|
77
95
|
const request_uri_method = "post";
|
|
78
96
|
const client_id_uri = `${props.clientId}.example.com`;
|
|
79
|
-
|
|
80
|
-
|
|
97
|
+
|
|
98
|
+
const deepLinkScheme = props.business
|
|
99
|
+
? 'businesswalletdebuginteraction://wallet.kvk.rijksoverheid.nl'
|
|
100
|
+
: 'walletdebuginteraction://wallet.edi.rijksoverheid.nl';
|
|
101
|
+
|
|
102
|
+
return `${deepLinkScheme}/disclosure_based_issuance?request_uri=${encodeURIComponent(
|
|
103
|
+
request_uri
|
|
104
|
+
)}&request_uri_method=${request_uri_method}&client_id=${client_id_uri}`;
|
|
81
105
|
};
|
|
82
106
|
|
|
83
107
|
const sameDeviceUl = computed(() => constructURI("same_device"));
|
|
@@ -85,31 +109,31 @@ const crossDeviceUl = computed(() => constructURI("cross_device"));
|
|
|
85
109
|
|
|
86
110
|
const fetchRequestedCredentials = async () => {
|
|
87
111
|
if (!props.apiKey || !props.clientId) return [];
|
|
88
|
-
|
|
89
|
-
const cacheKey = `${props.clientId}-${
|
|
90
|
-
|
|
112
|
+
|
|
113
|
+
const cacheKey = `${props.clientId}-${getDefaultHost()}`;
|
|
114
|
+
|
|
91
115
|
// Check if we already have data in cache
|
|
92
116
|
const cached = credentialsCache.get(cacheKey);
|
|
93
117
|
if (cached?.data) {
|
|
94
118
|
return cached.data;
|
|
95
119
|
}
|
|
96
|
-
|
|
120
|
+
|
|
97
121
|
// Check if there's already a request in progress
|
|
98
122
|
if (cached?.promise) {
|
|
99
123
|
return await cached.promise;
|
|
100
124
|
}
|
|
101
|
-
|
|
125
|
+
|
|
102
126
|
const fetchPromise = (async () => {
|
|
103
127
|
try {
|
|
104
|
-
const baseUrl =
|
|
128
|
+
const baseUrl = getDefaultHost();
|
|
105
129
|
const url = `${baseUrl}/api/client/${props.clientId}/requested-credentials`;
|
|
106
130
|
const headers = { 'Authorization': `Bearer ${props.apiKey}` };
|
|
107
|
-
|
|
131
|
+
|
|
108
132
|
const response = await axios.get(url, { headers });
|
|
109
|
-
|
|
133
|
+
|
|
110
134
|
// Extract credentials from the response
|
|
111
135
|
const credentials = response.data?.data?.requestedCredentials || [];
|
|
112
|
-
|
|
136
|
+
|
|
113
137
|
// Cache the result
|
|
114
138
|
credentialsCache.set(cacheKey, { data: credentials });
|
|
115
139
|
return credentials;
|
|
@@ -119,10 +143,10 @@ const fetchRequestedCredentials = async () => {
|
|
|
119
143
|
throw error;
|
|
120
144
|
}
|
|
121
145
|
})();
|
|
122
|
-
|
|
146
|
+
|
|
123
147
|
// Cache the promise to prevent duplicate requests
|
|
124
148
|
credentialsCache.set(cacheKey, { promise: fetchPromise });
|
|
125
|
-
|
|
149
|
+
|
|
126
150
|
return await fetchPromise;
|
|
127
151
|
};
|
|
128
152
|
|
|
@@ -259,12 +283,12 @@ const fetchDisclosedAttributes = async () => {
|
|
|
259
283
|
if (!session_token) return;
|
|
260
284
|
|
|
261
285
|
loading.value = true;
|
|
262
|
-
const baseUrl = props.apiKey ? (
|
|
286
|
+
const baseUrl = props.apiKey ? getDefaultHost() : "";
|
|
263
287
|
let url = baseUrl + `/api/disclosed-attributes?session_token=${session_token}&client_id=${props.clientId}`;
|
|
264
288
|
if (nonce) url = `${url}&nonce=${nonce}`;
|
|
265
289
|
|
|
266
290
|
const headers = props.apiKey ? { 'Authorization': `Bearer ${props.apiKey}` } : {};
|
|
267
|
-
|
|
291
|
+
|
|
268
292
|
try {
|
|
269
293
|
const { data } = await axios.get(url, { headers });
|
|
270
294
|
console.log("Disclosed attributes:", data);
|