@ddunigma/node 3.0.1 → 3.0.2
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/README.md +210 -198
- package/dist/browser.cjs +7 -0
- package/dist/browser.d.cts +217 -0
- package/dist/browser.d.ts +217 -0
- package/dist/browser.js +7 -0
- package/dist/core-BccIjoLZ.d.cts +663 -0
- package/dist/core-BccIjoLZ.d.ts +663 -0
- package/dist/core.cjs +7 -0
- package/dist/core.d.cts +1 -0
- package/dist/core.d.ts +1 -0
- package/dist/core.js +7 -0
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +62 -743
- package/dist/index.d.ts +62 -743
- package/dist/index.js +6 -4
- package/dist/wasm/codec.wasm +0 -0
- package/package.json +24 -3
- package/dist/DduStream-NP3CMCKK.js +0 -2
- package/dist/chunk-FVBZKVPE.js +0 -4
|
@@ -0,0 +1,663 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ddunigma 아이소모픽 라이브러리의 핵심 타입 정의.
|
|
3
|
+
* 모든 타입 정의의 정규 소스입니다.
|
|
4
|
+
*
|
|
5
|
+
* @module core/types
|
|
6
|
+
*/
|
|
7
|
+
declare enum DduSetSymbol {
|
|
8
|
+
DDU = "ddu",
|
|
9
|
+
DDU_V1 = "ddu_v1",
|
|
10
|
+
ONECHARSET = "oneCharSet"
|
|
11
|
+
}
|
|
12
|
+
interface CharSetConfig {
|
|
13
|
+
/** charset 식별 심볼 */
|
|
14
|
+
symbol: DduSetSymbol;
|
|
15
|
+
/** 인코딩에 사용할 문자 배열 (codaChar가 있으면 기본 문자 배열) */
|
|
16
|
+
charSet: string[];
|
|
17
|
+
/** 종성 문자 배열 (charSet × codaChar 조합으로 최종 charset 생성) */
|
|
18
|
+
codaChar?: string[];
|
|
19
|
+
/** 최대 필요 문자 수 */
|
|
20
|
+
maxRequiredLength: number;
|
|
21
|
+
/** 비트 길이 (log2) */
|
|
22
|
+
bitLength: number;
|
|
23
|
+
/** 패딩 문자 */
|
|
24
|
+
paddingChar: string;
|
|
25
|
+
/** 패딩 문자 반복 방식 사용 여부 */
|
|
26
|
+
useRepeatPadding?: boolean;
|
|
27
|
+
}
|
|
28
|
+
interface CharSetInfo {
|
|
29
|
+
/** 인코딩에 사용할 문자 배열 */
|
|
30
|
+
charSet: string[];
|
|
31
|
+
/** 패딩 문자 */
|
|
32
|
+
paddingChar: string;
|
|
33
|
+
/** 비트 길이 */
|
|
34
|
+
bitLength: number;
|
|
35
|
+
/** 2의 제곱수 charset 여부 */
|
|
36
|
+
usePowerOfTwo: boolean;
|
|
37
|
+
/** 문자열 인코딩 방식 */
|
|
38
|
+
encoding: BufferEncoding;
|
|
39
|
+
/** 기본 압축 사용 여부 */
|
|
40
|
+
defaultCompress: boolean;
|
|
41
|
+
/** 기본 최대 디코딩 바이트 수 */
|
|
42
|
+
defaultMaxDecodedBytes: number;
|
|
43
|
+
/** 기본 최대 압축해제 바이트 수 */
|
|
44
|
+
defaultMaxDecompressedBytes: number;
|
|
45
|
+
/** URL-Safe 모드 여부 */
|
|
46
|
+
urlSafe: boolean;
|
|
47
|
+
/** 암호화 키 보유 여부 */
|
|
48
|
+
hasEncryptionKey: boolean;
|
|
49
|
+
/** 기본 체크섬 사용 여부 */
|
|
50
|
+
defaultChecksum: boolean;
|
|
51
|
+
/** 기본 청크 크기 */
|
|
52
|
+
defaultChunkSize: number | undefined;
|
|
53
|
+
/** 기본 청크 구분자 */
|
|
54
|
+
defaultChunkSeparator: string;
|
|
55
|
+
/** 기본 압축 레벨 */
|
|
56
|
+
defaultCompressionLevel: number;
|
|
57
|
+
/** 기본 압축 알고리즘 */
|
|
58
|
+
defaultCompressionAlgorithm: "deflate" | "brotli";
|
|
59
|
+
}
|
|
60
|
+
/** 진행률 콜백 정보 */
|
|
61
|
+
interface DduProgressInfo {
|
|
62
|
+
/** 현재 처리된 바이트 수 (근사값) */
|
|
63
|
+
processedBytes: number;
|
|
64
|
+
/** 전체 바이트 수 */
|
|
65
|
+
totalBytes: number;
|
|
66
|
+
/** 진행률 (0-100, 단계별 근사값) */
|
|
67
|
+
percent: number;
|
|
68
|
+
/** 현재 처리 단계 */
|
|
69
|
+
stage?: "start" | "encrypt" | "compress" | "encode" | "decode" | "decompress" | "checksum" | "decrypt" | "done";
|
|
70
|
+
}
|
|
71
|
+
/** 인코딩 통계 정보 */
|
|
72
|
+
interface DduEncodeStats {
|
|
73
|
+
/** 원본 데이터 크기 (바이트) */
|
|
74
|
+
originalSize: number;
|
|
75
|
+
/** 인코딩된 문자열 길이 */
|
|
76
|
+
encodedSize: number;
|
|
77
|
+
/** 압축된 크기 (압축 사용시) */
|
|
78
|
+
compressedSize?: number;
|
|
79
|
+
/** 압축률 (0-1, 낮을수록 효율적) */
|
|
80
|
+
compressionRatio?: number;
|
|
81
|
+
/** 인코딩 확장 비율 */
|
|
82
|
+
expansionRatio: number;
|
|
83
|
+
/** 사용된 charset 크기 */
|
|
84
|
+
charsetSize: number;
|
|
85
|
+
/** 비트 길이 */
|
|
86
|
+
bitLength: number;
|
|
87
|
+
}
|
|
88
|
+
type KeyDerivationAlgorithm = "sha256" | "pbkdf2";
|
|
89
|
+
interface KeyDerivationOptions {
|
|
90
|
+
/** Key derivation algorithm. `sha256` preserves legacy compatibility. */
|
|
91
|
+
algorithm?: KeyDerivationAlgorithm;
|
|
92
|
+
/** Salt for PBKDF2. Provide a stable value to decode across instances. */
|
|
93
|
+
salt?: string | Uint8Array;
|
|
94
|
+
/** PBKDF2 iteration count. Values below 10000 are clamped unless throwOnError is enabled. */
|
|
95
|
+
iterations?: number;
|
|
96
|
+
/** Hash function used by PBKDF2. */
|
|
97
|
+
hash?: "SHA-256" | "SHA-384" | "SHA-512";
|
|
98
|
+
}
|
|
99
|
+
interface DduOptions {
|
|
100
|
+
/** 압축 사용 여부 (zlib deflate 또는 brotli) */
|
|
101
|
+
compress?: boolean;
|
|
102
|
+
/** decode stream에서 footer 기반 자동 감지 사용 여부 (기본값: true) */
|
|
103
|
+
streamAutoDetect?: boolean;
|
|
104
|
+
/** 내부 암/복호화 사용 여부 (기본값: true, 스트림 파이프라인 내부 제어용) */
|
|
105
|
+
encrypt?: boolean;
|
|
106
|
+
/** 압축 알고리즘 (기본값: "deflate") */
|
|
107
|
+
compressionAlgorithm?: "deflate" | "brotli";
|
|
108
|
+
/** 압축 레벨 (deflate 기본값: 6, brotli도 기본값 6을 사용하며 전달값은 0~11 범위로 보정) */
|
|
109
|
+
compressionLevel?: number;
|
|
110
|
+
/** 최대 디코딩 바이트 수 (Zip Bomb 방어) */
|
|
111
|
+
maxDecodedBytes?: number;
|
|
112
|
+
/** 최대 압축해제 바이트 수 (Zip Bomb 방어) */
|
|
113
|
+
maxDecompressedBytes?: number;
|
|
114
|
+
/** 체크섬 추가 여부 (CRC32) */
|
|
115
|
+
checksum?: boolean;
|
|
116
|
+
/** 청크 분할 크기 */
|
|
117
|
+
chunkSize?: number;
|
|
118
|
+
/** 청크 구분자 (기본값: '\n') */
|
|
119
|
+
chunkSeparator?: string;
|
|
120
|
+
/** 중간 스트림 청크처럼 푸터를 생략해야 할 때 사용 */
|
|
121
|
+
omitFooter?: boolean;
|
|
122
|
+
/** 진행률 콜백 */
|
|
123
|
+
onProgress?: (info: DduProgressInfo) => void;
|
|
124
|
+
/** 한글 난독화 활성화 (encryptionKey 필요) */
|
|
125
|
+
obfuscate?: boolean;
|
|
126
|
+
}
|
|
127
|
+
interface DduConstructorOptions extends DduOptions {
|
|
128
|
+
/** 미리 정의된 charset 심볼 */
|
|
129
|
+
dduSetSymbol?: DduSetSymbol;
|
|
130
|
+
/** 커스텀 charset 문자 배열 또는 문자열 */
|
|
131
|
+
dduChar?: string[] | string;
|
|
132
|
+
/** 종성 문자 배열 (dduChar × codaChar 조합으로 최종 charset 동적 생성) */
|
|
133
|
+
codaChar?: string[];
|
|
134
|
+
/** 패딩 문자 */
|
|
135
|
+
paddingChar?: string;
|
|
136
|
+
/** 필요 문자 수 */
|
|
137
|
+
requiredLength?: number;
|
|
138
|
+
/** 비트 길이 */
|
|
139
|
+
bitLength?: number;
|
|
140
|
+
/** 2의 제곱수 강제 여부 */
|
|
141
|
+
usePowerOfTwo?: boolean;
|
|
142
|
+
/**
|
|
143
|
+
* true이면 초기화 오류 시 throw합니다. false이면 fallback charset으로 대체합니다.
|
|
144
|
+
* @default false
|
|
145
|
+
* @deprecated throwOnError를 사용하세요. 이 옵션은 하위 호환성을 위해 유지됩니다.
|
|
146
|
+
*/
|
|
147
|
+
useBuildErrorReturn?: boolean;
|
|
148
|
+
/**
|
|
149
|
+
* true이면 초기화 오류 시 throw합니다. false이면 fallback charset으로 대체합니다.
|
|
150
|
+
* useBuildErrorReturn과 동일한 동작이며, 둘 다 지정 시 throwOnError가 우선합니다.
|
|
151
|
+
* @default false
|
|
152
|
+
*/
|
|
153
|
+
throwOnError?: boolean;
|
|
154
|
+
/** Buffer 인코딩 방식 */
|
|
155
|
+
encoding?: BufferEncoding;
|
|
156
|
+
/** URL-Safe 모드 (특수문자를 URL 안전 문자로 변환) */
|
|
157
|
+
urlSafe?: boolean;
|
|
158
|
+
/** 암호화 키 (AES-256-GCM) */
|
|
159
|
+
encryptionKey?: string;
|
|
160
|
+
/** 암호화 키 파생 옵션 */
|
|
161
|
+
keyDerivation?: KeyDerivationOptions;
|
|
162
|
+
/** 패딩 문자 반복 방식 사용 여부 */
|
|
163
|
+
useRepeatPadding?: boolean;
|
|
164
|
+
/** 명시적 플랫폼 어댑터 (자동 감지 대신 사용) */
|
|
165
|
+
adapter?: PlatformAdapter;
|
|
166
|
+
/** 한글 난독화 활성화 (encryptionKey 필요) */
|
|
167
|
+
obfuscate?: boolean;
|
|
168
|
+
/** WASM 임계값 (바이트 단위, 기본값: 4096, 범위: 1024-1048576) */
|
|
169
|
+
wasmThreshold?: number;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* 암호화 및 압축 연산을 제공하는 플랫폼 어댑터 인터페이스.
|
|
173
|
+
* 각 런타임(Node.js, 브라우저, 엣지)이 이 인터페이스를 구현합니다.
|
|
174
|
+
*
|
|
175
|
+
* 동기 메서드(`?`로 표시)는 Node.js에서만 사용 가능합니다.
|
|
176
|
+
* 브라우저/엣지 어댑터는 동기 메서드 호출 시 throw합니다.
|
|
177
|
+
*/
|
|
178
|
+
interface PlatformAdapter {
|
|
179
|
+
/** UTF-8 키 문자열에서 256비트 키를 파생 */
|
|
180
|
+
deriveKey(key: string, options?: KeyDerivationOptions): Promise<Uint8Array>;
|
|
181
|
+
/** 동기적으로 256비트 키를 파생 (Node.js 전용) */
|
|
182
|
+
deriveKeySync?(key: string, options?: KeyDerivationOptions): Uint8Array;
|
|
183
|
+
/** AES-256-GCM으로 데이터를 암호화. IV(12) + authTag(16) + 암호문을 반환 */
|
|
184
|
+
encrypt(data: Uint8Array, keyHash: Uint8Array): Promise<Uint8Array>;
|
|
185
|
+
/** 동기적으로 데이터를 암호화 (Node.js 전용) */
|
|
186
|
+
encryptSync?(data: Uint8Array, keyHash: Uint8Array): Uint8Array;
|
|
187
|
+
/** AES-256-GCM 페이로드를 복호화. IV(12) + authTag(16) + 암호문 형식을 기대 */
|
|
188
|
+
decrypt(data: Uint8Array, keyHash: Uint8Array): Promise<Uint8Array>;
|
|
189
|
+
/** 동기적으로 데이터를 복호화 (Node.js 전용) */
|
|
190
|
+
decryptSync?(data: Uint8Array, keyHash: Uint8Array): Uint8Array;
|
|
191
|
+
/** 암호학적으로 안전한 랜덤 바이트를 생성 */
|
|
192
|
+
randomBytes(length: number): Uint8Array;
|
|
193
|
+
/** deflate 알고리즘으로 데이터를 압축 */
|
|
194
|
+
deflate(data: Uint8Array, level?: number): Promise<Uint8Array>;
|
|
195
|
+
/** 동기적으로 deflate 압축 (Node.js 전용) */
|
|
196
|
+
deflateSync?(data: Uint8Array, level?: number): Uint8Array;
|
|
197
|
+
/** deflate 데이터를 압축 해제 */
|
|
198
|
+
inflate(data: Uint8Array, maxBytes?: number): Promise<Uint8Array>;
|
|
199
|
+
/** 동기적으로 deflate 데이터를 압축 해제 (Node.js 전용) */
|
|
200
|
+
inflateSync?(data: Uint8Array, maxBytes?: number): Uint8Array;
|
|
201
|
+
/** brotli 알고리즘으로 데이터를 압축 (Node.js 전용) */
|
|
202
|
+
brotliCompress?(data: Uint8Array, level?: number): Promise<Uint8Array>;
|
|
203
|
+
/** 동기적으로 brotli 압축 (Node.js 전용) */
|
|
204
|
+
brotliCompressSync?(data: Uint8Array, level?: number): Uint8Array;
|
|
205
|
+
/** brotli 데이터를 압축 해제 (Node.js 전용) */
|
|
206
|
+
brotliDecompress?(data: Uint8Array, maxBytes?: number): Promise<Uint8Array>;
|
|
207
|
+
/** 동기적으로 brotli 데이터를 압축 해제 (Node.js 전용) */
|
|
208
|
+
brotliDecompressSync?(data: Uint8Array, maxBytes?: number): Uint8Array;
|
|
209
|
+
/** 이 어댑터가 동기 암호화 연산을 지원하는지 여부 */
|
|
210
|
+
readonly supportsSyncCrypto: boolean;
|
|
211
|
+
/** 이 어댑터가 동기 압축 연산을 지원하는지 여부 */
|
|
212
|
+
readonly supportsSyncCompression: boolean;
|
|
213
|
+
/** 이 어댑터가 brotli 압축을 지원하는지 여부 */
|
|
214
|
+
readonly supportsBrotli: boolean;
|
|
215
|
+
/** 감지된 런타임 환경 */
|
|
216
|
+
readonly runtime: "node" | "browser" | "edge" | "deno" | "bun" | "unknown";
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* WASM 가속 비트 패킹 코덱 인터페이스.
|
|
220
|
+
* 순수 JavaScript 구현과 바이트 단위로 동일한 인코딩/디코딩 연산을 제공합니다.
|
|
221
|
+
*/
|
|
222
|
+
interface WasmCodec {
|
|
223
|
+
/** 바이트를 charset 인덱스로 인코딩 */
|
|
224
|
+
encode(input: Uint8Array, bitLength: number): {
|
|
225
|
+
indices: Uint16Array;
|
|
226
|
+
paddingBits: number;
|
|
227
|
+
};
|
|
228
|
+
/** charset 인덱스를 바이트로 디코딩 */
|
|
229
|
+
decode(indices: Uint16Array, bitLength: number, paddingBits: number): Uint8Array;
|
|
230
|
+
/** WASM 모듈이 초기화되어 사용 가능한지 확인 */
|
|
231
|
+
readonly ready: boolean;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* 인코딩/디코딩 연산을 위해 워커 스레드에 전달되는 설정.
|
|
235
|
+
*/
|
|
236
|
+
interface EncoderConfig {
|
|
237
|
+
charSet: string[];
|
|
238
|
+
paddingChar: string;
|
|
239
|
+
bitLength: number;
|
|
240
|
+
usePowerOfTwo: boolean;
|
|
241
|
+
compress?: boolean;
|
|
242
|
+
compressionAlgorithm?: "deflate" | "brotli";
|
|
243
|
+
compressionLevel?: number;
|
|
244
|
+
encrypt?: boolean;
|
|
245
|
+
encryptionKeyHash?: Uint8Array;
|
|
246
|
+
checksum?: boolean;
|
|
247
|
+
urlSafe?: boolean;
|
|
248
|
+
chunkSize?: number;
|
|
249
|
+
chunkSeparator?: string;
|
|
250
|
+
useRepeatPadding?: boolean;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* 대용량 페이로드의 인코딩/디코딩 연산을 오프로드하는 워커 스레드 풀 인터페이스.
|
|
254
|
+
*/
|
|
255
|
+
interface WorkerPool {
|
|
256
|
+
/** 워커 스레드를 사용하여 인코딩 */
|
|
257
|
+
encode(input: Uint8Array, config: EncoderConfig): Promise<string>;
|
|
258
|
+
/** 워커 스레드를 사용하여 디코딩 */
|
|
259
|
+
decode(input: string, config: EncoderConfig): Promise<Uint8Array>;
|
|
260
|
+
/** 풀의 워커 스레드 수를 설정 (1-64) */
|
|
261
|
+
setPoolSize(n: number): void;
|
|
262
|
+
/** 모든 워커 스레드를 종료하고 리소스를 정리 */
|
|
263
|
+
terminate(): Promise<void>;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* 한글 음절 난독화 레이어 인터페이스.
|
|
267
|
+
* 암호화된 출력을 자연스러운 한국어 음절 블록으로 변환합니다.
|
|
268
|
+
*/
|
|
269
|
+
interface ObfuscationLayer {
|
|
270
|
+
/**
|
|
271
|
+
* 암호화된 charset 인코딩 문자열을 자연스러운 한글 음절로 변환합니다.
|
|
272
|
+
* 모든 출력 문자는 U+AC00–U+D7A3 범위에 있습니다.
|
|
273
|
+
* 출력 길이 <= 입력 길이의 1.5배.
|
|
274
|
+
*/
|
|
275
|
+
obfuscate(input: string): string;
|
|
276
|
+
/**
|
|
277
|
+
* 난독화를 역변환하여 원본 charset 인코딩 문자열을 복원합니다.
|
|
278
|
+
*/
|
|
279
|
+
deobfuscate(input: string): string;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* 크로스 플랫폼 인코딩 호환성 및 와이어 포맷 적합성을 검증하기 위한
|
|
283
|
+
* 표준화된 테스트 벡터 형식.
|
|
284
|
+
*/
|
|
285
|
+
interface TestVector {
|
|
286
|
+
/** 이 테스트 벡터의 고유 식별자 */
|
|
287
|
+
id: string;
|
|
288
|
+
/** 이 벡터가 테스트하는 내용에 대한 설명 */
|
|
289
|
+
description: string;
|
|
290
|
+
/** 입력 데이터 명세 */
|
|
291
|
+
input: {
|
|
292
|
+
/** 16진수 인코딩된 입력 바이트 */
|
|
293
|
+
raw: string;
|
|
294
|
+
/** 원시 데이터의 인코딩 */
|
|
295
|
+
encoding: "utf-8" | "binary";
|
|
296
|
+
};
|
|
297
|
+
/** 이 벡터의 charset 설정 */
|
|
298
|
+
charset: {
|
|
299
|
+
/** 프리셋 심볼 (내장 charset 사용 시) */
|
|
300
|
+
preset?: DduSetSymbol;
|
|
301
|
+
/** 커스텀 charset 문자 (프리셋 미사용 시) */
|
|
302
|
+
dduChar?: string[];
|
|
303
|
+
/** 조합 charset용 종성 문자 */
|
|
304
|
+
codaChar?: string[];
|
|
305
|
+
/** 패딩 문자 */
|
|
306
|
+
paddingChar: string;
|
|
307
|
+
};
|
|
308
|
+
/** 인코딩 옵션 */
|
|
309
|
+
options: {
|
|
310
|
+
compress?: boolean;
|
|
311
|
+
compressionAlgorithm?: "deflate" | "brotli";
|
|
312
|
+
encrypt?: boolean;
|
|
313
|
+
encryptionKey?: string;
|
|
314
|
+
checksum?: boolean;
|
|
315
|
+
urlSafe?: boolean;
|
|
316
|
+
chunkSize?: number;
|
|
317
|
+
useRepeatPadding?: boolean;
|
|
318
|
+
};
|
|
319
|
+
/** 기대 출력 */
|
|
320
|
+
expected: {
|
|
321
|
+
/** 기대되는 인코딩 문자열 */
|
|
322
|
+
encoded: string;
|
|
323
|
+
/** 바이너리 비교를 위한 16진수 표현 */
|
|
324
|
+
encodedHex?: string;
|
|
325
|
+
};
|
|
326
|
+
/** 테스트 벡터 분류 태그 */
|
|
327
|
+
tags: string[];
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* 플랫폼 독립 Ddu64 인코더/디코더 코어.
|
|
332
|
+
* PlatformAdapter 인터페이스를 통해 암호화 및 압축 연산을 수행하는 전체 인코딩/디코딩 파이프라인을 제공합니다.
|
|
333
|
+
*
|
|
334
|
+
* @module core/Ddu64Core
|
|
335
|
+
*/
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* 플랫폼 독립 Ddu64 인코더/디코더.
|
|
339
|
+
*
|
|
340
|
+
* 모든 암호화 및 압축 연산에 PlatformAdapter를 사용합니다.
|
|
341
|
+
*/
|
|
342
|
+
declare class Ddu64Core {
|
|
343
|
+
/** 인코딩에 사용되는 문자 */
|
|
344
|
+
protected readonly dduChar: string[];
|
|
345
|
+
/** 패딩 문자 */
|
|
346
|
+
protected readonly paddingChar: string;
|
|
347
|
+
/** 비트 길이 (2의 제곱수 charset의 경우 charset 크기의 log2) */
|
|
348
|
+
protected readonly bitLength: number;
|
|
349
|
+
/** charset 크기가 2의 제곱수인지 여부 */
|
|
350
|
+
protected readonly usePowerOfTwo: boolean;
|
|
351
|
+
/** 인코딩에 사용되는 유효 비트 길이 */
|
|
352
|
+
private readonly effectiveBitLength;
|
|
353
|
+
/** 문자 → 인덱스 역방향 룩업 맵 */
|
|
354
|
+
protected readonly dduBinaryLookup: Map<string, number>;
|
|
355
|
+
/** 미리 정의된 charset 사용 여부 */
|
|
356
|
+
private readonly isPredefinedCharSet;
|
|
357
|
+
/** 기본 압축 활성화 */
|
|
358
|
+
protected readonly defaultCompress: boolean;
|
|
359
|
+
/** 기본 최대 디코딩 바이트 수 */
|
|
360
|
+
private readonly defaultMaxDecodedBytes;
|
|
361
|
+
/** 기본 최대 압축해제 바이트 수 */
|
|
362
|
+
private readonly defaultMaxDecompressedBytes;
|
|
363
|
+
/** URL-Safe 모드 */
|
|
364
|
+
private readonly urlSafe;
|
|
365
|
+
/** 암호화 키 (원시 문자열, 해시 파생용) */
|
|
366
|
+
private readonly encryptionKey;
|
|
367
|
+
/** 암호화 키 파생 옵션 */
|
|
368
|
+
private readonly keyDerivation;
|
|
369
|
+
/** 캐시된 암호화 키 해시 */
|
|
370
|
+
private encryptionKeyHash;
|
|
371
|
+
/** 기본 체크섬 활성화 */
|
|
372
|
+
private readonly defaultChecksum;
|
|
373
|
+
/** 기본 청크 크기 */
|
|
374
|
+
private readonly defaultChunkSize;
|
|
375
|
+
/** 기본 청크 구분자 */
|
|
376
|
+
private readonly defaultChunkSeparator;
|
|
377
|
+
/** 기본 압축 레벨 */
|
|
378
|
+
private readonly defaultCompressionLevel;
|
|
379
|
+
/** 기본 압축 알고리즘 */
|
|
380
|
+
private readonly defaultCompressionAlgorithm;
|
|
381
|
+
/** 반복 패딩 모드 사용 여부 */
|
|
382
|
+
private readonly useRepeatPadding;
|
|
383
|
+
/** BitPack 설정 */
|
|
384
|
+
private readonly bitPackConfig;
|
|
385
|
+
/** WASM 사용 임계값 */
|
|
386
|
+
private readonly wasmThreshold;
|
|
387
|
+
/** 네이티브 Base64 fast path 사용 여부 */
|
|
388
|
+
private readonly canUseNativeBase64;
|
|
389
|
+
/** 현재 charset 문자 → 네이티브 Base64 문자 매핑 */
|
|
390
|
+
private readonly nativeDecodeMap;
|
|
391
|
+
/** 플랫폼 어댑터 (동기용 지연 로드 또는 명시적 제공) */
|
|
392
|
+
private adapter;
|
|
393
|
+
/** 기본 난독화 활성화 */
|
|
394
|
+
private readonly defaultObfuscate;
|
|
395
|
+
/** 지연 초기화되는 난독화 레이어 */
|
|
396
|
+
private _obfuscationLayer;
|
|
397
|
+
constructor(dduChar?: string[] | string, paddingChar?: string, dduOptions?: DduConstructorOptions);
|
|
398
|
+
/**
|
|
399
|
+
* 입력 데이터를 charset 인코딩 문자열로 인코딩합니다.
|
|
400
|
+
*
|
|
401
|
+
* @param input - 인코딩할 String 또는 Uint8Array
|
|
402
|
+
* @param options - 인코딩 옵션
|
|
403
|
+
* @returns 인코딩된 문자열
|
|
404
|
+
* @throws 동기 암호화/압축이 필요하지만 어댑터가 지원하지 않는 경우
|
|
405
|
+
*/
|
|
406
|
+
encode(input: Uint8Array | string, options?: DduOptions): string;
|
|
407
|
+
/**
|
|
408
|
+
* 인코딩된 문자열을 UTF-8 문자열로 디코딩합니다.
|
|
409
|
+
*
|
|
410
|
+
* @param input - 디코딩할 인코딩된 문자열
|
|
411
|
+
* @param options - 디코딩 옵션
|
|
412
|
+
* @returns 디코딩된 문자열
|
|
413
|
+
*/
|
|
414
|
+
decode(input: string, options?: DduOptions): string;
|
|
415
|
+
/**
|
|
416
|
+
* 인코딩된 문자열을 Uint8Array로 디코딩합니다.
|
|
417
|
+
*
|
|
418
|
+
* @param input - 디코딩할 인코딩된 문자열
|
|
419
|
+
* @param options - 디코딩 옵션
|
|
420
|
+
* @returns 디코딩된 바이트
|
|
421
|
+
*/
|
|
422
|
+
decodeToUint8Array(input: string, options?: DduOptions): Uint8Array;
|
|
423
|
+
/**
|
|
424
|
+
* 비동기 인코딩 - 브라우저를 포함한 모든 런타임에서 동작합니다.
|
|
425
|
+
*/
|
|
426
|
+
encodeAsync(input: Uint8Array | string, options?: DduOptions): Promise<string>;
|
|
427
|
+
/**
|
|
428
|
+
* 비동기 디코딩 - 브라우저를 포함한 모든 런타임에서 동작합니다.
|
|
429
|
+
*/
|
|
430
|
+
decodeAsync(input: string, options?: DduOptions): Promise<string>;
|
|
431
|
+
/**
|
|
432
|
+
* 비동기 Uint8Array 디코딩 - 브라우저를 포함한 모든 런타임에서 동작합니다.
|
|
433
|
+
*/
|
|
434
|
+
decodeToUint8ArrayAsync(input: string, options?: DduOptions): Promise<Uint8Array>;
|
|
435
|
+
/**
|
|
436
|
+
* charset 정보를 가져옵니다.
|
|
437
|
+
*/
|
|
438
|
+
getCharSetInfo(): CharSetInfo;
|
|
439
|
+
/**
|
|
440
|
+
* 인코딩 통계를 가져옵니다.
|
|
441
|
+
*/
|
|
442
|
+
getStats(input: Uint8Array | string, options?: DduOptions): DduEncodeStats;
|
|
443
|
+
/**
|
|
444
|
+
* 대용량 인코딩/디코딩 연산을 오프로드하기 위한 전역 워커 풀 크기를 설정합니다.
|
|
445
|
+
*
|
|
446
|
+
* @param n - 워커 수 (정수, 1–64)
|
|
447
|
+
* @throws n이 정수가 아니거나 [1, 64] 범위를 벗어난 경우 에러
|
|
448
|
+
*/
|
|
449
|
+
static setWorkerPoolSize(n: number): void;
|
|
450
|
+
/**
|
|
451
|
+
* 통계를 위한 메타데이터 포함 내부 인코딩.
|
|
452
|
+
*/
|
|
453
|
+
private encodeInternal;
|
|
454
|
+
/**
|
|
455
|
+
* 인코딩 후처리: 난독화, 체크섬, URL-safe, 청킹을 적용합니다.
|
|
456
|
+
*/
|
|
457
|
+
private applyPostEncoding;
|
|
458
|
+
/**
|
|
459
|
+
* BitPack + 푸터를 사용하여 바이트를 charset 문자열로 인코딩합니다.
|
|
460
|
+
*/
|
|
461
|
+
private encodeBytes;
|
|
462
|
+
/**
|
|
463
|
+
* charset 문자열을 인덱스로 변환한 후 BitPack으로 바이트를 얻습니다.
|
|
464
|
+
*/
|
|
465
|
+
private decodeChars;
|
|
466
|
+
private encodeBytesWithNativeBase64;
|
|
467
|
+
private decodeCharsWithNativeBase64;
|
|
468
|
+
private bytesToBase64;
|
|
469
|
+
private base64ToBytes;
|
|
470
|
+
private shouldUseWasm;
|
|
471
|
+
private reportProgress;
|
|
472
|
+
private requireSyncAdapter;
|
|
473
|
+
private encryptSync;
|
|
474
|
+
private decryptSync;
|
|
475
|
+
private compressSync;
|
|
476
|
+
private decompressSync;
|
|
477
|
+
private getAdapterAsync;
|
|
478
|
+
private getKeyHashAsync;
|
|
479
|
+
/**
|
|
480
|
+
* 난독화 레이어를 가져오거나 생성합니다 (지연 초기화).
|
|
481
|
+
* 알파벳에는 charset 문자, 패딩 문자, 모든 푸터 마커 문자가 포함됩니다.
|
|
482
|
+
*/
|
|
483
|
+
private getObfuscationLayer;
|
|
484
|
+
/**
|
|
485
|
+
* 주어진 호출에 난독화를 적용해야 하는지 결정합니다.
|
|
486
|
+
* 호출별 옵션이 생성자 기본값을 오버라이드합니다.
|
|
487
|
+
* 암호화 키 없이 난독화가 활성화되면 throw합니다.
|
|
488
|
+
*/
|
|
489
|
+
private shouldObfuscate;
|
|
490
|
+
private normalizeLimit;
|
|
491
|
+
private estimateDecodedBytes;
|
|
492
|
+
private assertEncodedInputAligned;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* 커스텀 Charset을 쉽게 생성하기 위한 빌더 클래스.
|
|
497
|
+
*
|
|
498
|
+
* @module core/CharsetBuilder
|
|
499
|
+
*
|
|
500
|
+
* @example
|
|
501
|
+
* const chars = CharsetBuilder
|
|
502
|
+
* .fromUnicodeRange(0x4E00, 0x4E3F)
|
|
503
|
+
* .excludeConfusing()
|
|
504
|
+
* .shuffle()
|
|
505
|
+
* .build();
|
|
506
|
+
*/
|
|
507
|
+
declare class CharsetBuilder {
|
|
508
|
+
private chars;
|
|
509
|
+
private constructor();
|
|
510
|
+
/**
|
|
511
|
+
* 빈 빌더를 생성합니다.
|
|
512
|
+
*/
|
|
513
|
+
static create(): CharsetBuilder;
|
|
514
|
+
/**
|
|
515
|
+
* 유니코드 범위에서 문자들을 추가합니다.
|
|
516
|
+
*
|
|
517
|
+
* @param start - 시작 유니코드 코드포인트
|
|
518
|
+
* @param end - 끝 유니코드 코드포인트 (포함)
|
|
519
|
+
*/
|
|
520
|
+
static fromUnicodeRange(start: number, end: number): CharsetBuilder;
|
|
521
|
+
/**
|
|
522
|
+
* 문자열에서 문자들을 추가합니다.
|
|
523
|
+
*
|
|
524
|
+
* @param chars - 문자열 또는 문자 배열
|
|
525
|
+
*/
|
|
526
|
+
static fromString(chars: string | string[]): CharsetBuilder;
|
|
527
|
+
/**
|
|
528
|
+
* Base64 표준 문자셋으로 시작합니다.
|
|
529
|
+
*/
|
|
530
|
+
static base64(): CharsetBuilder;
|
|
531
|
+
/**
|
|
532
|
+
* Base32 표준 문자셋으로 시작합니다.
|
|
533
|
+
*/
|
|
534
|
+
static base32(): CharsetBuilder;
|
|
535
|
+
/**
|
|
536
|
+
* 영문 대문자만 포함합니다.
|
|
537
|
+
*/
|
|
538
|
+
static uppercase(): CharsetBuilder;
|
|
539
|
+
/**
|
|
540
|
+
* 영문 소문자만 포함합니다.
|
|
541
|
+
*/
|
|
542
|
+
static lowercase(): CharsetBuilder;
|
|
543
|
+
/**
|
|
544
|
+
* 숫자만 포함합니다.
|
|
545
|
+
*/
|
|
546
|
+
static digits(): CharsetBuilder;
|
|
547
|
+
/**
|
|
548
|
+
* 한글 자모를 포함합니다.
|
|
549
|
+
*/
|
|
550
|
+
static hangulJamo(): CharsetBuilder;
|
|
551
|
+
/**
|
|
552
|
+
* 유니코드 범위에서 문자들을 추가합니다.
|
|
553
|
+
*/
|
|
554
|
+
addUnicodeRange(start: number, end: number): CharsetBuilder;
|
|
555
|
+
/**
|
|
556
|
+
* 문자열에서 문자들을 추가합니다.
|
|
557
|
+
*/
|
|
558
|
+
addString(chars: string | string[]): CharsetBuilder;
|
|
559
|
+
/**
|
|
560
|
+
* 특정 문자들을 추가합니다.
|
|
561
|
+
*/
|
|
562
|
+
add(...chars: string[]): CharsetBuilder;
|
|
563
|
+
/**
|
|
564
|
+
* 혼동하기 쉬운 문자들을 제거합니다.
|
|
565
|
+
* (0, O, o, 1, l, I, i 등)
|
|
566
|
+
*/
|
|
567
|
+
excludeConfusing(): CharsetBuilder;
|
|
568
|
+
/**
|
|
569
|
+
* 특정 문자들을 제거합니다.
|
|
570
|
+
*/
|
|
571
|
+
exclude(...chars: string[]): CharsetBuilder;
|
|
572
|
+
/**
|
|
573
|
+
* URL에서 안전하지 않은 문자들을 제거합니다.
|
|
574
|
+
*/
|
|
575
|
+
excludeUrlUnsafe(): CharsetBuilder;
|
|
576
|
+
/**
|
|
577
|
+
* 중복 문자를 제거합니다.
|
|
578
|
+
*/
|
|
579
|
+
unique(): CharsetBuilder;
|
|
580
|
+
/**
|
|
581
|
+
* 문자셋을 무작위로 섞습니다.
|
|
582
|
+
*/
|
|
583
|
+
shuffle(seed?: number): CharsetBuilder;
|
|
584
|
+
/**
|
|
585
|
+
* 시드 기반 난수 생성기 (xorshift32)
|
|
586
|
+
*/
|
|
587
|
+
private seededRandom;
|
|
588
|
+
/**
|
|
589
|
+
* 특정 길이로 자릅니다.
|
|
590
|
+
*/
|
|
591
|
+
limit(length: number): CharsetBuilder;
|
|
592
|
+
/**
|
|
593
|
+
* 2의 제곱수 길이로 자릅니다.
|
|
594
|
+
*/
|
|
595
|
+
limitToPowerOfTwo(): CharsetBuilder;
|
|
596
|
+
/**
|
|
597
|
+
* 문자셋을 정렬합니다.
|
|
598
|
+
*/
|
|
599
|
+
sort(): CharsetBuilder;
|
|
600
|
+
/**
|
|
601
|
+
* 역순으로 정렬합니다.
|
|
602
|
+
*/
|
|
603
|
+
reverse(): CharsetBuilder;
|
|
604
|
+
/**
|
|
605
|
+
* 현재 문자 수를 반환합니다.
|
|
606
|
+
*/
|
|
607
|
+
get length(): number;
|
|
608
|
+
/**
|
|
609
|
+
* 문자셋을 문자열로 빌드합니다.
|
|
610
|
+
*/
|
|
611
|
+
buildString(): string;
|
|
612
|
+
/**
|
|
613
|
+
* 문자셋을 배열로 빌드합니다.
|
|
614
|
+
*/
|
|
615
|
+
build(): string[];
|
|
616
|
+
/**
|
|
617
|
+
* 문자셋과 패딩 문자를 함께 빌드합니다.
|
|
618
|
+
*
|
|
619
|
+
* @param paddingChar - 패딩 문자 (기본값: charset에서 제외된 첫 번째 문자)
|
|
620
|
+
*/
|
|
621
|
+
buildWithPadding(paddingChar?: string): {
|
|
622
|
+
charset: string[];
|
|
623
|
+
padding: string;
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* ddunigma 비트 패킹 가속을 위한 WASM 로더 및 통합.
|
|
629
|
+
*
|
|
630
|
+
* 순수 JavaScript 구현과 바이트 단위로 동일한 선택적 WASM 가속
|
|
631
|
+
* 인코딩/디코딩을 제공합니다. WASM을 사용할 수 없거나 실패하면
|
|
632
|
+
* 조용히 JS로 폴백합니다.
|
|
633
|
+
*
|
|
634
|
+
* @module wasm/WasmCodec
|
|
635
|
+
*/
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* WASM 모듈을 사전 로드하고 초기화합니다.
|
|
639
|
+
*
|
|
640
|
+
* 첫 번째 인코딩/디코딩 연산 전에 WASM이 준비되도록 애플리케이션 초기에
|
|
641
|
+
* 호출하세요. WASM이 초기화되면 resolve되고, 10초 내에 초기화에 실패하면
|
|
642
|
+
* reject됩니다.
|
|
643
|
+
*
|
|
644
|
+
* @throws WASM 초기화가 실패하거나 타임아웃(10초)된 경우 에러
|
|
645
|
+
*/
|
|
646
|
+
declare function preloadWasm(): Promise<void>;
|
|
647
|
+
/**
|
|
648
|
+
* WASM 코덱이 준비되었으면 반환하거나, 온디맨드 초기화를 시도합니다.
|
|
649
|
+
*
|
|
650
|
+
* `preloadWasm()`이 호출되지 않았으면 5초 타임아웃으로 초기화를 시도합니다.
|
|
651
|
+
* WASM을 사용할 수 없으면 null을 반환합니다.
|
|
652
|
+
*
|
|
653
|
+
* 이 함수는 throw하지 않음 — 실패 시 null을 반환합니다.
|
|
654
|
+
*/
|
|
655
|
+
declare function getWasmCodec(): WasmCodec | null;
|
|
656
|
+
/**
|
|
657
|
+
* WASM 코덱이 이미 초기화된 경우에만 반환합니다.
|
|
658
|
+
* 온디맨드 초기화를 트리거하지 않습니다.
|
|
659
|
+
* WASM이 준비되지 않았으면 null을 반환합니다.
|
|
660
|
+
*/
|
|
661
|
+
declare function getWasmCodecSync(): WasmCodec | null;
|
|
662
|
+
|
|
663
|
+
export { type CharSetConfig as C, Ddu64Core as D, type EncoderConfig as E, type KeyDerivationOptions as K, type ObfuscationLayer as O, type PlatformAdapter as P, type TestVector as T, type WasmCodec as W, type DduConstructorOptions as a, type DduOptions as b, type CharSetInfo as c, CharsetBuilder as d, type DduEncodeStats as e, type DduProgressInfo as f, DduSetSymbol as g, type KeyDerivationAlgorithm as h, type WorkerPool as i, getWasmCodec as j, getWasmCodecSync as k, preloadWasm as p };
|