@nuitee/booking-widget 1.0.5 → 1.0.6

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
@@ -94,15 +94,15 @@ widget.open();
94
94
  No bundler: load the script and CSS from the CDN, then create the widget.
95
95
 
96
96
  ```html
97
- <link rel="stylesheet" href="https://cdn.thehotelplanet.com/booking-widget/v1.0.5/dist/booking-widget.css">
98
- <script src="https://cdn.thehotelplanet.com/booking-widget/v1.0.5/dist/booking-widget-standalone.js"></script>
97
+ <link rel="stylesheet" href="https://cdn.thehotelplanet.com/booking-widget/v1.0.6/dist/booking-widget.css">
98
+ <script src="https://cdn.thehotelplanet.com/booking-widget/v1.0.6/dist/booking-widget-standalone.js"></script>
99
99
 
100
100
  <div id="booking-widget-container"></div>
101
101
 
102
102
  <script>
103
103
  const widget = new BookingWidget({
104
104
  containerId: 'booking-widget-container',
105
- cssUrl: 'https://cdn.thehotelplanet.com/booking-widget/v1.0.5/dist/booking-widget.css',
105
+ cssUrl: 'https://cdn.thehotelplanet.com/booking-widget/v1.0.6/dist/booking-widget.css',
106
106
  propertyKey: 'your-property-key',
107
107
  onOpen: () => console.log('Opened'),
108
108
  onClose: () => console.log('Closed'),
@@ -230,6 +230,7 @@ function createBookingApi(config = {}) {
230
230
  const url = `${(base || '').replace(/\/$/, '')}${path}`;
231
231
  const headers = {
232
232
  'Content-Type': 'application/json',
233
+ 'Source': 'booking_engine',
233
234
  ...staticHeaders,
234
235
  ...getHeaders(),
235
236
  };
@@ -291,8 +292,8 @@ function createBookingApi(config = {}) {
291
292
  ? `${propertyBaseUrl}/ari/get_properties?id=${encodeURIComponent(propertyId)}`
292
293
  : `/ari/get_properties?id=${encodeURIComponent(propertyId)}`;
293
294
  try {
294
- const getOpts = { method: 'GET' };
295
- if (propFullUrl.includes('ngrok')) getOpts.headers = { 'ngrok-skip-browser-warning': 'true' };
295
+ const getOpts = { method: 'GET', headers: { 'Source': 'booking_engine' } };
296
+ if (propFullUrl.includes('ngrok')) getOpts.headers['ngrok-skip-browser-warning'] = 'true';
296
297
  const propRes = await fetch(propFullUrl, getOpts);
297
298
  if (propRes.ok) {
298
299
  const propData = await propRes.json();
@@ -692,7 +693,7 @@ async function decryptPropertyId(options = {}) {
692
693
  const url = `${base}/${locale}/booking_engine/decrypt_property_id`;
693
694
  const res = await fetch(url, {
694
695
  method: 'POST',
695
- headers: { 'Content-Type': 'application/json', ...headers },
696
+ headers: { 'Content-Type': 'application/json', 'Source': 'booking_engine', ...headers },
696
697
  body: JSON.stringify({ hash: propertyKey }),
697
698
  });
698
699
  if (!res.ok) throw new Error(res.statusText || 'Failed to decrypt property id');
@@ -719,7 +720,7 @@ async function fetchBookingEnginePref(options = {}) {
719
720
  const url = `${base}/api/core/${locale}/booking_engine/booking_engine_pref?property_id=${encodeURIComponent(propertyId)}`;
720
721
  const res = await fetch(url, {
721
722
  method: 'GET',
722
- headers: { 'Content-Type': 'application/json', ...headers },
723
+ headers: { 'Content-Type': 'application/json', 'Source': 'booking_engine', ...headers },
723
724
  });
724
725
  if (!res.ok) throw new Error(res.statusText || 'Failed to fetch config');
725
726
 
@@ -906,7 +907,7 @@ if (typeof window !== 'undefined') {
906
907
  const url = defaultApiBase.replace(/\/$/, '') + '/proxy/create-payment-intent' + (options.mode === 'sandbox' ? '?sandbox=true' : '');
907
908
  return fetch(url, {
908
909
  method: 'POST',
909
- headers: { 'Content-Type': 'application/json' },
910
+ headers: { 'Content-Type': 'application/json', 'Source': 'booking_engine' },
910
911
  body: JSON.stringify(payload),
911
912
  }).then(function (r) {
912
913
  if (!r.ok) throw new Error(r.statusText || 'Payment intent failed');
@@ -1205,7 +1206,7 @@ if (typeof window !== 'undefined') {
1205
1206
  this.render();
1206
1207
 
1207
1208
  const url = 'https://ai.thehotelplanet.com/load-config?apikey=' + encodeURIComponent(key) + (isSandbox ? '&mode=sandbox' : '');
1208
- this._configPromise = fetch(url)
1209
+ this._configPromise = fetch(url, { headers: { 'Source': 'booking_engine' } })
1209
1210
  .then(function (res) {
1210
1211
  if (!res.ok) throw new Error('Failed to load widget configuration (HTTP ' + res.status + ').');
1211
1212
  return res.json();
@@ -1991,7 +1992,7 @@ if (typeof window !== 'undefined') {
1991
1992
  if (!token) throw new Error('Missing confirmation token');
1992
1993
  const base = String(this.options.confirmationBaseUrl || 'https://ai.thehotelplanet.com').replace(/\/$/, '');
1993
1994
  const url = base + '/proxy/confirmation/' + encodeURIComponent(token) + (this.options.mode === 'sandbox' ? '?sandbox=true' : '');
1994
- const res = await fetch(url, { method: 'POST' });
1995
+ const res = await fetch(url, { method: 'POST', headers: { 'Source': 'booking_engine' } });
1995
1996
  if (!res.ok) throw new Error(await res.text());
1996
1997
  return await res.json();
1997
1998
  }
@@ -122,7 +122,7 @@ class BookingWidget {
122
122
  const url = apiBase.replace(/\/$/, '') + '/proxy/create-payment-intent' + (builtInMode === 'sandbox' ? '?sandbox=true' : '');
123
123
  return fetch(url, {
124
124
  method: 'POST',
125
- headers: { 'Content-Type': 'application/json' },
125
+ headers: { 'Content-Type': 'application/json', 'Source': 'booking_engine' },
126
126
  body: JSON.stringify(payload),
127
127
  }).then(function (r) {
128
128
  if (!r.ok) throw new Error(r.statusText || 'Payment intent failed');
@@ -483,7 +483,7 @@ class BookingWidget {
483
483
  this.render();
484
484
 
485
485
  const url = 'https://ai.thehotelplanet.com/load-config?apikey=' + encodeURIComponent(key) + (isSandbox ? '&mode=sandbox' : '');
486
- this._configPromise = fetch(url)
486
+ this._configPromise = fetch(url, { headers: { 'Source': 'booking_engine' } })
487
487
  .then(function (res) {
488
488
  if (!res.ok) throw new Error('Failed to load widget configuration (HTTP ' + res.status + ').');
489
489
  return res.json();
@@ -1407,7 +1407,7 @@ class BookingWidget {
1407
1407
  if (!token) throw new Error('Missing confirmation token');
1408
1408
  const base = String(this.options.confirmationBaseUrl || 'https://ai.thehotelplanet.com').replace(/\/$/, '');
1409
1409
  const url = `${base}/proxy/confirmation/${encodeURIComponent(token)}${this.options.mode === 'sandbox' ? '?sandbox=true' : ''}`;
1410
- const res = await fetch(url, { method: 'POST' });
1410
+ const res = await fetch(url, { method: 'POST', headers: { 'Source': 'booking_engine' } });
1411
1411
  if (!res.ok) throw new Error(await res.text());
1412
1412
  return await res.json();
1413
1413
  }
@@ -229,6 +229,7 @@ function createBookingApi(config = {}) {
229
229
  const url = `${(base || '').replace(/\/$/, '')}${path}`;
230
230
  const headers = {
231
231
  'Content-Type': 'application/json',
232
+ 'Source': 'booking_engine',
232
233
  ...staticHeaders,
233
234
  ...getHeaders(),
234
235
  };
@@ -290,8 +291,8 @@ function createBookingApi(config = {}) {
290
291
  ? `${propertyBaseUrl}/ari/get_properties?id=${encodeURIComponent(propertyId)}`
291
292
  : `/ari/get_properties?id=${encodeURIComponent(propertyId)}`;
292
293
  try {
293
- const getOpts = { method: 'GET' };
294
- if (propFullUrl.includes('ngrok')) getOpts.headers = { 'ngrok-skip-browser-warning': 'true' };
294
+ const getOpts = { method: 'GET', headers: { 'Source': 'booking_engine' } };
295
+ if (propFullUrl.includes('ngrok')) getOpts.headers['ngrok-skip-browser-warning'] = 'true';
295
296
  const propRes = await fetch(propFullUrl, getOpts);
296
297
  if (propRes.ok) {
297
298
  const propData = await propRes.json();
@@ -691,7 +692,7 @@ async function decryptPropertyId(options = {}) {
691
692
  const url = `${base}/${locale}/booking_engine/decrypt_property_id`;
692
693
  const res = await fetch(url, {
693
694
  method: 'POST',
694
- headers: { 'Content-Type': 'application/json', ...headers },
695
+ headers: { 'Content-Type': 'application/json', 'Source': 'booking_engine', ...headers },
695
696
  body: JSON.stringify({ hash: propertyKey }),
696
697
  });
697
698
  if (!res.ok) throw new Error(res.statusText || 'Failed to decrypt property id');
@@ -718,7 +719,7 @@ async function fetchBookingEnginePref(options = {}) {
718
719
  const url = `${base}/api/core/${locale}/booking_engine/booking_engine_pref?property_id=${encodeURIComponent(propertyId)}`;
719
720
  const res = await fetch(url, {
720
721
  method: 'GET',
721
- headers: { 'Content-Type': 'application/json', ...headers },
722
+ headers: { 'Content-Type': 'application/json', 'Source': 'booking_engine', ...headers },
722
723
  });
723
724
  if (!res.ok) throw new Error(res.statusText || 'Failed to fetch config');
724
725
 
@@ -57,7 +57,7 @@ const BookingWidget = ({
57
57
  if (!effectivePaymentIntentUrl) return null;
58
58
  return async (payload) => {
59
59
  const url = effectivePaymentIntentUrl + (isSandbox ? '?sandbox=true' : '');
60
- const headers = { 'Content-Type': 'application/json' };
60
+ const headers = { 'Content-Type': 'application/json', 'Source': 'booking_engine' };
61
61
  if (url.includes('ngrok')) headers['ngrok-skip-browser-warning'] = 'true';
62
62
  const res = await fetch(url, { method: 'POST', headers, body: JSON.stringify(payload) });
63
63
  if (!res.ok) throw new Error(await res.text());
@@ -205,7 +205,7 @@ const BookingWidget = ({
205
205
  if (cancelled) return;
206
206
  try {
207
207
  const url = `${effectiveConfirmationBaseUrl}/proxy/confirmation/${encodeURIComponent(String(confirmationToken).trim())}${isSandbox ? '?sandbox=true' : ''}`;
208
- const res = await fetch(url, { method: 'POST' });
208
+ const res = await fetch(url, { method: 'POST', headers: { 'Source': 'booking_engine' } });
209
209
  if (!res.ok) throw new Error(await res.text());
210
210
  const data = await res.json();
211
211
  const status = data?.status != null ? String(data.status) : '';
@@ -89,7 +89,7 @@ export async function fetchRuntimeConfig(propertyKey, installerColors = null, mo
89
89
  }
90
90
 
91
91
  const url = `${CONFIG_BASE_URL}?apikey=${encodeURIComponent(key)}${isSandbox ? '&mode=sandbox' : ''}`;
92
- const res = await fetch(url);
92
+ const res = await fetch(url, { headers: { 'Source': 'booking_engine' } });
93
93
  if (!res.ok) {
94
94
  throw new Error(`Failed to load widget configuration (HTTP ${res.status}).`);
95
95
  }
@@ -604,7 +604,7 @@ export default {
604
604
  if (!url) return null;
605
605
  return async (payload) => {
606
606
  const requestUrl = url + (this.isSandbox ? '?sandbox=true' : '');
607
- const headers = { 'Content-Type': 'application/json' };
607
+ const headers = { 'Content-Type': 'application/json', 'Source': 'booking_engine' };
608
608
  if (requestUrl.includes('ngrok')) headers['ngrok-skip-browser-warning'] = 'true';
609
609
  const res = await fetch(requestUrl, { method: 'POST', headers, body: JSON.stringify(payload) });
610
610
  if (!res.ok) throw new Error(await res.text());
@@ -795,7 +795,7 @@ export default {
795
795
  const t = String(token || '').trim();
796
796
  if (!t) throw new Error('Missing confirmation token');
797
797
  const url = `${this.effectiveConfirmationBaseUrl}/proxy/confirmation/${encodeURIComponent(t)}${this.isSandbox ? '?sandbox=true' : ''}`;
798
- const res = await fetch(url, { method: 'POST' });
798
+ const res = await fetch(url, { method: 'POST', headers: { 'Source': 'booking_engine' } });
799
799
  if (!res.ok) throw new Error(await res.text());
800
800
  return await res.json();
801
801
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuitee/booking-widget",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "A beautiful, customizable booking widget modal that can be embedded in any website. Supports vanilla JavaScript, React, and Vue.js.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",