@enfyra/sdk-nuxt 0.3.16 → 0.3.18

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.
Files changed (47) hide show
  1. package/index.ts +1 -1
  2. package/module.d.ts +2 -2
  3. package/{src/module.ts → module.ts} +10 -9
  4. package/package.json +24 -24
  5. package/src/composables/useEnfyraAuth.ts +1 -1
  6. package/src/utils/url.ts +4 -11
  7. package/dist/composables/useEnfyraApi.d.ts +0 -8
  8. package/dist/composables/useEnfyraApi.d.ts.map +0 -1
  9. package/dist/composables/useEnfyraApi.js +0 -363
  10. package/dist/composables/useEnfyraApi.mjs +0 -345
  11. package/dist/composables/useEnfyraAuth.d.ts +0 -89
  12. package/dist/composables/useEnfyraAuth.d.ts.map +0 -1
  13. package/dist/composables/useEnfyraAuth.js +0 -77
  14. package/dist/composables/useEnfyraAuth.mjs +0 -81
  15. package/dist/constants/auth.d.ts +0 -0
  16. package/dist/constants/auth.mjs +0 -3
  17. package/dist/constants/config.d.ts +0 -2
  18. package/dist/constants/config.d.ts.map +0 -1
  19. package/dist/constants/config.js +0 -1
  20. package/dist/constants/config.mjs +0 -1
  21. package/dist/module.cjs +0 -82
  22. package/dist/module.d.cts +0 -10
  23. package/dist/module.d.mts +0 -10
  24. package/dist/module.json +0 -9
  25. package/dist/module.mjs +0 -79
  26. package/dist/types/auth.d.ts +0 -43
  27. package/dist/types/auth.d.ts.map +0 -1
  28. package/dist/types/auth.js +0 -1
  29. package/dist/types/index.d.ts +0 -141
  30. package/dist/types/index.d.ts.map +0 -1
  31. package/dist/types/index.js +0 -1
  32. package/dist/types.d.mts +0 -7
  33. package/dist/types.d.ts +0 -7
  34. package/dist/utils/config.d.ts +0 -0
  35. package/dist/utils/config.mjs +0 -16
  36. package/dist/utils/http.d.ts +0 -8
  37. package/dist/utils/http.d.ts.map +0 -1
  38. package/dist/utils/http.js +0 -57
  39. package/dist/utils/http.mjs +0 -61
  40. package/dist/utils/server/proxy.d.ts +0 -0
  41. package/dist/utils/server/proxy.mjs +0 -14
  42. package/dist/utils/server/refreshToken.d.ts +0 -0
  43. package/dist/utils/server/refreshToken.mjs +0 -69
  44. package/dist/utils/url.d.ts +0 -12
  45. package/dist/utils/url.d.ts.map +0 -1
  46. package/dist/utils/url.js +0 -77
  47. package/dist/utils/url.mjs +0 -56
