@sonhoseong/mfa-lib 1.0.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.
Files changed (98) hide show
  1. package/README.md +172 -0
  2. package/dist/components/button/ScrollTopButton.d.ts +5 -0
  3. package/dist/components/button/ScrollTopButton.d.ts.map +1 -0
  4. package/dist/components/button/ScrollTopButton.js +28 -0
  5. package/dist/components/button/index.d.ts +3 -0
  6. package/dist/components/button/index.d.ts.map +1 -0
  7. package/dist/components/button/index.js +2 -0
  8. package/dist/components/button/types/index.d.ts +10 -0
  9. package/dist/components/button/types/index.d.ts.map +1 -0
  10. package/dist/components/button/types/index.js +1 -0
  11. package/dist/components/error/ErrorBoundary.d.ts +25 -0
  12. package/dist/components/error/ErrorBoundary.d.ts.map +1 -0
  13. package/dist/components/error/ErrorBoundary.js +130 -0
  14. package/dist/components/error/index.d.ts +2 -0
  15. package/dist/components/error/index.d.ts.map +1 -0
  16. package/dist/components/error/index.js +1 -0
  17. package/dist/components/index.d.ts +6 -0
  18. package/dist/components/index.d.ts.map +1 -0
  19. package/dist/components/index.js +10 -0
  20. package/dist/components/loading/GlobalLoading.d.ts +12 -0
  21. package/dist/components/loading/GlobalLoading.d.ts.map +1 -0
  22. package/dist/components/loading/GlobalLoading.js +84 -0
  23. package/dist/components/loading/index.d.ts +2 -0
  24. package/dist/components/loading/index.d.ts.map +1 -0
  25. package/dist/components/loading/index.js +1 -0
  26. package/dist/components/modal/ModalContainer.d.ts +8 -0
  27. package/dist/components/modal/ModalContainer.d.ts.map +1 -0
  28. package/dist/components/modal/ModalContainer.js +161 -0
  29. package/dist/components/modal/ModalContext.d.ts +43 -0
  30. package/dist/components/modal/ModalContext.d.ts.map +1 -0
  31. package/dist/components/modal/ModalContext.js +78 -0
  32. package/dist/components/modal/index.d.ts +4 -0
  33. package/dist/components/modal/index.d.ts.map +1 -0
  34. package/dist/components/modal/index.js +2 -0
  35. package/dist/components/toast/ToastContainer.d.ts +12 -0
  36. package/dist/components/toast/ToastContainer.d.ts.map +1 -0
  37. package/dist/components/toast/ToastContainer.js +125 -0
  38. package/dist/components/toast/ToastContext.d.ts +40 -0
  39. package/dist/components/toast/ToastContext.d.ts.map +1 -0
  40. package/dist/components/toast/ToastContext.js +56 -0
  41. package/dist/components/toast/index.d.ts +4 -0
  42. package/dist/components/toast/index.d.ts.map +1 -0
  43. package/dist/components/toast/index.js +2 -0
  44. package/dist/hooks/index.d.ts +11 -0
  45. package/dist/hooks/index.d.ts.map +1 -0
  46. package/dist/hooks/index.js +17 -0
  47. package/dist/hooks/use-auth.d.ts +38 -0
  48. package/dist/hooks/use-auth.d.ts.map +1 -0
  49. package/dist/hooks/use-auth.js +117 -0
  50. package/dist/hooks/use-error-notification.d.ts +29 -0
  51. package/dist/hooks/use-error-notification.d.ts.map +1 -0
  52. package/dist/hooks/use-error-notification.js +91 -0
  53. package/dist/hooks/use-global-loading.d.ts +16 -0
  54. package/dist/hooks/use-global-loading.d.ts.map +1 -0
  55. package/dist/hooks/use-global-loading.js +72 -0
  56. package/dist/hooks/use-initialize.d.ts +26 -0
  57. package/dist/hooks/use-initialize.d.ts.map +1 -0
  58. package/dist/hooks/use-initialize.js +104 -0
  59. package/dist/hooks/use-modal.d.ts +39 -0
  60. package/dist/hooks/use-modal.d.ts.map +1 -0
  61. package/dist/hooks/use-modal.js +83 -0
  62. package/dist/hooks/use-navigate.d.ts +34 -0
  63. package/dist/hooks/use-navigate.d.ts.map +1 -0
  64. package/dist/hooks/use-navigate.js +89 -0
  65. package/dist/hooks/use-track-history.d.ts +33 -0
  66. package/dist/hooks/use-track-history.d.ts.map +1 -0
  67. package/dist/hooks/use-track-history.js +150 -0
  68. package/dist/index.d.ts +12 -0
  69. package/dist/index.d.ts.map +1 -0
  70. package/dist/index.js +17 -0
  71. package/dist/network/axios-factory.d.ts +61 -0
  72. package/dist/network/axios-factory.d.ts.map +1 -0
  73. package/dist/network/axios-factory.js +119 -0
  74. package/dist/network/index.d.ts +5 -0
  75. package/dist/network/index.d.ts.map +1 -0
  76. package/dist/network/index.js +4 -0
  77. package/dist/network/supabase-axios.d.ts +62 -0
  78. package/dist/network/supabase-axios.d.ts.map +1 -0
  79. package/dist/network/supabase-axios.js +74 -0
  80. package/dist/store/index.d.ts +2 -0
  81. package/dist/store/index.d.ts.map +1 -0
  82. package/dist/store/index.js +1 -0
  83. package/dist/store/store-access.d.ts +48 -0
  84. package/dist/store/store-access.d.ts.map +1 -0
  85. package/dist/store/store-access.js +131 -0
  86. package/dist/types/index.d.ts +58 -0
  87. package/dist/types/index.d.ts.map +1 -0
  88. package/dist/types/index.js +5 -0
  89. package/dist/types/service.d.ts +17 -0
  90. package/dist/types/service.d.ts.map +1 -0
  91. package/dist/types/service.js +31 -0
  92. package/dist/utils/index.d.ts +2 -0
  93. package/dist/utils/index.d.ts.map +1 -0
  94. package/dist/utils/index.js +1 -0
  95. package/dist/utils/storage.d.ts +27 -0
  96. package/dist/utils/storage.d.ts.map +1 -0
  97. package/dist/utils/storage.js +78 -0
  98. package/package.json +27 -0
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Host Store 접근 유틸리티 - KOMCA 패턴
3
+ * Remote 앱에서 Host의 Redux Store에 접근
4
+ */
5
+ import { User, HostStore, HostRootState } from '../types';
6
+ import { Reducer } from '@reduxjs/toolkit';
7
+ /**
8
+ * Host Store 가져오기
9
+ */
10
+ export declare const getHostStore: () => HostStore | undefined;
11
+ /**
12
+ * Host Store 상태 가져오기
13
+ */
14
+ export declare const getHostState: () => HostRootState | null;
15
+ /**
16
+ * 현재 로그인된 사용자 가져오기
17
+ */
18
+ export declare const getCurrentUser: () => User | null;
19
+ /**
20
+ * accessToken 가져오기
21
+ */
22
+ export declare const getAccessToken: () => string;
23
+ /**
24
+ * 인증 여부 확인
25
+ */
26
+ export declare const isAuthenticated: () => boolean;
27
+ /**
28
+ * 현재 서비스 가져오기
29
+ */
30
+ export declare const getCurrentService: () => string;
31
+ /**
32
+ * 로딩 상태 확인
33
+ */
34
+ export declare const isLoading: () => boolean;
35
+ /**
36
+ * Host Store에 액션 디스패치
37
+ */
38
+ export declare const dispatchToHost: (action: any) => void;
39
+ /**
40
+ * Host Store 상태 변경 구독
41
+ */
42
+ export declare const subscribeToHost: (listener: () => void) => (() => void);
43
+ /**
44
+ * 동적으로 Reducer 주입 (Remote 앱에서 자체 상태 관리 시 사용)
45
+ * 주의: 이 함수는 Host의 injectReducer를 호출해야 함
46
+ */
47
+ export declare const injectReducerToHost: (key: string, reducer: Reducer) => void;
48
+ //# sourceMappingURL=store-access.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store-access.d.ts","sourceRoot":"","sources":["../../src/store/store-access.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,YAAY,QAAO,SAAS,GAAG,SAE3C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,QAAO,aAAa,GAAG,IAU/C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,QAAO,IAAI,GAAG,IAYxC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,QAAO,MAWjC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,QAAO,OAGlC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,QAAO,MAOpC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,QAAO,OAO5B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,GAAG,KAAG,IAS5C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,IAAI,KAAG,CAAC,MAAM,IAAI,CAUjE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAAI,KAAK,MAAM,EAAE,SAAS,OAAO,KAAG,IAOnE,CAAC"}
@@ -0,0 +1,131 @@
1
+ /**
2
+ * Host Store 접근 유틸리티 - KOMCA 패턴
3
+ * Remote 앱에서 Host의 Redux Store에 접근
4
+ */
5
+ /**
6
+ * Host Store 가져오기
7
+ */
8
+ export const getHostStore = () => {
9
+ return window.__REDUX_STORE__;
10
+ };
11
+ /**
12
+ * Host Store 상태 가져오기
13
+ */
14
+ export const getHostState = () => {
15
+ try {
16
+ const store = getHostStore();
17
+ if (store) {
18
+ return store.getState();
19
+ }
20
+ return null;
21
+ }
22
+ catch {
23
+ return null;
24
+ }
25
+ };
26
+ /**
27
+ * 현재 로그인된 사용자 가져오기
28
+ */
29
+ export const getCurrentUser = () => {
30
+ try {
31
+ const state = getHostState();
32
+ if (state) {
33
+ return state.app?.user || null;
34
+ }
35
+ // Store가 없으면 localStorage에서 직접 가져오기 (fallback)
36
+ const userStr = localStorage.getItem('user');
37
+ return userStr ? JSON.parse(userStr) : null;
38
+ }
39
+ catch {
40
+ return null;
41
+ }
42
+ };
43
+ /**
44
+ * accessToken 가져오기
45
+ */
46
+ export const getAccessToken = () => {
47
+ try {
48
+ const state = getHostState();
49
+ if (state) {
50
+ return state.app?.accessToken || '';
51
+ }
52
+ // Store가 없으면 localStorage에서 직접 가져오기 (fallback)
53
+ return localStorage.getItem('accessToken') || '';
54
+ }
55
+ catch {
56
+ return '';
57
+ }
58
+ };
59
+ /**
60
+ * 인증 여부 확인
61
+ */
62
+ export const isAuthenticated = () => {
63
+ const token = getAccessToken();
64
+ return !!token;
65
+ };
66
+ /**
67
+ * 현재 서비스 가져오기
68
+ */
69
+ export const getCurrentService = () => {
70
+ try {
71
+ const state = getHostState();
72
+ return state?.app?.service || '';
73
+ }
74
+ catch {
75
+ return '';
76
+ }
77
+ };
78
+ /**
79
+ * 로딩 상태 확인
80
+ */
81
+ export const isLoading = () => {
82
+ try {
83
+ const state = getHostState();
84
+ return state?.app?.isLoading || false;
85
+ }
86
+ catch {
87
+ return false;
88
+ }
89
+ };
90
+ /**
91
+ * Host Store에 액션 디스패치
92
+ */
93
+ export const dispatchToHost = (action) => {
94
+ try {
95
+ const store = getHostStore();
96
+ if (store) {
97
+ store.dispatch(action);
98
+ }
99
+ }
100
+ catch (error) {
101
+ console.error('Failed to dispatch to host store:', error);
102
+ }
103
+ };
104
+ /**
105
+ * Host Store 상태 변경 구독
106
+ */
107
+ export const subscribeToHost = (listener) => {
108
+ try {
109
+ const store = getHostStore();
110
+ if (store) {
111
+ return store.subscribe(listener);
112
+ }
113
+ return () => { };
114
+ }
115
+ catch {
116
+ return () => { };
117
+ }
118
+ };
119
+ /**
120
+ * 동적으로 Reducer 주입 (Remote 앱에서 자체 상태 관리 시 사용)
121
+ * 주의: 이 함수는 Host의 injectReducer를 호출해야 함
122
+ */
123
+ export const injectReducerToHost = (key, reducer) => {
124
+ // Host의 window에 노출된 injectReducer 함수 호출
125
+ if (typeof window.__INJECT_REDUCER__ === 'function') {
126
+ window.__INJECT_REDUCER__(key, reducer);
127
+ }
128
+ else {
129
+ console.warn('Host injectReducer not available');
130
+ }
131
+ };
@@ -0,0 +1,58 @@
1
+ /**
2
+ * MFA 공통 타입 정의
3
+ */
4
+ export * from './service';
5
+ export interface User {
6
+ id: string;
7
+ name: string;
8
+ email: string;
9
+ role?: 'admin' | 'user';
10
+ }
11
+ export interface AppState {
12
+ accessToken: string;
13
+ user: User | null;
14
+ isLoading: boolean;
15
+ globalLoadingTitle: string;
16
+ service: string;
17
+ selectedGnb: string;
18
+ }
19
+ export interface RecentMenu {
20
+ id: string;
21
+ pathname: string;
22
+ search: string;
23
+ title: string;
24
+ service?: string;
25
+ state?: any;
26
+ data?: any;
27
+ }
28
+ export interface MenuItem {
29
+ id: string;
30
+ title: string;
31
+ path: string;
32
+ icon?: string;
33
+ children?: MenuItem[];
34
+ }
35
+ export interface MenuState {
36
+ menuList: MenuItem[];
37
+ }
38
+ export interface RecentMenuState {
39
+ list: RecentMenu[];
40
+ currentId: string;
41
+ }
42
+ export interface HostRootState {
43
+ app: AppState;
44
+ recentMenu: RecentMenuState;
45
+ [key: string]: any;
46
+ }
47
+ export interface HostStore {
48
+ getState: () => HostRootState;
49
+ dispatch: (action: any) => any;
50
+ subscribe: (listener: () => void) => () => void;
51
+ replaceReducer: (reducer: any) => void;
52
+ }
53
+ declare global {
54
+ interface Window {
55
+ __REDUX_STORE__: HostStore;
56
+ }
57
+ }
58
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,cAAc,WAAW,CAAC;AAG1B,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CACzB;AAGD,MAAM,WAAW,QAAQ;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB;AAGD,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ;AAGD,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;CACvB;AAGD,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,QAAQ,EAAE,CAAC;CACtB;AAGD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAGD,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,QAAQ,CAAC;IACd,UAAU,EAAE,eAAe,CAAC;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAGD,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,aAAa,CAAC;IAC9B,QAAQ,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,GAAG,CAAC;IAC/B,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;IAChD,cAAc,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC;CACxC;AAGD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,eAAe,EAAE,SAAS,CAAC;KAC5B;CACF"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * MFA 공통 타입 정의
3
+ */
4
+ // Service Types
5
+ export * from './service';
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Service Type 정의 - KOMCA 패턴
3
+ * 각 Remote 앱을 구분하는 타입
4
+ */
5
+ export type ServiceType = 'resume' | 'blog' | 'portfolio';
6
+ export type ServicePrefixType = '@resume' | '@blog' | '@portfolio';
7
+ export declare const serviceTypeToPrefix: Record<ServiceType, ServicePrefixType>;
8
+ export declare const prefixToServiceType: Record<ServicePrefixType, ServiceType>;
9
+ export interface ServiceMeta {
10
+ type: ServiceType;
11
+ prefix: ServicePrefixType;
12
+ name: string;
13
+ port: number;
14
+ }
15
+ export declare const services: ServiceMeta[];
16
+ export declare const getServiceFromPath: (pathname: string) => ServiceType | null;
17
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/types/service.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;AAG1D,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,OAAO,GAAG,YAAY,CAAC;AAGnE,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,WAAW,EAAE,iBAAiB,CAItE,CAAC;AAGF,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,iBAAiB,EAAE,WAAW,CAItE,CAAC;AAGF,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,WAAW,CAAC;IAClB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAGD,eAAO,MAAM,QAAQ,EAAE,WAAW,EAIjC,CAAC;AAGF,eAAO,MAAM,kBAAkB,GAAI,UAAU,MAAM,KAAG,WAAW,GAAG,IAOnE,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Service Type 정의 - KOMCA 패턴
3
+ * 각 Remote 앱을 구분하는 타입
4
+ */
5
+ // Service Type → Prefix 매핑
6
+ export const serviceTypeToPrefix = {
7
+ resume: '@resume',
8
+ blog: '@blog',
9
+ portfolio: '@portfolio',
10
+ };
11
+ // Prefix → Service Type 매핑
12
+ export const prefixToServiceType = {
13
+ '@resume': 'resume',
14
+ '@blog': 'blog',
15
+ '@portfolio': 'portfolio',
16
+ };
17
+ // 서비스 목록
18
+ export const services = [
19
+ { type: 'resume', prefix: '@resume', name: '이력서', port: 5001 },
20
+ { type: 'blog', prefix: '@blog', name: '블로그', port: 5002 },
21
+ { type: 'portfolio', prefix: '@portfolio', name: '포트폴리오', port: 5003 },
22
+ ];
23
+ // 경로에서 서비스 타입 추출
24
+ export const getServiceFromPath = (pathname) => {
25
+ for (const service of services) {
26
+ if (pathname.startsWith(`/${service.prefix}`) || pathname.startsWith(service.prefix)) {
27
+ return service.type;
28
+ }
29
+ }
30
+ return null;
31
+ };
@@ -0,0 +1,2 @@
1
+ export * from './storage';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './storage';
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Storage 유틸리티 - KOMCA 패턴
3
+ * localStorage/sessionStorage 관리
4
+ */
5
+ import { User, RecentMenu } from '../types';
6
+ export declare const STORAGE_KEYS: {
7
+ ACCESS_TOKEN: string;
8
+ USER: string;
9
+ RECENT_MENU: string;
10
+ IS_HOST_APP: string;
11
+ };
12
+ /**
13
+ * Storage 유틸리티
14
+ */
15
+ export declare const storage: {
16
+ setHostApp: () => void;
17
+ isHostApp: () => boolean;
18
+ getAccessToken: () => string;
19
+ setAccessToken: (token: string) => void;
20
+ getUser: () => User | null;
21
+ setUser: (user: User | null) => void;
22
+ getRecentMenu: () => RecentMenu[];
23
+ setRecentMenu: (list: RecentMenu[]) => void;
24
+ clearAuth: () => void;
25
+ clearAll: () => void;
26
+ };
27
+ //# sourceMappingURL=storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/utils/storage.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAG5C,eAAO,MAAM,YAAY;;;;;CAKxB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO;;;0BAWE,MAAM;4BAIF,MAAM;mBASjB,IAAI,GAAG,IAAI;oBASR,IAAI,GAAG,IAAI;yBASR,UAAU,EAAE;0BAST,UAAU,EAAE;;;CAiBnC,CAAC"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Storage 유틸리티 - KOMCA 패턴
3
+ * localStorage/sessionStorage 관리
4
+ */
5
+ // Storage 키 상수
6
+ export const STORAGE_KEYS = {
7
+ ACCESS_TOKEN: 'accessToken',
8
+ USER: 'user',
9
+ RECENT_MENU: 'recentMenu',
10
+ IS_HOST_APP: 'isHostApp',
11
+ };
12
+ /**
13
+ * Storage 유틸리티
14
+ */
15
+ export const storage = {
16
+ // Host 앱 여부 설정/확인
17
+ setHostApp: () => {
18
+ sessionStorage.setItem(STORAGE_KEYS.IS_HOST_APP, 'true');
19
+ },
20
+ isHostApp: () => {
21
+ return sessionStorage.getItem(STORAGE_KEYS.IS_HOST_APP) === 'true';
22
+ },
23
+ // Access Token
24
+ getAccessToken: () => {
25
+ return localStorage.getItem(STORAGE_KEYS.ACCESS_TOKEN) || '';
26
+ },
27
+ setAccessToken: (token) => {
28
+ if (token) {
29
+ localStorage.setItem(STORAGE_KEYS.ACCESS_TOKEN, token);
30
+ }
31
+ else {
32
+ localStorage.removeItem(STORAGE_KEYS.ACCESS_TOKEN);
33
+ }
34
+ },
35
+ // User 정보
36
+ getUser: () => {
37
+ try {
38
+ const userStr = localStorage.getItem(STORAGE_KEYS.USER);
39
+ return userStr ? JSON.parse(userStr) : null;
40
+ }
41
+ catch {
42
+ return null;
43
+ }
44
+ },
45
+ setUser: (user) => {
46
+ if (user) {
47
+ localStorage.setItem(STORAGE_KEYS.USER, JSON.stringify(user));
48
+ }
49
+ else {
50
+ localStorage.removeItem(STORAGE_KEYS.USER);
51
+ }
52
+ },
53
+ // Recent Menu (탭 관리)
54
+ getRecentMenu: () => {
55
+ try {
56
+ const menuStr = localStorage.getItem(STORAGE_KEYS.RECENT_MENU);
57
+ return menuStr ? JSON.parse(menuStr) : [];
58
+ }
59
+ catch {
60
+ return [];
61
+ }
62
+ },
63
+ setRecentMenu: (list) => {
64
+ localStorage.setItem(STORAGE_KEYS.RECENT_MENU, JSON.stringify(list));
65
+ },
66
+ // 인증 정보 전체 삭제
67
+ clearAuth: () => {
68
+ localStorage.removeItem(STORAGE_KEYS.ACCESS_TOKEN);
69
+ localStorage.removeItem(STORAGE_KEYS.USER);
70
+ localStorage.removeItem(STORAGE_KEYS.RECENT_MENU);
71
+ sessionStorage.removeItem(STORAGE_KEYS.IS_HOST_APP);
72
+ },
73
+ // 전체 삭제
74
+ clearAll: () => {
75
+ localStorage.clear();
76
+ sessionStorage.clear();
77
+ },
78
+ };
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@sonhoseong/mfa-lib",
3
+ "version": "1.0.0",
4
+ "description": "MFA 공통 라이브러리 - KOMCA 패턴",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": ["dist", "README.md"],
8
+ "scripts": {
9
+ "build": "tsc",
10
+ "watch": "tsc --watch"
11
+ },
12
+ "dependencies": {
13
+ "@reduxjs/toolkit": "^2.11.2",
14
+ "axios": "^1.7.9",
15
+ "uuid": "^11.1.0"
16
+ },
17
+ "devDependencies": {
18
+ "@types/uuid": "^10.0.0",
19
+ "typescript": "^5.0.0"
20
+ },
21
+ "peerDependencies": {
22
+ "react": "^19.0.0",
23
+ "react-dom": "^19.0.0",
24
+ "react-redux": "^9.0.0",
25
+ "react-router-dom": "^7.0.0"
26
+ }
27
+ }