@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/module.d.cts DELETED
@@ -1,10 +0,0 @@
1
- import * as _nuxt_schema from '@nuxt/schema';
2
-
3
- interface ModuleOptions {
4
- apiUrl: string;
5
- apiPrefix?: string;
6
- }
7
- declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
8
-
9
- export { _default as default };
10
- export type { ModuleOptions };
package/dist/module.d.mts DELETED
@@ -1,10 +0,0 @@
1
- import * as _nuxt_schema from '@nuxt/schema';
2
-
3
- interface ModuleOptions {
4
- apiUrl: string;
5
- apiPrefix?: string;
6
- }
7
- declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
8
-
9
- export { _default as default };
10
- export type { ModuleOptions };
package/dist/module.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "name": "@enfyra/sdk-nuxt",
3
- "configKey": "enfyraSDK",
4
- "version": "0.3.16",
5
- "builder": {
6
- "@nuxt/module-builder": "0.8.4",
7
- "unbuild": "2.0.0"
8
- }
9
- }
package/dist/module.mjs DELETED
@@ -1,79 +0,0 @@
1
- import { defineNuxtModule, createResolver, addPlugin, addImportsDir, addServerHandler } from '@nuxt/kit';
2
- import { ENFYRA_API_PREFIX } from '../dist/constants/config.mjs';
3
-
4
- const module = defineNuxtModule({
5
- meta: {
6
- name: "@enfyra/sdk-nuxt",
7
- configKey: "enfyraSDK"
8
- },
9
- defaults: {
10
- apiUrl: "",
11
- apiPrefix: ENFYRA_API_PREFIX
12
- },
13
- setup(options, nuxt) {
14
- const normalizedOptions = {
15
- ...options,
16
- apiUrl: typeof options.apiUrl === "string" ? options.apiUrl.replace(/\/+$/, "") : options.apiUrl,
17
- apiPrefix: typeof options.apiPrefix === "string" ? options.apiPrefix.trim() ? "/" + options.apiPrefix.replace(/^\/+|\/+$/g, "").replace(/\/+/g, "/") : ENFYRA_API_PREFIX : ENFYRA_API_PREFIX
18
- };
19
- const apiPrefix = normalizedOptions.apiPrefix;
20
- const { resolve } = createResolver(import.meta.url);
21
- if (!normalizedOptions.apiUrl) {
22
- console.warn(
23
- `[Enfyra SDK Nuxt] Missing required configuration:
24
- - apiUrl is required
25
- Please configure it in your nuxt.config.ts:
26
- enfyraSDK: {
27
- apiUrl: 'https://your-api-url'
28
- }`
29
- );
30
- nuxt.options.runtimeConfig.public.enfyraSDK = {
31
- ...normalizedOptions,
32
- apiPrefix,
33
- configError: true,
34
- configErrorMessage: "Enfyra SDK: apiUrl is required. Please configure it in nuxt.config.ts"
35
- };
36
- } else {
37
- nuxt.options.runtimeConfig.public.enfyraSDK = {
38
- ...normalizedOptions,
39
- apiPrefix
40
- };
41
- }
42
- if (!normalizedOptions.apiUrl) {
43
- addPlugin({
44
- src: resolve("./runtime/plugin/config-error.client"),
45
- mode: "client"
46
- });
47
- }
48
- addImportsDir(resolve("./composables"));
49
- nuxt.hook("prepare:types", ({ declarations, references }) => {
50
- references.push({
51
- path: resolve("./types/nuxt-imports.d.ts")
52
- });
53
- });
54
- addServerHandler({
55
- handler: resolve("./runtime/server/middleware/auth"),
56
- middleware: true
57
- });
58
- addServerHandler({
59
- route: `${apiPrefix}/login`,
60
- handler: resolve("./runtime/server/api/login.post"),
61
- method: "post"
62
- });
63
- addServerHandler({
64
- route: `${apiPrefix}/logout`,
65
- handler: resolve("./runtime/server/api/logout.post"),
66
- method: "post"
67
- });
68
- addServerHandler({
69
- route: "/assets/**",
70
- handler: resolve("./runtime/server/api/all")
71
- });
72
- addServerHandler({
73
- route: `${apiPrefix}/**`,
74
- handler: resolve("./runtime/server/api/all")
75
- });
76
- }
77
- });
78
-
79
- export { module as default };
@@ -1,43 +0,0 @@
1
- import type { Ref } from 'vue';
2
- export interface User {
3
- id: string;
4
- email: string;
5
- isRootAdmin: boolean;
6
- isSystem: boolean;
7
- role?: {
8
- id: string;
9
- name: string;
10
- routePermissions: RoutePermission[];
11
- };
12
- allowedRoutePermissions?: RoutePermission[];
13
- }
14
- export interface RoutePermission {
15
- id: string;
16
- isEnabled: boolean;
17
- allowedUsers?: {
18
- id: string;
19
- }[];
20
- methods: {
21
- id: string;
22
- method: string;
23
- }[];
24
- route: {
25
- id: string;
26
- path: string;
27
- };
28
- }
29
- export interface LoginPayload {
30
- email: string;
31
- password: string;
32
- remember?: boolean;
33
- }
34
- export interface UseEnfyraAuthReturn {
35
- me: Ref<User | null>;
36
- login: (payload: LoginPayload) => Promise<any>;
37
- logout: () => Promise<void>;
38
- fetchUser: (options?: {
39
- fields?: string[];
40
- }) => Promise<void>;
41
- isLoggedIn: Ref<boolean>;
42
- }
43
- //# sourceMappingURL=auth.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/types/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAE9B,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,OAAO,CAAA;IACpB,QAAQ,EAAE,OAAO,CAAA;IACjB,IAAI,CAAC,EAAE;QACL,EAAE,EAAE,MAAM,CAAA;QACV,IAAI,EAAE,MAAM,CAAA;QACZ,gBAAgB,EAAE,eAAe,EAAE,CAAA;KACpC,CAAA;IACD,uBAAuB,CAAC,EAAE,eAAe,EAAE,CAAA;CAC5C;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE,OAAO,CAAA;IAClB,YAAY,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IAC/B,OAAO,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IACzC,KAAK,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;CACpC;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAA;IACpB,KAAK,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IAC9C,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC3B,SAAS,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC7D,UAAU,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;CACzB"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,141 +0,0 @@
1
- export interface EnfyraConfig {
2
- apiUrl: string;
3
- defaultHeaders?: Record<string, string>;
4
- }
5
- export interface ApiError {
6
- message: string;
7
- status?: number;
8
- data?: any;
9
- response?: any;
10
- }
11
- export interface BatchProgress {
12
- /** Current progress percentage (0-100) */
13
- progress: number;
14
- /** Number of completed operations */
15
- completed: number;
16
- /** Total number of operations */
17
- total: number;
18
- /** Number of failed operations */
19
- failed: number;
20
- /** Number of operations currently in progress */
21
- inProgress: number;
22
- /** Estimated time remaining in milliseconds */
23
- estimatedTimeRemaining?: number;
24
- /** Average time per operation in milliseconds */
25
- averageTime?: number;
26
- /** Current batch being processed */
27
- currentBatch: number;
28
- /** Total number of batches */
29
- totalBatches: number;
30
- /** Processing speed (operations per second) */
31
- operationsPerSecond?: number;
32
- /** Detailed results array for completed operations */
33
- results: Array<{
34
- index: number;
35
- status: 'completed' | 'failed';
36
- result?: any;
37
- error?: ApiError;
38
- duration?: number;
39
- }>;
40
- }
41
- interface BaseApiOptions<T> {
42
- method?: 'get' | 'post' | 'put' | 'patch' | 'delete' | 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
43
- body?: any;
44
- query?: Record<string, any>;
45
- headers?: Record<string, string>;
46
- errorContext?: string;
47
- onError?: (error: ApiError, context?: string) => void;
48
- disableBatch?: boolean;
49
- default?: () => T;
50
- /** Enable SSR with useFetch instead of $fetch */
51
- ssr?: boolean;
52
- /** Unique key for useFetch caching */
53
- key?: string;
54
- /** Whether to fetch on server (default: true) - Only applies when ssr: true */
55
- server?: boolean;
56
- /** Don't block navigation (default: false) - Only applies when ssr: true */
57
- lazy?: boolean;
58
- /** Execute immediately (default: true) - Only applies when ssr: true */
59
- immediate?: boolean;
60
- /** Transform the response data - Only applies when ssr: true */
61
- transform?: (data: any) => T;
62
- /** Pick specific fields from response - Only applies when ssr: true */
63
- pick?: string[];
64
- /** Watch reactive sources and refetch when they change - Only applies when ssr: true */
65
- watch?: any[];
66
- /** Deep watch (default: false) - Only applies when ssr: true */
67
- deep?: boolean;
68
- /** Custom cache data retrieval function - Only applies when ssr: true */
69
- getCachedData?: (key: string) => T | null;
70
- /** Enable refresh (default: true) - Only applies when ssr: true */
71
- refresh?: boolean;
72
- /** Auto refresh interval in milliseconds - Only applies when ssr: true */
73
- refreshInterval?: number;
74
- /** Deduplication key - Only applies when ssr: true */
75
- dedupe?: string;
76
- }
77
- interface BatchApiOptions {
78
- /** Batch size for chunking large operations (default: no limit) - Only available for batch operations */
79
- batchSize?: number;
80
- /** Maximum concurrent requests (default: no limit) - Only available for batch operations */
81
- concurrent?: number;
82
- /** Real-time progress callback for batch operations - Only available for batch operations */
83
- onProgress?: (progress: BatchProgress) => void;
84
- }
85
- type ConditionalBatchOptions<T> = T extends {
86
- method?: 'patch' | 'delete' | 'PATCH' | 'DELETE';
87
- } ? BatchApiOptions : T extends {
88
- method?: 'post' | 'POST';
89
- } ? BatchApiOptions : T extends {
90
- method?: undefined;
91
- } ? Partial<BatchApiOptions> : {};
92
- export type ApiOptions<T> = BaseApiOptions<T> & ConditionalBatchOptions<BaseApiOptions<T>>;
93
- export interface BackendError {
94
- success: false;
95
- message: string;
96
- }
97
- export interface BackendErrorExtended extends BackendError {
98
- error: {
99
- code: string;
100
- message: string;
101
- details?: any;
102
- timestamp: string;
103
- path: string;
104
- method: string;
105
- correlationId?: string;
106
- };
107
- }
108
- import type { Ref } from 'vue';
109
- import type { AsyncData } from 'nuxt/app';
110
- export interface UseEnfyraApiSSRReturn<T> extends Omit<AsyncData<T | null, ApiError>, 'pending' | 'error'> {
111
- data: Ref<T | null>;
112
- loading: Ref<boolean>;
113
- error: Ref<ApiError | null>;
114
- refresh: () => Promise<void>;
115
- pending?: Ref<boolean>;
116
- }
117
- interface BaseExecuteOptions {
118
- body?: any;
119
- id?: string | number;
120
- query?: Record<string, any>;
121
- }
122
- interface BatchExecuteOptions {
123
- ids?: (string | number)[];
124
- /** Array of FormData objects for batch upload */
125
- files?: FormData[];
126
- /** Override batch size for this specific execution */
127
- batchSize?: number;
128
- /** Override concurrent limit for this specific execution */
129
- concurrent?: number;
130
- /** Override progress callback for this specific execution */
131
- onProgress?: (progress: BatchProgress) => void;
132
- }
133
- export type ExecuteOptions = BaseExecuteOptions & BatchExecuteOptions;
134
- export interface UseEnfyraApiClientReturn<T> {
135
- data: Ref<T | null>;
136
- error: Ref<ApiError | null>;
137
- pending: Ref<boolean>;
138
- execute: (executeOpts?: ExecuteOptions) => Promise<T | T[] | null>;
139
- }
140
- export * from './auth';
141
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAA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AC,QAAQ,GAAG,IAAI,CAAC,CAAC;IAC5B,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7B,OAAO,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;CACxB;AAED,UAAU,kBAAkB;IAC1B,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC7B;AAED,UAAU,mBAAmB;IAC3B,GAAG,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAC1B,iDAAiD;IACjD,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;IACnB,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6DAA6D;IAC7D,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,IAAI,CAAC;CAChD;AAQD,MAAM,MAAM,cAAc,GAAG,kBAAkB,GAAG,mBAAmB,CAAC;AAEtE,MAAM,WAAW,wBAAwB,CAAC,CAAC;IACzC,IAAI,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IACpB,KAAK,EAAE,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;IAC5B,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACtB,OAAO,EAAE,CAAC,WAAW,CAAC,EAAE,cAAc,KAAK,OAAO,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;CACpE;AAGD,cAAc,QAAQ,CAAC"}
@@ -1 +0,0 @@
1
- export * from './auth';
package/dist/types.d.mts DELETED
@@ -1,7 +0,0 @@
1
- import type { NuxtModule } from '@nuxt/schema'
2
-
3
- import type { default as Module } from './module.js'
4
-
5
- export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
-
7
- export { default } from './module.js'
package/dist/types.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import type { NuxtModule } from '@nuxt/schema'
2
-
3
- import type { default as Module } from './module'
4
-
5
- export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
-
7
- export { default } from './module'
File without changes
@@ -1,16 +0,0 @@
1
- import { ref } from "vue";
2
- const config = ref({
3
- apiUrl: "",
4
- defaultHeaders: {}
5
- });
6
- export function useEnfyraConfig() {
7
- const setConfig = (newConfig) => {
8
- config.value = { ...config.value, ...newConfig };
9
- };
10
- const getConfig = () => config.value;
11
- return {
12
- setConfig,
13
- getConfig
14
- };
15
- }
16
- export { config };
@@ -1,8 +0,0 @@
1
- export declare function $fetch<T = any>(path: string, options?: {
2
- method?: string;
3
- body?: any;
4
- headers?: Record<string, string>;
5
- query?: Record<string, any>;
6
- baseURL?: string;
7
- }): Promise<T>;
8
- //# sourceMappingURL=http.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/utils/http.ts"],"names":[],"mappings":"AAAA,wBAAsB,MAAM,CAAC,CAAC,GAAG,GAAG,EAClC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;IACP,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;CACb,GACL,OAAO,CAAC,CAAC,CAAC,CAoEZ"}
@@ -1,57 +0,0 @@
1
- export async function $fetch(path, options = {}) {
2
- const { method = "GET", body, headers: optionHeaders = {}, query = {}, baseURL, } = options;
3
- if (!baseURL) {
4
- throw new Error('baseURL is required for $fetch');
5
- }
6
- const url = new URL(path.startsWith("/") ? path.slice(1) : path, baseURL.endsWith("/") ? baseURL : `${baseURL}/`);
7
- Object.entries(query).forEach(([key, value]) => {
8
- if (value !== undefined && value !== null) {
9
- if (typeof value === 'object') {
10
- url.searchParams.append(key, JSON.stringify(value));
11
- }
12
- else {
13
- url.searchParams.append(key, String(value));
14
- }
15
- }
16
- });
17
- const headers = {
18
- "Content-Type": "application/json",
19
- ...optionHeaders,
20
- };
21
- const fetchOptions = {
22
- method: method.toUpperCase(),
23
- headers,
24
- };
25
- if (body && method.toUpperCase() !== "GET") {
26
- if (body instanceof FormData) {
27
- delete headers["Content-Type"]; // Let browser set boundary for FormData
28
- fetchOptions.body = body;
29
- }
30
- else {
31
- fetchOptions.body = JSON.stringify(body);
32
- }
33
- }
34
- try {
35
- const response = await fetch(url.toString(), fetchOptions);
36
- if (!response.ok) {
37
- let errorData;
38
- try {
39
- errorData = await response.json();
40
- }
41
- catch {
42
- errorData = { message: response.statusText };
43
- }
44
- throw { response: { data: errorData } };
45
- }
46
- const contentType = response.headers.get("content-type");
47
- if (contentType?.includes("application/json")) {
48
- return await response.json();
49
- }
50
- else {
51
- return (await response.text());
52
- }
53
- }
54
- catch (error) {
55
- throw error;
56
- }
57
- }
@@ -1,61 +0,0 @@
1
- export async function $fetch(path, options = {}) {
2
- const {
3
- method = "GET",
4
- body,
5
- headers: optionHeaders = {},
6
- query = {},
7
- baseURL
8
- } = options;
9
- if (!baseURL) {
10
- throw new Error("baseURL is required for $fetch");
11
- }
12
- const url = new URL(
13
- path.startsWith("/") ? path.slice(1) : path,
14
- baseURL.endsWith("/") ? baseURL : `${baseURL}/`
15
- );
16
- Object.entries(query).forEach(([key, value]) => {
17
- if (value !== void 0 && value !== null) {
18
- if (typeof value === "object") {
19
- url.searchParams.append(key, JSON.stringify(value));
20
- } else {
21
- url.searchParams.append(key, String(value));
22
- }
23
- }
24
- });
25
- const headers = {
26
- "Content-Type": "application/json",
27
- ...optionHeaders
28
- };
29
- const fetchOptions = {
30
- method: method.toUpperCase(),
31
- headers
32
- };
33
- if (body && method.toUpperCase() !== "GET") {
34
- if (body instanceof FormData) {
35
- delete headers["Content-Type"];
36
- fetchOptions.body = body;
37
- } else {
38
- fetchOptions.body = JSON.stringify(body);
39
- }
40
- }
41
- try {
42
- const response = await fetch(url.toString(), fetchOptions);
43
- if (!response.ok) {
44
- let errorData;
45
- try {
46
- errorData = await response.json();
47
- } catch {
48
- errorData = { message: response.statusText };
49
- }
50
- throw { response: { data: errorData } };
51
- }
52
- const contentType = response.headers.get("content-type");
53
- if (contentType?.includes("application/json")) {
54
- return await response.json();
55
- } else {
56
- return await response.text();
57
- }
58
- } catch (error) {
59
- throw error;
60
- }
61
- }
File without changes
@@ -1,14 +0,0 @@
1
- import { proxyRequest } from "h3";
2
- import { useRuntimeConfig } from "#imports";
3
- import { ENFYRA_API_PREFIX } from "../../constants/config";
4
- import { normalizeUrl } from "../../utils/url";
5
- export function proxyToAPI(event, customPath) {
6
- const config = useRuntimeConfig();
7
- const apiPrefix = config.public?.enfyraSDK?.apiPrefix || ENFYRA_API_PREFIX;
8
- const rawPath = customPath || event.path.replace(new RegExp(`^${apiPrefix}`), "");
9
- const targetUrl = normalizeUrl(config.public?.enfyraSDK?.apiUrl, rawPath);
10
- const headers = event.context.proxyHeaders || {};
11
- return proxyRequest(event, targetUrl, {
12
- headers
13
- });
14
- }
File without changes
@@ -1,69 +0,0 @@
1
- import { setCookie, getCookie, deleteCookie } from "h3";
2
- import { $fetch } from "ofetch";
3
- import {
4
- ACCESS_TOKEN_KEY,
5
- REFRESH_TOKEN_KEY,
6
- EXP_TIME_KEY
7
- } from "../../constants/auth";
8
- import { normalizeUrl } from "../../utils/url";
9
- export function decodeJWT(token) {
10
- try {
11
- const parts = token.split(".");
12
- if (parts.length !== 3) {
13
- return null;
14
- }
15
- const payload = parts[1];
16
- const decodedPayload = Buffer.from(payload, "base64url").toString("utf-8");
17
- return JSON.parse(decodedPayload);
18
- } catch (error) {
19
- console.warn("Failed to decode JWT:", error);
20
- return null;
21
- }
22
- }
23
- export function isAccessTokenExpired(accessToken) {
24
- const decoded = decodeJWT(accessToken);
25
- if (!decoded || !decoded.exp) {
26
- return true;
27
- }
28
- const expirationTime = decoded.exp * 1e3;
29
- return Date.now() >= expirationTime;
30
- }
31
- export function validateTokens(event) {
32
- const accessToken = getCookie(event, ACCESS_TOKEN_KEY);
33
- const refreshToken = getCookie(event, REFRESH_TOKEN_KEY);
34
- if (accessToken && !isAccessTokenExpired(accessToken)) {
35
- return { accessToken, needsRefresh: false };
36
- } else if (refreshToken && (!accessToken || isAccessTokenExpired(accessToken))) {
37
- return { accessToken: null, needsRefresh: true };
38
- }
39
- return { accessToken: null, needsRefresh: false };
40
- }
41
- export async function refreshAccessToken(event, refreshToken, apiUrl) {
42
- try {
43
- const response = await $fetch(normalizeUrl(apiUrl, "/auth/refresh-token"), {
44
- method: "POST",
45
- body: { refreshToken }
46
- });
47
- const {
48
- accessToken: newAccessToken,
49
- refreshToken: newRefreshToken,
50
- expTime: newExpTime
51
- } = response;
52
- const cookieOptions = {
53
- httpOnly: true,
54
- secure: true,
55
- sameSite: "lax",
56
- path: "/"
57
- };
58
- setCookie(event, ACCESS_TOKEN_KEY, newAccessToken, cookieOptions);
59
- setCookie(event, REFRESH_TOKEN_KEY, newRefreshToken, cookieOptions);
60
- setCookie(event, EXP_TIME_KEY, String(newExpTime), cookieOptions);
61
- return newAccessToken;
62
- } catch (error) {
63
- console.warn("Token refresh failed:", error);
64
- deleteCookie(event, ACCESS_TOKEN_KEY);
65
- deleteCookie(event, REFRESH_TOKEN_KEY);
66
- deleteCookie(event, EXP_TIME_KEY);
67
- throw error;
68
- }
69
- }
@@ -1,12 +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 declare function normalizeUrl(...segments: (string | undefined | null)[]): string;
7
- /**
8
- * Joins URL paths safely, avoiding double slashes
9
- */
10
- export declare function joinUrlPath(...paths: (string | undefined | null)[]): string;
11
- export declare function getAppUrl(): string;
12
- //# sourceMappingURL=url.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/utils/url.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,QAAQ,EAAE,CAAC,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC,EAAE,GAAG,MAAM,CAmB/E;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,KAAK,EAAE,CAAC,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC,EAAE,GAAG,MAAM,CAQ3E;AAED,wBAAgB,SAAS,IAAI,MAAM,CA8ClC"}