package/dist/utils/url.js DELETED
@@ -1,77 +0,0 @@
1
- /**
2
- * Normalizes URL segments to avoid double slashes when concatenating
3
- * Removes trailing slashes from base URL and leading slashes from path segments
4
- * Also normalizes multiple consecutive slashes within segments
5
- */
6
- export function normalizeUrl(...segments) {
7
- const validSegments = segments.filter((s) => Boolean(s));
8
- if (validSegments.length === 0)
9
- return '';
10
- // First segment is the base URL - remove trailing slashes
11
- let result = validSegments[0].replace(/\/+$/, '');
12
- // For remaining segments, remove leading and trailing slashes, normalize internal slashes, then join
13
- for (let i = 1; i < validSegments.length; i++) {
14
- const segment = validSegments[i]
15
- .replace(/^\/+/, '') // Remove leading slashes
16
- .replace(/\/+$/, '') // Remove trailing slashes
17
- .replace(/\/+/g, '/'); // Normalize multiple consecutive slashes to single slash
18
- if (segment) {
19
- result += '/' + segment;
20
- }
21
- }
22
- return result;
23
- }
24
- /**
25
- * Joins URL paths safely, avoiding double slashes
26
- */
27
- export function joinUrlPath(...paths) {
28
- const validPaths = paths.filter((p) => Boolean(p));
29
- if (validPaths.length === 0)
30
- return '';
31
- return validPaths
32
- .map(path => path.replace(/^\/+/, '').replace(/\/+$/, ''))
33
- .filter(Boolean)
34
- .join('/');
35
- }
36
- export function getAppUrl() {
37
- if (process.client && typeof window !== 'undefined') {
38
- return window.location.origin;
39
- }
40
- if (process.server) {
41
- try {
42
- let useRequestHeaders;
43
- let useRequestURL;
44
- try {
45
- const imports = eval('require("#imports")');
46
- useRequestHeaders = imports.useRequestHeaders;
47
- useRequestURL = imports.useRequestURL;
48
- }
49
- catch (e) {
50
- return '';
51
- }
52
- try {
53
- const url = useRequestURL();
54
- if (url) {
55
- return `${url.protocol}//${url.host}`;
56
- }
57
- }
58
- catch (e) {
59
- }
60
- const headers = useRequestHeaders();
61
- const forwarded = headers['x-forwarded-host'] || headers['x-forwarded-server'];
62
- const protocol = headers['x-forwarded-proto'] || 'https';
63
- if (forwarded) {
64
- return `${protocol}://${forwarded}`;
65
- }
66
- const host = headers.host;
67
- if (host) {
68
- const isHttps = protocol === 'https' || headers['x-forwarded-ssl'] === 'on';
69
- return `${isHttps ? 'https' : 'http'}://${host}`;
70
- }
71
- }
72
- catch (e) {
73
- console.warn('[Enfyra SDK] Could not auto-detect app URL on server:', e);
74
- }
75
- }
76
- return '';
77
- }
@@ -1,56 +0,0 @@
1
- export function normalizeUrl(...segments) {
2
- const validSegments = segments.filter((s) => Boolean(s));
3
- if (validSegments.length === 0) return "";
4
- let result = validSegments[0].replace(/\/+$/, "");
5
- for (let i = 1; i < validSegments.length; i++) {
6
- const segment = validSegments[i].replace(/^\/+/, "").replace(/\/+$/, "").replace(/\/+/g, "/");
7
- if (segment) {
8
- result += "/" + segment;
9
- }
10
- }
11
- return result;
12
- }
13
- export function joinUrlPath(...paths) {
14
- const validPaths = paths.filter((p) => Boolean(p));
15
- if (validPaths.length === 0) return "";
16
- return validPaths.map((path) => path.replace(/^\/+/, "").replace(/\/+$/, "")).filter(Boolean).join("/");
17
- }
18
- export function getAppUrl() {
19
- if (process.client && typeof window !== "undefined") {
20
- return window.location.origin;
21
- }
22
- if (process.server) {
23
- try {
24
- let useRequestHeaders;
25
- let useRequestURL;
26
- try {
27
- const imports = eval('require("#imports")');
28
- useRequestHeaders = imports.useRequestHeaders;
29
- useRequestURL = imports.useRequestURL;
30
- } catch (e) {
31
- return "";
32
- }
33
- try {
34
- const url = useRequestURL();
35
- if (url) {
36
- return `${url.protocol}//${url.host}`;
37
- }
38
- } catch (e) {
39
- }
40
- const headers = useRequestHeaders();
41
- const forwarded = headers["x-forwarded-host"] || headers["x-forwarded-server"];
42
- const protocol = headers["x-forwarded-proto"] || "https";
43
- if (forwarded) {
44
- return `${protocol}://${forwarded}`;
45
- }
46
- const host = headers.host;
47
- if (host) {
48
- const isHttps = protocol === "https" || headers["x-forwarded-ssl"] === "on";
49
- return `${isHttps ? "https" : "http"}://${host}`;
50
- }
51
- } catch (e) {
52
- console.warn("[Enfyra SDK] Could not auto-detect app URL on server:", e);
53
- }
54
- }
55
- return "";
56
- }