@byuckchon-frontend/utils 1.2.0 → 1.2.1

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.
@@ -1,6 +1,8 @@
1
1
  import { FormatTimeOptions } from './type';
2
2
  /** utc -> kst 시간 변환 함수 */
3
- export declare const utcToKst: (utcDate: Date) => Date;
3
+ export declare const utcToKst: (utcDate: Date | string) => Date;
4
+ /** kst -> utc 시간 변환 함수 */
5
+ export declare const kstToUtc: (kstDate: Date | string) => Date;
4
6
  /** 날짜 형식 변환 함수 ( ex: yyyy-MM-dd ) */
5
7
  export declare const formatDate: (date: Date | string, pattern?: string) => string;
6
8
  /** 날짜 ISO 형식 변환 함수 */
@@ -14,3 +16,4 @@ export declare const afterDate: (firstDate: Date, secondDate: Date) => Date;
14
16
  /** 현재 시간을 기준으로 상대 시간 반환 함수 */
15
17
  export declare const relativeTime: (date: Date, labels?: Partial<Record<"direction" | "seconds" | "minutes" | "hours" | "days" | "weeks" | "months" | "years", string>>) => string;
16
18
  export declare const formatToCustomKoreanTime: (isoString: Date | string, options?: FormatTimeOptions) => string;
19
+ export declare function isSameDay(date1: string | Date, date2: string | Date): boolean;
@@ -3,4 +3,5 @@ export * from './validate';
3
3
  export * from './handleError';
4
4
  export * from './filterParams';
5
5
  export * from './userAgent';
6
+ export * from './sanitizeHtml';
6
7
  export * as dateUtils from './DateUtils';
@@ -0,0 +1,35 @@
1
+ /**
2
+ * HTML sanitization 설정 옵션
3
+ *
4
+ * @interface SanitizeHtmlConfig
5
+ * @property {string[]} [addElements] - 기본 허용 태그에 추가할 HTML 태그 목록. allowElements가 있으면 무시됨
6
+ * @property {string[]} [allowElements] - 허용할 HTML 태그 목록. 비어있으면 기본 DOMPurify 허용 태그 사용
7
+ * @property {Record<string, string[]>} [allowAttributes] - 태그별 허용할 속성 목록.
8
+ * @property {string[]} [dropElements] - 제거할 HTML 태그 목록
9
+ * @property {Record<string, string[]>} [dropAttributes] - 태그별 제거할 속성 목록
10
+ */
11
+ export interface SanitizeHtmlConfig {
12
+ addElements?: string[];
13
+ allowElements?: string[];
14
+ allowAttributes?: Record<string, string[]>;
15
+ dropElements?: string[];
16
+ dropAttributes?: Record<string, string[]>;
17
+ }
18
+ interface SanitizeHtmlProps {
19
+ content: string;
20
+ config?: SanitizeHtmlConfig;
21
+ }
22
+ /**
23
+ * DOMPurify를 사용하여 HTML을 안전하게 sanitize하는 함수
24
+ *
25
+ * XSS 공격을 방지하기 위해 위험한 스크립트, 이벤트 핸들러 등을 제거하고,
26
+ * 설정된 규칙에 따라 허용된 태그와 속성만 유지합니다.
27
+ *
28
+ * @param {SanitizeHtmlProps} props - 컴포넌트 props
29
+ * @param {string} props.content - sanitize할 HTML 문자열
30
+ * @param {SanitizeHtmlConfig} [props.config] - HTML sanitization 설정 옵션
31
+ *
32
+ * @returns {string} sanitize된 HTML 문자열
33
+ */
34
+ export declare const SanitizeHtml: ({ content, config }: SanitizeHtmlProps) => string;
35
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@byuckchon-frontend/utils",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/index.umd.js",