propro-utils 1.6.4 → 1.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "propro-utils",
3
- "version": "1.6.4",
3
+ "version": "1.6.6",
4
4
  "description": "Auth middleware for propro-auth",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -101,7 +101,17 @@ const setAuthCookies = async (res, tokens, account, user, appUrl) => {
101
101
  // Domain configuration
102
102
  let domain;
103
103
  try {
104
- domain = appUrl ? new URL(appUrl).hostname : undefined;
104
+ // Handle URLs that don't include the protocol
105
+ let processedAppUrl = appUrl;
106
+ if (
107
+ appUrl &&
108
+ !appUrl.startsWith("http://") &&
109
+ !appUrl.startsWith("https://")
110
+ ) {
111
+ processedAppUrl = `https://${appUrl}`;
112
+ }
113
+
114
+ domain = processedAppUrl ? new URL(processedAppUrl).hostname : undefined;
105
115
  if (domain?.includes("mapmap.app")) {
106
116
  domain = ".mapmap.app";
107
117
  }
@@ -109,7 +119,12 @@ const setAuthCookies = async (res, tokens, account, user, appUrl) => {
109
119
  domain = undefined;
110
120
  }
111
121
  if (domain?.includes("propro.so")) {
112
- domain = "propro.so";
122
+ // Handle both main domain and subdomains of propro.so
123
+ if (domain.startsWith("short.")) {
124
+ domain = "short.propro.so";
125
+ } else {
126
+ domain = "propro.so";
127
+ }
113
128
  }
114
129
  } catch (error) {
115
130
  console.error("Invalid appUrl:", { error, appUrl });
@@ -211,13 +226,31 @@ const setAuthCookies = async (res, tokens, account, user, appUrl) => {
211
226
  const clearAuthCookies = async (res, appUrl) => {
212
227
  let domain;
213
228
  try {
214
- domain = appUrl ? new URL(appUrl).hostname : undefined;
229
+ // Handle URLs that don't include the protocol
230
+ let processedAppUrl = appUrl;
231
+ if (
232
+ appUrl &&
233
+ !appUrl.startsWith("http://") &&
234
+ !appUrl.startsWith("https://")
235
+ ) {
236
+ processedAppUrl = `https://${appUrl}`;
237
+ }
238
+
239
+ domain = processedAppUrl ? new URL(processedAppUrl).hostname : undefined;
215
240
  if (domain?.includes("mapmap.app")) {
216
241
  domain = ".mapmap.app";
217
242
  }
218
243
  if (domain?.includes("localhost")) {
219
244
  domain = undefined;
220
245
  }
246
+ if (domain?.includes("propro.so")) {
247
+ // Handle both main domain and subdomains of propro.so
248
+ if (domain.startsWith("short.")) {
249
+ domain = "short.propro.so";
250
+ } else {
251
+ domain = "propro.so";
252
+ }
253
+ }
221
254
  } catch (error) {
222
255
  console.error("Invalid appUrl:", error);
223
256
  domain = undefined;