una-nuxt-module 3.0.3 → 3.0.5

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/module.d.mts CHANGED
@@ -4,6 +4,7 @@ import { IUnaxtModuleOptions } from '../dist/runtime/types/index.js';
4
4
  declare const _default: _nuxt_schema.NuxtModule<IUnaxtModuleOptions, IUnaxtModuleOptions, false>;
5
5
 
6
6
  interface ModulePublicRuntimeConfig {
7
+ apiBaseUrl: string;
7
8
  unaxt: IUnaxtModuleOptions;
8
9
  }
9
10
  declare module '@nuxt/schema' {
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "una-nuxt-module",
3
- "version": "3.0.3",
3
+ "version": "3.0.5",
4
4
  "configKey": "unaxt",
5
5
  "compatibility": {
6
6
  "nuxt": ">=4.0.0"
package/dist/module.mjs CHANGED
@@ -167,7 +167,7 @@ function addTemplates() {
167
167
  }
168
168
 
169
169
  const name = "una-nuxt-module";
170
- const version = "3.0.3";
170
+ const version = "3.0.5";
171
171
 
172
172
  const module$1 = defineNuxtModule({
173
173
  meta: {
@@ -20,19 +20,18 @@ export const useAuthorization = () => {
20
20
  if (authStore.authData) {
21
21
  authStore.authData.accessToken = token;
22
22
  }
23
- const AUTHORIZATION_API = runtimeConfig.public.unaxt.apis.authorization;
23
+ const baseURL = runtimeConfig.public.apiBaseUrl;
24
+ const modulo = runtimeConfig.public.unaxt.authorization.modulo;
25
+ const endpoint = `/api/recurso/modulo/${modulo}`;
24
26
  try {
25
- const response = await $fetch(
26
- AUTHORIZATION_API.endpoints.getResources,
27
- {
28
- baseURL: AUTHORIZATION_API.baseUrl,
29
- method: "GET",
30
- headers: {
31
- // Se agrega el token de la sesión
32
- Authorization: `Bearer ${token}`
33
- }
27
+ const response = await $fetch(endpoint, {
28
+ baseURL,
29
+ method: "GET",
30
+ headers: {
31
+ // Se agrega el token de la sesión
32
+ Authorization: `Bearer ${token}`
34
33
  }
35
- );
34
+ });
36
35
  if (response) return response.data;
37
36
  } catch (error) {
38
37
  console.error("Error obteniendo recursos:", error);
@@ -1,5 +1,4 @@
1
1
  import { defineNuxtRouteMiddleware, useNuxtApp } from "#app";
2
- import { upperFirst } from "scule";
3
2
  import { useAuthStore } from "../stores/auth.js";
4
3
  import { useAuthorization } from "../composables/useAuthorization.js";
5
4
  export default defineNuxtRouteMiddleware(async () => {
@@ -19,11 +18,12 @@ export default defineNuxtRouteMiddleware(async () => {
19
18
  const resources = await authorization.getResources(token);
20
19
  const getUserInfo = () => {
21
20
  if (authResponse?.email) {
22
- const [name, lastName] = authResponse.email.split(".");
21
+ const email = Array.isArray(authResponse?.email) ? authResponse?.email[0] : authResponse?.email;
22
+ const [name, lastName] = email.toUpperCase().split(".");
23
23
  return {
24
- name: upperFirst(name),
25
- lastName: upperFirst(lastName),
26
- fullName: upperFirst(name) + " " + upperFirst(lastName)
24
+ name,
25
+ lastName,
26
+ fullName: name + " " + lastName
27
27
  };
28
28
  }
29
29
  };
@@ -9,14 +9,15 @@ export default defineNuxtPlugin(() => {
9
9
  const auth = AsgardeoSPAClient.getInstance();
10
10
  const runtimeConfig = useRuntimeConfig();
11
11
  const ssoConfig = runtimeConfig.public.unaxt.sso;
12
+ const DEFAULT_SCOPES = ["openid", "profile", "email"];
13
+ const scope = ssoConfig.scopes !== "" ? ssoConfig.scopes.split("|") : DEFAULT_SCOPES;
12
14
  const config = {
13
15
  baseUrl: ssoConfig.baseUrl,
14
16
  clientID: ssoConfig.clientId,
15
17
  clientSecret: ssoConfig.clientSecret,
16
- scope: ssoConfig.scope?.split("|") || [],
18
+ scope,
17
19
  signInRedirectURL: ssoConfig.signInRedirectUrl,
18
- signOutRedirectURL: ssoConfig.signOutRedirectUrl,
19
- validateIDToken: ssoConfig.validateIdToken
20
+ signOutRedirectURL: ssoConfig.signOutRedirectUrl
20
21
  };
21
22
  auth?.initialize(config);
22
23
  auth?.signIn();
@@ -35,34 +35,13 @@ export interface IUnaxtModuleOptions {
35
35
  /**
36
36
  * Lista de permisos o alcances solicitados.
37
37
  */
38
- scope: string;
39
- /**
40
- * Indica si se debe validar el IDToken.
41
- */
42
- validateIdToken?: boolean;
38
+ scopes: string;
43
39
  };
44
40
  /**
45
- * Configuración de las APIs utilizadas por el módulo.
41
+ * Configuración de la API de autorización.
46
42
  */
47
- apis: {
48
- /**
49
- * Configuración de la API de autorización.
50
- */
51
- authorization: {
52
- /**
53
- * URL base de la API de autorización.
54
- */
55
- baseUrl: string;
56
- /**
57
- * Endpoints disponibles en la API de autorización.
58
- */
59
- endpoints: {
60
- /**
61
- * Endpoint para obtener los recursos disponibles.
62
- */
63
- getResources: string;
64
- };
65
- };
43
+ authorization: {
44
+ modulo: string;
66
45
  };
67
46
  /**
68
47
  * Configuración general del módulo.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "una-nuxt-module",
3
- "version": "3.0.3",
3
+ "version": "3.0.5",
4
4
  "description": "Módulo Nuxt para desarrollo CGI",
5
5
  "repository": {
6
6
  "type": "git",