@tiquo/dom-package 1.1.2 → 1.2.0

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.d.mts CHANGED
@@ -4,13 +4,13 @@
4
4
  * This module handles setting a cross-subdomain cookie that stores customer user IDs.
5
5
  * The cookie is shared across all *.tiquo.app subdomains and persists for 1 year.
6
6
  *
7
- * The cookie is NOT set if the user is logged in with Clerk (dashboard staff).
7
+ * The cookie is NOT set if the user is a dashboard staff member.
8
8
  */
9
9
  /**
10
- * Check if the current user is authenticated via Clerk (dashboard staff).
11
- * If they are, we should NOT set the customer cookie.
10
+ * Check if the current user has an active dashboard staff session.
11
+ * If they do, we should NOT set the customer cookie.
12
12
  */
13
- declare function isClerkAuthenticated(): boolean;
13
+ declare function isDashboardSession(): boolean;
14
14
  /**
15
15
  * Get the list of customer user IDs from the cookie.
16
16
  */
@@ -18,7 +18,7 @@ declare function getCustomerUserIds(): string[];
18
18
  /**
19
19
  * Add a customer user ID to the cookie.
20
20
  * Does nothing if:
21
- * - The user is authenticated via Clerk (dashboard staff)
21
+ * - The user has an active dashboard staff session
22
22
  * - The user ID is already in the cookie
23
23
  * - Running in a non-browser environment
24
24
  *
@@ -30,7 +30,7 @@ declare function addCustomerUserId(userId: string): void;
30
30
  * This fetches the user's email associated with the cookie user IDs.
31
31
  * Results are cached for 5 minutes to avoid repeated API calls.
32
32
  *
33
- * @param organizationId - The Clerk organization ID
33
+ * @param organizationId - The organization ID
34
34
  * @returns Promise with email and optional name fields, or null if not found
35
35
  */
36
36
  declare function getPrefilledEmailFromCookie(organizationId: string): Promise<{
@@ -47,7 +47,7 @@ declare function clearCachedEmail(): void;
47
47
  * Track customer presence when the cookie is detected.
48
48
  * This updates the customer's online status and logs activity.
49
49
  *
50
- * @param organizationId - The Clerk organization ID
50
+ * @param organizationId - The organization ID
51
51
  * @returns Promise with tracking results
52
52
  */
53
53
  declare function trackCustomerPresence(organizationId: string): Promise<{
@@ -439,4 +439,4 @@ declare function useTiquoAuth(auth: TiquoAuth): {
439
439
  onAuthStateChange: (cb: AuthStateChangeCallback) => () => void;
440
440
  };
441
441
 
442
- export { type AuthStateChangeCallback, type GetBookingsOptions, type GetBookingsResult, type GetEnquiriesOptions, type GetEnquiriesResult, type GetOrdersOptions, type GetOrdersResult, type IframeTokenResult, type ProfileUpdateData, type ProfileUpdateResult, type SendOTPResult, TiquoAuth, type TiquoAuthConfig, TiquoAuthError, type TiquoBooking, type TiquoCustomer, type TiquoCustomerEmail, type TiquoCustomerPhone, type TiquoEnquiry, type TiquoOrder, type TiquoOrderItem, type TiquoSession, type TiquoUser, type VerifyOTPResult, addCustomerUserId, clearCachedEmail, TiquoAuth as default, getCustomerUserIds, getPrefilledEmailFromCookie, isClerkAuthenticated, trackCustomerPresence, useTiquoAuth };
442
+ export { type AuthStateChangeCallback, type GetBookingsOptions, type GetBookingsResult, type GetEnquiriesOptions, type GetEnquiriesResult, type GetOrdersOptions, type GetOrdersResult, type IframeTokenResult, type ProfileUpdateData, type ProfileUpdateResult, type SendOTPResult, TiquoAuth, type TiquoAuthConfig, TiquoAuthError, type TiquoBooking, type TiquoCustomer, type TiquoCustomerEmail, type TiquoCustomerPhone, type TiquoEnquiry, type TiquoOrder, type TiquoOrderItem, type TiquoSession, type TiquoUser, type VerifyOTPResult, addCustomerUserId, clearCachedEmail, TiquoAuth as default, getCustomerUserIds, getPrefilledEmailFromCookie, isDashboardSession, trackCustomerPresence, useTiquoAuth };
package/dist/index.d.ts CHANGED
@@ -4,13 +4,13 @@
4
4
  * This module handles setting a cross-subdomain cookie that stores customer user IDs.
5
5
  * The cookie is shared across all *.tiquo.app subdomains and persists for 1 year.
6
6
  *
7
- * The cookie is NOT set if the user is logged in with Clerk (dashboard staff).
7
+ * The cookie is NOT set if the user is a dashboard staff member.
8
8
  */
9
9
  /**
10
- * Check if the current user is authenticated via Clerk (dashboard staff).
11
- * If they are, we should NOT set the customer cookie.
10
+ * Check if the current user has an active dashboard staff session.
11
+ * If they do, we should NOT set the customer cookie.
12
12
  */
13
- declare function isClerkAuthenticated(): boolean;
13
+ declare function isDashboardSession(): boolean;
14
14
  /**
15
15
  * Get the list of customer user IDs from the cookie.
16
16
  */
@@ -18,7 +18,7 @@ declare function getCustomerUserIds(): string[];
18
18
  /**
19
19
  * Add a customer user ID to the cookie.
20
20
  * Does nothing if:
21
- * - The user is authenticated via Clerk (dashboard staff)
21
+ * - The user has an active dashboard staff session
22
22
  * - The user ID is already in the cookie
23
23
  * - Running in a non-browser environment
24
24
  *
@@ -30,7 +30,7 @@ declare function addCustomerUserId(userId: string): void;
30
30
  * This fetches the user's email associated with the cookie user IDs.
31
31
  * Results are cached for 5 minutes to avoid repeated API calls.
32
32
  *
33
- * @param organizationId - The Clerk organization ID
33
+ * @param organizationId - The organization ID
34
34
  * @returns Promise with email and optional name fields, or null if not found
35
35
  */
36
36
  declare function getPrefilledEmailFromCookie(organizationId: string): Promise<{
@@ -47,7 +47,7 @@ declare function clearCachedEmail(): void;
47
47
  * Track customer presence when the cookie is detected.
48
48
  * This updates the customer's online status and logs activity.
49
49
  *
50
- * @param organizationId - The Clerk organization ID
50
+ * @param organizationId - The organization ID
51
51
  * @returns Promise with tracking results
52
52
  */
53
53
  declare function trackCustomerPresence(organizationId: string): Promise<{
@@ -439,4 +439,4 @@ declare function useTiquoAuth(auth: TiquoAuth): {
439
439
  onAuthStateChange: (cb: AuthStateChangeCallback) => () => void;
440
440
  };
441
441
 
442
- export { type AuthStateChangeCallback, type GetBookingsOptions, type GetBookingsResult, type GetEnquiriesOptions, type GetEnquiriesResult, type GetOrdersOptions, type GetOrdersResult, type IframeTokenResult, type ProfileUpdateData, type ProfileUpdateResult, type SendOTPResult, TiquoAuth, type TiquoAuthConfig, TiquoAuthError, type TiquoBooking, type TiquoCustomer, type TiquoCustomerEmail, type TiquoCustomerPhone, type TiquoEnquiry, type TiquoOrder, type TiquoOrderItem, type TiquoSession, type TiquoUser, type VerifyOTPResult, addCustomerUserId, clearCachedEmail, TiquoAuth as default, getCustomerUserIds, getPrefilledEmailFromCookie, isClerkAuthenticated, trackCustomerPresence, useTiquoAuth };
442
+ export { type AuthStateChangeCallback, type GetBookingsOptions, type GetBookingsResult, type GetEnquiriesOptions, type GetEnquiriesResult, type GetOrdersOptions, type GetOrdersResult, type IframeTokenResult, type ProfileUpdateData, type ProfileUpdateResult, type SendOTPResult, TiquoAuth, type TiquoAuthConfig, TiquoAuthError, type TiquoBooking, type TiquoCustomer, type TiquoCustomerEmail, type TiquoCustomerPhone, type TiquoEnquiry, type TiquoOrder, type TiquoOrderItem, type TiquoSession, type TiquoUser, type VerifyOTPResult, addCustomerUserId, clearCachedEmail, TiquoAuth as default, getCustomerUserIds, getPrefilledEmailFromCookie, isDashboardSession, trackCustomerPresence, useTiquoAuth };
package/dist/index.js CHANGED
@@ -27,7 +27,7 @@ __export(index_exports, {
27
27
  default: () => index_default,
28
28
  getCustomerUserIds: () => getCustomerUserIds,
29
29
  getPrefilledEmailFromCookie: () => getPrefilledEmailFromCookie,
30
- isClerkAuthenticated: () => isClerkAuthenticated,
30
+ isDashboardSession: () => isDashboardSession,
31
31
  trackCustomerPresence: () => trackCustomerPresence,
32
32
  useTiquoAuth: () => useTiquoAuth
33
33
  });
@@ -36,9 +36,10 @@ module.exports = __toCommonJS(index_exports);
36
36
  // src/customer-cookie.ts
37
37
  var COOKIE_NAME = "tiquo_customer_user_ids";
38
38
  var COOKIE_MAX_AGE = 31536e3;
39
- function isClerkAuthenticated() {
39
+ var STAFF_SESSION_MARKERS = ["__clerk_db_jwt", "__session"];
40
+ function isDashboardSession() {
40
41
  if (typeof document === "undefined") return false;
41
- return document.cookie.includes("__clerk_db_jwt") || document.cookie.includes("__session");
42
+ return STAFF_SESSION_MARKERS.some((marker) => document.cookie.includes(marker));
42
43
  }
43
44
  function getCustomerUserIds() {
44
45
  if (typeof document === "undefined") return [];
@@ -59,8 +60,8 @@ function getCustomerUserIds() {
59
60
  function addCustomerUserId(userId) {
60
61
  if (typeof document === "undefined") return;
61
62
  if (typeof window === "undefined") return;
62
- if (isClerkAuthenticated()) {
63
- console.log("[Customer Cookie] Skipping - Clerk user detected");
63
+ if (isDashboardSession()) {
64
+ console.log("[Customer Cookie] Skipping - staff session detected");
64
65
  return;
65
66
  }
66
67
  if (!userId || typeof userId !== "string") {
@@ -86,16 +87,15 @@ function addCustomerUserId(userId) {
86
87
  cookieParts.push("Secure");
87
88
  }
88
89
  document.cookie = cookieParts.join("; ");
89
- console.log("[Customer Cookie] Added user ID to cookie:", userId);
90
90
  }
91
- var CONVEX_SITE_URL = "https://edge.tiquo.app";
91
+ var API_BASE_URL = "https://edge.tiquo.app";
92
92
  var cachedEmailData = null;
93
93
  var EMAIL_CACHE_TTL = 5 * 60 * 1e3;
94
94
  async function getPrefilledEmailFromCookie(organizationId) {
95
95
  if (typeof window === "undefined") {
96
96
  return null;
97
97
  }
98
- if (isClerkAuthenticated()) {
98
+ if (isDashboardSession()) {
99
99
  return null;
100
100
  }
101
101
  const userIds = getCustomerUserIds();
@@ -110,7 +110,7 @@ async function getPrefilledEmailFromCookie(organizationId) {
110
110
  };
111
111
  }
112
112
  try {
113
- const response = await fetch(`${CONVEX_SITE_URL}/api/customer-cookie-email`, {
113
+ const response = await fetch(`${API_BASE_URL}/api/customer-cookie-email`, {
114
114
  method: "POST",
115
115
  headers: { "Content-Type": "application/json" },
116
116
  body: JSON.stringify({ userIds, organizationId })
@@ -145,15 +145,15 @@ async function trackCustomerPresence(organizationId) {
145
145
  if (typeof window === "undefined") {
146
146
  return { success: false, error: "Not in browser environment" };
147
147
  }
148
- if (isClerkAuthenticated()) {
149
- return { success: false, error: "Clerk user detected" };
148
+ if (isDashboardSession()) {
149
+ return { success: false, error: "Staff session detected" };
150
150
  }
151
151
  const userIds = getCustomerUserIds();
152
152
  if (userIds.length === 0) {
153
153
  return { success: false, error: "No user IDs in cookie" };
154
154
  }
155
155
  try {
156
- const response = await fetch(`${CONVEX_SITE_URL}/api/customer-presence`, {
156
+ const response = await fetch(`${API_BASE_URL}/api/customer-presence`, {
157
157
  method: "POST",
158
158
  headers: { "Content-Type": "application/json" },
159
159
  body: JSON.stringify({ userIds, organizationId })
@@ -949,7 +949,7 @@ var index_default = TiquoAuth;
949
949
  clearCachedEmail,
950
950
  getCustomerUserIds,
951
951
  getPrefilledEmailFromCookie,
952
- isClerkAuthenticated,
952
+ isDashboardSession,
953
953
  trackCustomerPresence,
954
954
  useTiquoAuth
955
955
  });
package/dist/index.mjs CHANGED
@@ -1,9 +1,10 @@
1
1
  // src/customer-cookie.ts
2
2
  var COOKIE_NAME = "tiquo_customer_user_ids";
3
3
  var COOKIE_MAX_AGE = 31536e3;
4
- function isClerkAuthenticated() {
4
+ var STAFF_SESSION_MARKERS = ["__clerk_db_jwt", "__session"];
5
+ function isDashboardSession() {
5
6
  if (typeof document === "undefined") return false;
6
- return document.cookie.includes("__clerk_db_jwt") || document.cookie.includes("__session");
7
+ return STAFF_SESSION_MARKERS.some((marker) => document.cookie.includes(marker));
7
8
  }
8
9
  function getCustomerUserIds() {
9
10
  if (typeof document === "undefined") return [];
@@ -24,8 +25,8 @@ function getCustomerUserIds() {
24
25
  function addCustomerUserId(userId) {
25
26
  if (typeof document === "undefined") return;
26
27
  if (typeof window === "undefined") return;
27
- if (isClerkAuthenticated()) {
28
- console.log("[Customer Cookie] Skipping - Clerk user detected");
28
+ if (isDashboardSession()) {
29
+ console.log("[Customer Cookie] Skipping - staff session detected");
29
30
  return;
30
31
  }
31
32
  if (!userId || typeof userId !== "string") {
@@ -51,16 +52,15 @@ function addCustomerUserId(userId) {
51
52
  cookieParts.push("Secure");
52
53
  }
53
54
  document.cookie = cookieParts.join("; ");
54
- console.log("[Customer Cookie] Added user ID to cookie:", userId);
55
55
  }
56
- var CONVEX_SITE_URL = "https://edge.tiquo.app";
56
+ var API_BASE_URL = "https://edge.tiquo.app";
57
57
  var cachedEmailData = null;
58
58
  var EMAIL_CACHE_TTL = 5 * 60 * 1e3;
59
59
  async function getPrefilledEmailFromCookie(organizationId) {
60
60
  if (typeof window === "undefined") {
61
61
  return null;
62
62
  }
63
- if (isClerkAuthenticated()) {
63
+ if (isDashboardSession()) {
64
64
  return null;
65
65
  }
66
66
  const userIds = getCustomerUserIds();
@@ -75,7 +75,7 @@ async function getPrefilledEmailFromCookie(organizationId) {
75
75
  };
76
76
  }
77
77
  try {
78
- const response = await fetch(`${CONVEX_SITE_URL}/api/customer-cookie-email`, {
78
+ const response = await fetch(`${API_BASE_URL}/api/customer-cookie-email`, {
79
79
  method: "POST",
80
80
  headers: { "Content-Type": "application/json" },
81
81
  body: JSON.stringify({ userIds, organizationId })
@@ -110,15 +110,15 @@ async function trackCustomerPresence(organizationId) {
110
110
  if (typeof window === "undefined") {
111
111
  return { success: false, error: "Not in browser environment" };
112
112
  }
113
- if (isClerkAuthenticated()) {
114
- return { success: false, error: "Clerk user detected" };
113
+ if (isDashboardSession()) {
114
+ return { success: false, error: "Staff session detected" };
115
115
  }
116
116
  const userIds = getCustomerUserIds();
117
117
  if (userIds.length === 0) {
118
118
  return { success: false, error: "No user IDs in cookie" };
119
119
  }
120
120
  try {
121
- const response = await fetch(`${CONVEX_SITE_URL}/api/customer-presence`, {
121
+ const response = await fetch(`${API_BASE_URL}/api/customer-presence`, {
122
122
  method: "POST",
123
123
  headers: { "Content-Type": "application/json" },
124
124
  body: JSON.stringify({ userIds, organizationId })
@@ -914,7 +914,7 @@ export {
914
914
  index_default as default,
915
915
  getCustomerUserIds,
916
916
  getPrefilledEmailFromCookie,
917
- isClerkAuthenticated,
917
+ isDashboardSession,
918
918
  trackCustomerPresence,
919
919
  useTiquoAuth
920
920
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiquo/dom-package",
3
- "version": "1.1.2",
3
+ "version": "1.2.0",
4
4
  "description": "Tiquo SDK for third-party websites - authentication, customer profiles, orders, bookings, and enquiries",
5
5
  "publishConfig": {
6
6
  "access": "restricted"