@ddunigma/node 3.1.0 → 4.0.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.
Files changed (42) hide show
  1. package/README.md +42 -8
  2. package/dist/BrowserAdapter-G4XORUQJ.js +2 -0
  3. package/dist/BrowserAdapter-LIUL744V.cjs +2 -0
  4. package/dist/NodeAdapter-AHALQ4DQ.js +2 -0
  5. package/dist/NodeAdapter-DS44MI5D.cjs +2 -0
  6. package/dist/{ObfuscationLayer-DAVKTnHf.d.cts → ObfuscationLayer-BRiyE5xu.d.cts} +10 -12
  7. package/dist/{ObfuscationLayer-D-xl5d7P.d.ts → ObfuscationLayer-DZiQGHMw.d.ts} +10 -12
  8. package/dist/browser.cjs +1 -1
  9. package/dist/browser.d.cts +5 -4
  10. package/dist/browser.d.ts +5 -4
  11. package/dist/browser.js +1 -1
  12. package/dist/chunk-342X2QEY.js +2 -0
  13. package/dist/chunk-65RDFQV7.js +10 -0
  14. package/dist/chunk-FACJ5LAG.cjs +10 -0
  15. package/dist/chunk-M7526IW7.js +2 -0
  16. package/dist/chunk-P7WJ2LOQ.js +2 -0
  17. package/dist/chunk-RFBXQWSA.cjs +2 -0
  18. package/dist/chunk-RHVBUC4T.cjs +2 -0
  19. package/dist/chunk-WS6GB27C.cjs +2 -0
  20. package/dist/core.cjs +1 -1
  21. package/dist/core.d.cts +40 -1
  22. package/dist/core.d.ts +40 -1
  23. package/dist/core.js +1 -1
  24. package/dist/{core-DYSnygnp.d.cts → errors-DxOlTuHc.d.cts} +94 -81
  25. package/dist/{core-DYSnygnp.d.ts → errors-DxOlTuHc.d.ts} +94 -81
  26. package/dist/index.cjs +1 -1
  27. package/dist/index.d.cts +23 -8
  28. package/dist/index.d.ts +23 -8
  29. package/dist/index.js +1 -1
  30. package/package.json +42 -5
  31. package/dist/BrowserAdapter-BHHWPUTB.js +0 -2
  32. package/dist/BrowserAdapter-M7PUHVGS.cjs +0 -2
  33. package/dist/NodeAdapter-JB2EZ3T4.js +0 -2
  34. package/dist/NodeAdapter-JRRSYUJT.cjs +0 -2
  35. package/dist/chunk-5RZDTEOZ.js +0 -2
  36. package/dist/chunk-JUBMOKKH.js +0 -2
  37. package/dist/chunk-JZSHJ6KN.cjs +0 -9
  38. package/dist/chunk-KEWLOPEV.js +0 -9
  39. package/dist/chunk-M6LY6DIE.js +0 -2
  40. package/dist/chunk-NFMYVNOG.cjs +0 -2
  41. package/dist/chunk-PHMARSJE.cjs +0 -2
  42. package/dist/chunk-TJTDYO65.cjs +0 -2
@@ -0,0 +1,2 @@
1
+ 'use strict';var chunkNY4FGVF3_cjs=require('./chunk-NY4FGVF3.cjs'),crypto=require('crypto'),zlib=require('zlib'),util=require('util');var N=util.promisify(zlib.deflateRaw),w=util.promisify(zlib.inflateRaw),v=util.promisify(zlib.brotliCompress),h=util.promisify(zlib.brotliDecompress),E=util.promisify(crypto.pbkdf2);function _(e){let n=e,r=String(n?.message??"").toLowerCase();return String(n?.code??"")==="ERR_BUFFER_TOO_LARGE"||r.includes("output length")||r.includes("buffer too large")||r.includes("cannot create a buffer larger")}function f(e,n,r){throw _(e)?new Error(`[Ddu64 ${r}] Decompressed data exceeds limit. Limit: ${n} bytes`,{cause:e}):e}function s(e){return Buffer.isBuffer(e)?e:e.buffer instanceof SharedArrayBuffer?Buffer.from(e):Buffer.from(e.buffer,e.byteOffset,e.byteLength)}var g=class{supportsSyncCrypto=true;supportsSyncCompression=true;supportsBrotli=true;runtime="node";async deriveKey(n,r){if(r?.algorithm==="pbkdf2"){let t=await E(n,chunkNY4FGVF3_cjs.d(r.salt),chunkNY4FGVF3_cjs.a(r.iterations),32,chunkNY4FGVF3_cjs.b(r.hash));return new Uint8Array(t)}return this.deriveKeySync(n,r)}deriveKeySync(n,r){return r?.algorithm==="pbkdf2"?new Uint8Array(crypto.pbkdf2Sync(n,chunkNY4FGVF3_cjs.d(r.salt),chunkNY4FGVF3_cjs.a(r.iterations),32,chunkNY4FGVF3_cjs.b(r.hash))):new Uint8Array(crypto.createHash("sha256").update(n).digest())}async encrypt(n,r,t){return this.encryptSync(n,r,t)}encryptSync(n,r,t){let i=crypto.randomBytes(12),o=crypto.createCipheriv("aes-256-gcm",r,i);t&&t.length>0&&o.setAAD(s(t));let u=Buffer.concat([o.update(n),o.final()]),a=o.getAuthTag(),c=new Uint8Array(28+u.length);return c.set(i,0),c.set(a,12),c.set(u,28),c}async decrypt(n,r,t){return this.decryptSync(n,r,t)}decryptSync(n,r,t){if(n.length<28)throw new Error("[Ddu64 decrypt] Invalid encrypted data: too short");let i=n.subarray(0,12),o=n.subarray(12,28),u=n.subarray(28),a=crypto.createDecipheriv("aes-256-gcm",r,i);t&&t.length>0&&a.setAAD(s(t)),a.setAuthTag(o);let c=Buffer.concat([a.update(u),a.final()]);return new Uint8Array(c)}randomBytes(n){return new Uint8Array(crypto.randomBytes(n))}async deflate(n,r){let t={};r!==void 0&&(t.level=r);let i=await N(s(n),t);return new Uint8Array(i)}deflateSync(n,r){let t={};return r!==void 0&&(t.level=r),new Uint8Array(zlib.deflateRawSync(s(n),t))}async inflate(n,r){if(r===void 0||r===Number.POSITIVE_INFINITY){let i=await w(s(n));return new Uint8Array(i)}let t={maxOutputLength:r};try{let i=await w(s(n),t);return new Uint8Array(i)}catch(i){f(i,r,"inflate");}}inflateSync(n,r){if(r===void 0||r===Number.POSITIVE_INFINITY)return new Uint8Array(zlib.inflateRawSync(s(n)));try{return new Uint8Array(zlib.inflateRawSync(s(n),{maxOutputLength:r}))}catch(t){f(t,r,"inflate");}}async brotliCompress(n,r){let t={};r!==void 0&&(t.params={[zlib.constants.BROTLI_PARAM_QUALITY]:Math.max(0,Math.min(11,r))});let i=await v(s(n),t);return new Uint8Array(i)}brotliCompressSync(n,r){let t={};return r!==void 0&&(t.params={[zlib.constants.BROTLI_PARAM_QUALITY]:Math.max(0,Math.min(11,r))}),new Uint8Array(zlib.brotliCompressSync(s(n),t))}async brotliDecompress(n,r){if(r===void 0||r===Number.POSITIVE_INFINITY){let t=await h(s(n));return new Uint8Array(t)}try{let t=await h(s(n),{maxOutputLength:r});return new Uint8Array(t)}catch(t){f(t,r,"brotli");}}brotliDecompressSync(n,r){if(r===void 0||r===Number.POSITIVE_INFINITY)return new Uint8Array(zlib.brotliDecompressSync(s(n)));try{return new Uint8Array(zlib.brotliDecompressSync(s(n),{maxOutputLength:r}))}catch(t){f(t,r,"brotli");}}};exports.a=g;//# sourceMappingURL=chunk-RHVBUC4T.cjs.map
2
+ //# sourceMappingURL=chunk-RHVBUC4T.cjs.map
@@ -0,0 +1,2 @@
1
+ 'use strict';var chunkFACJ5LAG_cjs=require('./chunk-FACJ5LAG.cjs');function R(){let e=globalThis;return e.Deno?.version?.deno?"deno":e.Bun?.version?"bun":e.process?.versions?.node?"node":typeof e.EdgeRuntime=="string"||typeof e.WebSocketPair<"u"&&e.crypto?.subtle?"edge":typeof e.crypto<"u"&&e.crypto?.subtle?"browser":"unknown"}function W(e,n){let r=e.getCharSetInfo(),d=n?.compress??r.defaultCompress,p=(n?.encrypt??true)&&r.hasEncryptionKey,y=n?.checksum??r.defaultChecksum,t=d?n?.compressionAlgorithm??r.defaultCompressionAlgorithm:void 0,m=r.paddingChar,f=D(r,{compressed:d,encrypted:p,checksum:y}),c=false,s=[],h=0,o=null;return new TransformStream({async transform(a,u){if(f){if(!c){let k=chunkFACJ5LAG_cjs.z(m,{compressionAlgorithm:void 0,encrypted:false});u.enqueue(k),c=true;}let i;o&&o.length>0?(i=new Uint8Array(o.length+a.length),i.set(o,0),i.set(a,o.length)):i=a;let g=r.bitLength,S=U(g,8)/8,l=Math.floor(i.length/S)*S;if(l>0){let k=i.subarray(0,l),E=await e.encodeAsync(k,{compress:false,encrypt:false,checksum:false,chunkSize:void 0,chunkSeparator:void 0,omitFooter:true});u.enqueue(E);}l<i.length?o=i.slice(l):o=null;}else s.push(a),h+=a.length;},async flush(a){try{if(f){if(!c){let u=chunkFACJ5LAG_cjs.z(m,{compressionAlgorithm:void 0,encrypted:!1});a.enqueue(u);}if(o&&o.length>0){let u=await e.encodeAsync(o,{compress:!1,encrypt:!1,checksum:!1,chunkSize:void 0,chunkSeparator:void 0});a.enqueue(u);}o=null;}else {let u=chunkFACJ5LAG_cjs.z(m,{compressionAlgorithm:t,encrypted:p});if(a.enqueue(u),h>0){let i=new Uint8Array(h),g=0;for(let l of s)i.set(l,g),g+=l.length;let S=await e.encodeAsync(i,{...n,compress:d,encrypt:p,checksum:y,chunkSize:void 0,chunkSeparator:void 0});a.enqueue(S);}s=[],h=0;}}catch(u){a.error(chunkFACJ5LAG_cjs.w(u,"stream"));}}})}function L(e,n){let r=e.getCharSetInfo(),d=r.paddingChar,p=chunkFACJ5LAG_cjs.y(d),y=n?.checksum??r.defaultChecksum,t="",m=false,f=null;return new TransformStream({async transform(c,s){if(t+=c,!m&&t.length>=p){if(!t.startsWith(d)){s.error(new Error("[WebStreams decode] Invalid or missing stream header"));return}if(f=chunkFACJ5LAG_cjs.A(t,d),f===null){s.error(new Error("[WebStreams decode] Invalid or missing stream header"));return}if(f.encrypted&&!r.hasEncryptionKey){s.error(new Error("[WebStreams decode] Encrypted stream requires an encryptionKey"));return}m=true,t=t.slice(p);}},async flush(c){try{if(!m){if(t.length===0)return;c.error(new Error("[WebStreams decode] Incomplete stream header"));return}if(t.length===0)return;let s=f.compressionAlgorithm,h=await e.decodeToUint8ArrayAsync(t,{...n,compress:n?.compress,compressionAlgorithm:s,encrypt:n?.encrypt,checksum:y,chunkSize:void 0,chunkSeparator:void 0});h.length>0&&c.enqueue(h),t="";}catch(s){c.error(chunkFACJ5LAG_cjs.w(s,"stream"));}}})}function D(e,n){return e.usePowerOfTwo&&!n.compressed&&!n.encrypted&&!n.checksum}function U(e,n){return e*n/I(e,n)}function I(e,n){for(;n!==0;){let r=n;n=e%n,e=r;}return e}exports.a=R;exports.b=W;exports.c=L;//# sourceMappingURL=chunk-WS6GB27C.cjs.map
2
+ //# sourceMappingURL=chunk-WS6GB27C.cjs.map
package/dist/core.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkJZSHJ6KN_cjs=require('./chunk-JZSHJ6KN.cjs');Object.defineProperty(exports,"CharsetBuilder",{enumerable:true,get:function(){return chunkJZSHJ6KN_cjs.l}});Object.defineProperty(exports,"Ddu64",{enumerable:true,get:function(){return chunkJZSHJ6KN_cjs.k}});Object.defineProperty(exports,"Ddu64Core",{enumerable:true,get:function(){return chunkJZSHJ6KN_cjs.k}});Object.defineProperty(exports,"DduSetSymbol",{enumerable:true,get:function(){return chunkJZSHJ6KN_cjs.d}});Object.defineProperty(exports,"getWasmCodec",{enumerable:true,get:function(){return chunkJZSHJ6KN_cjs.h}});Object.defineProperty(exports,"getWasmCodecSync",{enumerable:true,get:function(){return chunkJZSHJ6KN_cjs.i}});Object.defineProperty(exports,"preloadWasm",{enumerable:true,get:function(){return chunkJZSHJ6KN_cjs.g}});//# sourceMappingURL=core.cjs.map
1
+ 'use strict';var chunkFACJ5LAG_cjs=require('./chunk-FACJ5LAG.cjs');Object.defineProperty(exports,"CharsetBuilder",{enumerable:true,get:function(){return chunkFACJ5LAG_cjs.C}});Object.defineProperty(exports,"Ddu64",{enumerable:true,get:function(){return chunkFACJ5LAG_cjs.B}});Object.defineProperty(exports,"Ddu64AdapterError",{enumerable:true,get:function(){return chunkFACJ5LAG_cjs.s}});Object.defineProperty(exports,"Ddu64CharsetError",{enumerable:true,get:function(){return chunkFACJ5LAG_cjs.q}});Object.defineProperty(exports,"Ddu64ChecksumError",{enumerable:true,get:function(){return chunkFACJ5LAG_cjs.p}});Object.defineProperty(exports,"Ddu64CompressionError",{enumerable:true,get:function(){return chunkFACJ5LAG_cjs.l}});Object.defineProperty(exports,"Ddu64Core",{enumerable:true,get:function(){return chunkFACJ5LAG_cjs.B}});Object.defineProperty(exports,"Ddu64DecodeError",{enumerable:true,get:function(){return chunkFACJ5LAG_cjs.k}});Object.defineProperty(exports,"Ddu64DecompressionError",{enumerable:true,get:function(){return chunkFACJ5LAG_cjs.m}});Object.defineProperty(exports,"Ddu64DecryptionError",{enumerable:true,get:function(){return chunkFACJ5LAG_cjs.o}});Object.defineProperty(exports,"Ddu64EncodeError",{enumerable:true,get:function(){return chunkFACJ5LAG_cjs.j}});Object.defineProperty(exports,"Ddu64EncryptionError",{enumerable:true,get:function(){return chunkFACJ5LAG_cjs.n}});Object.defineProperty(exports,"Ddu64Error",{enumerable:true,get:function(){return chunkFACJ5LAG_cjs.i}});Object.defineProperty(exports,"Ddu64ErrorCode",{enumerable:true,get:function(){return chunkFACJ5LAG_cjs.h}});Object.defineProperty(exports,"Ddu64LimitError",{enumerable:true,get:function(){return chunkFACJ5LAG_cjs.r}});Object.defineProperty(exports,"Ddu64ObfuscationError",{enumerable:true,get:function(){return chunkFACJ5LAG_cjs.t}});Object.defineProperty(exports,"Ddu64StreamError",{enumerable:true,get:function(){return chunkFACJ5LAG_cjs.u}});Object.defineProperty(exports,"DduSetSymbol",{enumerable:true,get:function(){return chunkFACJ5LAG_cjs.a}});Object.defineProperty(exports,"getWasmCodec",{enumerable:true,get:function(){return chunkFACJ5LAG_cjs.e}});Object.defineProperty(exports,"getWasmCodecSync",{enumerable:true,get:function(){return chunkFACJ5LAG_cjs.f}});Object.defineProperty(exports,"isDdu64Error",{enumerable:true,get:function(){return chunkFACJ5LAG_cjs.v}});Object.defineProperty(exports,"preloadWasm",{enumerable:true,get:function(){return chunkFACJ5LAG_cjs.d}});//# sourceMappingURL=core.cjs.map
2
2
  //# sourceMappingURL=core.cjs.map
package/dist/core.d.cts CHANGED
@@ -1 +1,40 @@
1
- export { C as CharSetConfig, b as CharSetInfo, c as CharsetBuilder, D as Ddu64, D as Ddu64Core, a as DduConstructorOptions, d as DduEncodeStats, e as DduOptions, f as DduProgressInfo, g as DduSetSymbol, h as DduTextEncoding, E as EncodingProfile, K as KeyDerivationAlgorithm, i as KeyDerivationOptions, O as ObfuscationLayer, P as PlatformAdapter, W as WasmCodec, j as getWasmCodec, k as getWasmCodecSync, p as preloadWasm } from './core-DYSnygnp.cjs';
1
+ import { W as WasmCodec } from './errors-DxOlTuHc.cjs';
2
+ export { C as CharSetConfig, b as CharSetInfo, c as CharsetBuilder, D as Ddu64, d as Ddu64AdapterError, e as Ddu64CharsetError, f as Ddu64ChecksumError, g as Ddu64CompressionError, D as Ddu64Core, h as Ddu64DecodeError, i as Ddu64DecompressionError, j as Ddu64DecryptionError, k as Ddu64EncodeError, l as Ddu64EncryptionError, m as Ddu64Error, n as Ddu64ErrorCode, o as Ddu64ErrorOptions, p as Ddu64LimitError, q as Ddu64ObfuscationError, r as Ddu64Operation, s as Ddu64StreamError, a as DduConstructorOptions, t as DduEncodeStats, u as DduOptions, v as DduProgressInfo, w as DduSetSymbol, x as DduTextEncoding, E as EncodingProfile, K as KeyDerivationAlgorithm, y as KeyDerivationOptions, O as ObfuscationLayer, P as PlatformAdapter, z as isDdu64Error } from './errors-DxOlTuHc.cjs';
3
+
4
+ /**
5
+ * ddunigma 비트 패킹 가속을 위한 WASM 로더 및 통합.
6
+ *
7
+ * 순수 JavaScript 구현과 바이트 단위로 동일한 선택적 WASM 가속
8
+ * 인코딩/디코딩을 제공합니다. WASM을 사용할 수 없거나 실패하면
9
+ * 조용히 JS로 폴백합니다.
10
+ *
11
+ * @module wasm/WasmCodec
12
+ */
13
+
14
+ /**
15
+ * WASM 모듈을 사전 로드하고 초기화합니다.
16
+ *
17
+ * 첫 번째 인코딩/디코딩 연산 전에 WASM이 준비되도록 애플리케이션 초기에
18
+ * 호출하세요. WASM이 초기화되면 resolve되고, 10초 내에 초기화에 실패하면
19
+ * reject됩니다.
20
+ *
21
+ * @throws WASM 초기화가 실패하거나 타임아웃(10초)된 경우 에러
22
+ */
23
+ declare function preloadWasm(): Promise<void>;
24
+ /**
25
+ * WASM 코덱이 준비되었으면 반환하거나, 온디맨드 초기화를 시도합니다.
26
+ *
27
+ * `preloadWasm()`이 호출되지 않았으면 5초 타임아웃으로 초기화를 시도합니다.
28
+ * WASM을 사용할 수 없으면 null을 반환합니다.
29
+ *
30
+ * 이 함수는 throw하지 않음 — 실패 시 null을 반환합니다.
31
+ */
32
+ declare function getWasmCodec(): WasmCodec | null;
33
+ /**
34
+ * WASM 코덱이 이미 초기화된 경우에만 반환합니다.
35
+ * 온디맨드 초기화를 트리거하지 않습니다.
36
+ * WASM이 준비되지 않았으면 null을 반환합니다.
37
+ */
38
+ declare function getWasmCodecSync(): WasmCodec | null;
39
+
40
+ export { WasmCodec, getWasmCodec, getWasmCodecSync, preloadWasm };
package/dist/core.d.ts CHANGED
@@ -1 +1,40 @@
1
- export { C as CharSetConfig, b as CharSetInfo, c as CharsetBuilder, D as Ddu64, D as Ddu64Core, a as DduConstructorOptions, d as DduEncodeStats, e as DduOptions, f as DduProgressInfo, g as DduSetSymbol, h as DduTextEncoding, E as EncodingProfile, K as KeyDerivationAlgorithm, i as KeyDerivationOptions, O as ObfuscationLayer, P as PlatformAdapter, W as WasmCodec, j as getWasmCodec, k as getWasmCodecSync, p as preloadWasm } from './core-DYSnygnp.js';
1
+ import { W as WasmCodec } from './errors-DxOlTuHc.js';
2
+ export { C as CharSetConfig, b as CharSetInfo, c as CharsetBuilder, D as Ddu64, d as Ddu64AdapterError, e as Ddu64CharsetError, f as Ddu64ChecksumError, g as Ddu64CompressionError, D as Ddu64Core, h as Ddu64DecodeError, i as Ddu64DecompressionError, j as Ddu64DecryptionError, k as Ddu64EncodeError, l as Ddu64EncryptionError, m as Ddu64Error, n as Ddu64ErrorCode, o as Ddu64ErrorOptions, p as Ddu64LimitError, q as Ddu64ObfuscationError, r as Ddu64Operation, s as Ddu64StreamError, a as DduConstructorOptions, t as DduEncodeStats, u as DduOptions, v as DduProgressInfo, w as DduSetSymbol, x as DduTextEncoding, E as EncodingProfile, K as KeyDerivationAlgorithm, y as KeyDerivationOptions, O as ObfuscationLayer, P as PlatformAdapter, z as isDdu64Error } from './errors-DxOlTuHc.js';
3
+
4
+ /**
5
+ * ddunigma 비트 패킹 가속을 위한 WASM 로더 및 통합.
6
+ *
7
+ * 순수 JavaScript 구현과 바이트 단위로 동일한 선택적 WASM 가속
8
+ * 인코딩/디코딩을 제공합니다. WASM을 사용할 수 없거나 실패하면
9
+ * 조용히 JS로 폴백합니다.
10
+ *
11
+ * @module wasm/WasmCodec
12
+ */
13
+
14
+ /**
15
+ * WASM 모듈을 사전 로드하고 초기화합니다.
16
+ *
17
+ * 첫 번째 인코딩/디코딩 연산 전에 WASM이 준비되도록 애플리케이션 초기에
18
+ * 호출하세요. WASM이 초기화되면 resolve되고, 10초 내에 초기화에 실패하면
19
+ * reject됩니다.
20
+ *
21
+ * @throws WASM 초기화가 실패하거나 타임아웃(10초)된 경우 에러
22
+ */
23
+ declare function preloadWasm(): Promise<void>;
24
+ /**
25
+ * WASM 코덱이 준비되었으면 반환하거나, 온디맨드 초기화를 시도합니다.
26
+ *
27
+ * `preloadWasm()`이 호출되지 않았으면 5초 타임아웃으로 초기화를 시도합니다.
28
+ * WASM을 사용할 수 없으면 null을 반환합니다.
29
+ *
30
+ * 이 함수는 throw하지 않음 — 실패 시 null을 반환합니다.
31
+ */
32
+ declare function getWasmCodec(): WasmCodec | null;
33
+ /**
34
+ * WASM 코덱이 이미 초기화된 경우에만 반환합니다.
35
+ * 온디맨드 초기화를 트리거하지 않습니다.
36
+ * WASM이 준비되지 않았으면 null을 반환합니다.
37
+ */
38
+ declare function getWasmCodecSync(): WasmCodec | null;
39
+
40
+ export { WasmCodec, getWasmCodec, getWasmCodecSync, preloadWasm };
package/dist/core.js CHANGED
@@ -1,2 +1,2 @@
1
- export{l as CharsetBuilder,k as Ddu64,k as Ddu64Core,d as DduSetSymbol,h as getWasmCodec,i as getWasmCodecSync,g as preloadWasm}from'./chunk-KEWLOPEV.js';//# sourceMappingURL=core.js.map
1
+ export{C as CharsetBuilder,B as Ddu64,s as Ddu64AdapterError,q as Ddu64CharsetError,p as Ddu64ChecksumError,l as Ddu64CompressionError,B as Ddu64Core,k as Ddu64DecodeError,m as Ddu64DecompressionError,o as Ddu64DecryptionError,j as Ddu64EncodeError,n as Ddu64EncryptionError,i as Ddu64Error,h as Ddu64ErrorCode,r as Ddu64LimitError,t as Ddu64ObfuscationError,u as Ddu64StreamError,a as DduSetSymbol,e as getWasmCodec,f as getWasmCodecSync,v as isDdu64Error,d as preloadWasm}from'./chunk-65RDFQV7.js';//# sourceMappingURL=core.js.map
2
2
  //# sourceMappingURL=core.js.map
@@ -159,23 +159,11 @@ interface DduConstructorOptions extends DduOptions {
159
159
  paddingChar?: string;
160
160
  /** 필요 문자 수 */
161
161
  requiredLength?: number;
162
- /**
163
- * 비트 길이.
164
- * @deprecated 무시되는 옵션입니다. 심볼당 비트 수는 charset 길이에서 자동 계산됩니다.
165
- */
166
- bitLength?: number;
167
162
  /** 2의 제곱수 강제 여부 */
168
163
  usePowerOfTwo?: boolean;
169
164
  /**
170
165
  * true이면 초기화 오류 시 throw합니다. false이면 fallback charset으로 대체합니다.
171
166
  * @default false
172
- * @deprecated throwOnError를 사용하세요. 이 옵션은 하위 호환성을 위해 유지됩니다.
173
- */
174
- useBuildErrorReturn?: boolean;
175
- /**
176
- * true이면 초기화 오류 시 throw합니다. false이면 fallback charset으로 대체합니다.
177
- * useBuildErrorReturn과 동일한 동작이며, 둘 다 지정 시 throwOnError가 우선합니다.
178
- * @default false
179
167
  */
180
168
  throwOnError?: boolean;
181
169
  /** URL-Safe 모드 (특수문자를 URL 안전 문자로 변환) */
@@ -188,7 +176,7 @@ interface DduConstructorOptions extends DduOptions {
188
176
  useRepeatPadding?: boolean;
189
177
  /** 명시적 플랫폼 어댑터 (자동 감지 대신 사용) */
190
178
  adapter?: PlatformAdapter;
191
- /** WASM 임계값 (바이트 단위, 기본값: 4096, 범위: 1024-1048576) */
179
+ /** WASM 임계값 (바이트 단위, 기본값: 4096, 범위: 1024-1048576, Infinity면 비활성화) */
192
180
  wasmThreshold?: number;
193
181
  }
194
182
  /**
@@ -204,13 +192,13 @@ interface PlatformAdapter {
204
192
  /** 동기적으로 256비트 키를 파생 (Node.js 전용) */
205
193
  deriveKeySync?(key: string, options?: KeyDerivationOptions): Uint8Array;
206
194
  /** AES-256-GCM으로 데이터를 암호화. IV(12) + authTag(16) + 암호문을 반환 */
207
- encrypt(data: Uint8Array, keyHash: Uint8Array): Promise<Uint8Array>;
195
+ encrypt(data: Uint8Array, keyHash: Uint8Array, aad?: Uint8Array): Promise<Uint8Array>;
208
196
  /** 동기적으로 데이터를 암호화 (Node.js 전용) */
209
- encryptSync?(data: Uint8Array, keyHash: Uint8Array): Uint8Array;
197
+ encryptSync?(data: Uint8Array, keyHash: Uint8Array, aad?: Uint8Array): Uint8Array;
210
198
  /** AES-256-GCM 페이로드를 복호화. IV(12) + authTag(16) + 암호문 형식을 기대 */
211
- decrypt(data: Uint8Array, keyHash: Uint8Array): Promise<Uint8Array>;
199
+ decrypt(data: Uint8Array, keyHash: Uint8Array, aad?: Uint8Array): Promise<Uint8Array>;
212
200
  /** 동기적으로 데이터를 복호화 (Node.js 전용) */
213
- decryptSync?(data: Uint8Array, keyHash: Uint8Array): Uint8Array;
201
+ decryptSync?(data: Uint8Array, keyHash: Uint8Array, aad?: Uint8Array): Uint8Array;
214
202
  /** 암호학적으로 안전한 랜덤 바이트를 생성 */
215
203
  randomBytes(length: number): Uint8Array;
216
204
  /** deflate 알고리즘으로 데이터를 압축 */
@@ -379,12 +367,14 @@ declare class Ddu64Core {
379
367
  private readonly wasmThreshold;
380
368
  /** 표준 Base64 charset에서 네이티브 Base64 fast path 사용 여부 */
381
369
  private readonly canUseNativeBase64;
370
+ /** 인코딩/디코딩 payload codec 공유 컨텍스트 */
371
+ private readonly payloadCodecContext;
382
372
  /** 플랫폼 어댑터 (동기용 지연 로드 또는 명시적 제공) */
383
373
  private adapter;
384
374
  /** 기본 난독화 활성화 */
385
375
  private readonly defaultObfuscate;
386
376
  /** 지연 초기화되는 난독화 레이어 */
387
- private _obfuscationLayer;
377
+ private obfuscationLayer;
388
378
  constructor(dduChar?: string[] | string | DduConstructorOptions, paddingChar?: string, dduOptions?: DduConstructorOptions);
389
379
  /**
390
380
  * 입력 데이터를 charset 인코딩 문자열로 인코딩합니다.
@@ -393,6 +383,7 @@ declare class Ddu64Core {
393
383
  * @param options - 인코딩 옵션
394
384
  * @returns 인코딩된 문자열
395
385
  * @throws 동기 암호화/압축이 필요하지만 어댑터가 지원하지 않는 경우
386
+ * @group Sync
396
387
  */
397
388
  encode(input: Uint8Array | string, options?: DduOptions): string;
398
389
  /**
@@ -401,6 +392,7 @@ declare class Ddu64Core {
401
392
  * @param input - 디코딩할 인코딩된 문자열
402
393
  * @param options - 디코딩 옵션
403
394
  * @returns 디코딩된 문자열
395
+ * @group Sync
404
396
  */
405
397
  decode(input: string, options?: DduOptions): string;
406
398
  /**
@@ -409,33 +401,46 @@ declare class Ddu64Core {
409
401
  * @param input - 디코딩할 인코딩된 문자열
410
402
  * @param options - 디코딩 옵션
411
403
  * @returns 디코딩된 바이트
404
+ * @group Sync
412
405
  */
413
406
  decodeToUint8Array(input: string, options?: DduOptions): Uint8Array;
407
+ private decodeToUint8ArrayInternal;
414
408
  /**
415
409
  * 비동기 인코딩 - 브라우저를 포함한 모든 런타임에서 동작합니다.
410
+ *
411
+ * @group Async
416
412
  */
417
413
  encodeAsync(input: Uint8Array | string, options?: DduOptions): Promise<string>;
414
+ private encodeAsyncInternal;
418
415
  /**
419
416
  * 비동기 디코딩 - 브라우저를 포함한 모든 런타임에서 동작합니다.
417
+ *
418
+ * @group Async
420
419
  */
421
420
  decodeAsync(input: string, options?: DduOptions): Promise<string>;
422
421
  /**
423
422
  * 비동기 Uint8Array 디코딩 - 브라우저를 포함한 모든 런타임에서 동작합니다.
423
+ *
424
+ * @group Async
424
425
  */
425
426
  decodeToUint8ArrayAsync(input: string, options?: DduOptions): Promise<Uint8Array>;
427
+ private decodeToUint8ArrayAsyncInternal;
426
428
  /**
427
429
  * charset 정보를 가져옵니다.
430
+ *
431
+ * @group Introspection
428
432
  */
429
433
  getCharSetInfo(): CharSetInfo;
430
434
  /**
431
435
  * 인코딩 통계를 가져옵니다.
436
+ *
437
+ * @group Introspection
432
438
  */
433
439
  getStats(input: Uint8Array | string, options?: DduOptions): DduEncodeStats;
434
440
  /**
435
441
  * 통계를 위한 메타데이터 포함 내부 인코딩.
436
442
  */
437
443
  private encodeInternal;
438
- private resolveEncodeSettings;
439
444
  /**
440
445
  * 인코딩 마무리: 비트팩 인코딩 + 후처리(난독화/체크섬/URL-safe/청킹).
441
446
  * 동기/비동기 인코딩에서 공유하는 순수 동기 단계입니다.
@@ -445,43 +450,19 @@ declare class Ddu64Core {
445
450
  * 인코딩 후처리: 난독화, 체크섬, URL-safe, 청킹을 적용합니다.
446
451
  */
447
452
  private applyPostEncoding;
448
- /**
449
- * BitPack + 푸터를 사용하여 바이트를 charset 문자열로 인코딩합니다.
450
- */
451
- private encodeBytes;
452
453
  /**
453
454
  * 디코딩 전처리: 동기/비동기 디코딩에서 공통으로 쓰는 순수 동기 단계.
454
455
  * 청크 제거 → URL-safe 역변환 → 체크섬 추출 → 역난독화 → 푸터 파싱 →
455
456
  * 검증(정렬/패딩/크기) → 비트팩 해제까지 수행합니다.
456
457
  */
457
458
  private decodePrelude;
458
- /**
459
- * 압축 해제 단계를 실행해야 하는지 결정합니다.
460
- * (압축 마커 존재 + 내부 압축 해제 허용 + 파이프라인 단계 조건)
461
- */
462
- private shouldDecompress;
463
- /**
464
- * 추출된 체크섬이 있으면 복원된 데이터의 CRC32와 비교 검증합니다.
465
- * 동기/비동기 디코딩에서 공유하는 순수 동기 단계입니다.
466
- */
467
- private verifyDecodedChecksum;
468
- /**
469
- * charset 문자열을 인덱스로 변환한 후 BitPack으로 바이트를 얻습니다.
470
- */
471
- private decodeChars;
472
- private encodeBytesWithNativeBase64;
473
- private decodeCharsWithNativeBase64;
474
- private bytesToBase64;
475
- private base64ToBytes;
476
- private shouldUseWasm;
459
+ private getPayloadCodecContext;
477
460
  private reportProgress;
478
- private requireSyncAdapter;
479
461
  private encryptSync;
480
462
  private decryptSync;
481
463
  private compressSync;
482
464
  private decompressSync;
483
- private getAdapterAsync;
484
- private getKeyHashAsync;
465
+ private getSyncGatewayContext;
485
466
  /**
486
467
  * 난독화 레이어를 가져오거나 생성합니다 (지연 초기화).
487
468
  * 알파벳에는 charset 문자, 패딩 문자, 모든 푸터 마커 문자가 포함됩니다.
@@ -493,12 +474,8 @@ declare class Ddu64Core {
493
474
  * 암호화 키 없이 난독화가 활성화되면 throw합니다.
494
475
  */
495
476
  private shouldObfuscate;
496
- private normalizeLimit;
497
477
  private assertSafeChunkSeparator;
498
478
  private isLineBreakSeparator;
499
- private estimateDecodedBytes;
500
- private assertEncodedInputAligned;
501
- private assertCanonicalPadding;
502
479
  }
503
480
 
504
481
  /**
@@ -634,39 +611,75 @@ declare class CharsetBuilder {
634
611
  }
635
612
 
636
613
  /**
637
- * ddunigma 비트 패킹 가속을 위한 WASM 로더 및 통합.
614
+ * ddunigma custom error hierarchy.
638
615
  *
639
- * 순수 JavaScript 구현과 바이트 단위로 동일한 선택적 WASM 가속
640
- * 인코딩/디코딩을 제공합니다. WASM을 사용할 없거나 실패하면
641
- * 조용히 JS로 폴백합니다.
616
+ * Public encode/decode APIs wrap internal/runtime failures in these typed
617
+ * errors so callers can branch on a stable code without parsing messages.
642
618
  *
643
- * @module wasm/WasmCodec
619
+ * @module core/errors
644
620
  */
621
+ type Ddu64Operation = "construct" | "encode" | "decode" | "compress" | "decompress" | "encrypt" | "decrypt" | "checksum" | "charset" | "adapter" | "obfuscation" | "stream";
622
+ declare enum Ddu64ErrorCode {
623
+ EncodeFailed = "DDU64_ENCODE_FAILED",
624
+ DecodeFailed = "DDU64_DECODE_FAILED",
625
+ CompressionFailed = "DDU64_COMPRESSION_FAILED",
626
+ DecompressionFailed = "DDU64_DECOMPRESSION_FAILED",
627
+ EncryptionFailed = "DDU64_ENCRYPTION_FAILED",
628
+ DecryptionFailed = "DDU64_DECRYPTION_FAILED",
629
+ ChecksumMismatch = "DDU64_CHECKSUM_MISMATCH",
630
+ InvalidCharset = "DDU64_INVALID_CHARSET",
631
+ InvalidInput = "DDU64_INVALID_INPUT",
632
+ LimitExceeded = "DDU64_LIMIT_EXCEEDED",
633
+ AdapterUnavailable = "DDU64_ADAPTER_UNAVAILABLE",
634
+ ObfuscationFailed = "DDU64_OBFUSCATION_FAILED",
635
+ StreamFailed = "DDU64_STREAM_FAILED"
636
+ }
637
+ interface Ddu64ErrorOptions {
638
+ code: Ddu64ErrorCode;
639
+ operation: Ddu64Operation;
640
+ cause?: unknown;
641
+ }
642
+ declare class Ddu64Error extends Error {
643
+ readonly code: Ddu64ErrorCode;
644
+ readonly operation: Ddu64Operation;
645
+ constructor(message: string, options: Ddu64ErrorOptions);
646
+ }
647
+ declare class Ddu64EncodeError extends Ddu64Error {
648
+ constructor(message: string, cause?: unknown);
649
+ }
650
+ declare class Ddu64DecodeError extends Ddu64Error {
651
+ constructor(message: string, cause?: unknown);
652
+ }
653
+ declare class Ddu64CompressionError extends Ddu64Error {
654
+ constructor(message: string, cause?: unknown);
655
+ }
656
+ declare class Ddu64DecompressionError extends Ddu64Error {
657
+ constructor(message: string, cause?: unknown);
658
+ }
659
+ declare class Ddu64EncryptionError extends Ddu64Error {
660
+ constructor(message: string, cause?: unknown);
661
+ }
662
+ declare class Ddu64DecryptionError extends Ddu64Error {
663
+ constructor(message: string, cause?: unknown);
664
+ }
665
+ declare class Ddu64ChecksumError extends Ddu64Error {
666
+ constructor(message: string, cause?: unknown);
667
+ }
668
+ declare class Ddu64CharsetError extends Ddu64Error {
669
+ constructor(message: string, cause?: unknown);
670
+ }
671
+ declare class Ddu64LimitError extends Ddu64Error {
672
+ constructor(message: string, operation: Ddu64Operation, cause?: unknown);
673
+ }
674
+ declare class Ddu64AdapterError extends Ddu64Error {
675
+ constructor(message: string, operation: Ddu64Operation, cause?: unknown);
676
+ }
677
+ declare class Ddu64ObfuscationError extends Ddu64Error {
678
+ constructor(message: string, cause?: unknown);
679
+ }
680
+ declare class Ddu64StreamError extends Ddu64Error {
681
+ constructor(message: string, cause?: unknown);
682
+ }
683
+ declare function isDdu64Error(error: unknown): error is Ddu64Error;
645
684
 
646
- /**
647
- * WASM 모듈을 사전 로드하고 초기화합니다.
648
- *
649
- * 첫 번째 인코딩/디코딩 연산 전에 WASM이 준비되도록 애플리케이션 초기에
650
- * 호출하세요. WASM이 초기화되면 resolve되고, 10초 내에 초기화에 실패하면
651
- * reject됩니다.
652
- *
653
- * @throws WASM 초기화가 실패하거나 타임아웃(10초)된 경우 에러
654
- */
655
- declare function preloadWasm(): Promise<void>;
656
- /**
657
- * WASM 코덱이 준비되었으면 반환하거나, 온디맨드 초기화를 시도합니다.
658
- *
659
- * `preloadWasm()`이 호출되지 않았으면 5초 타임아웃으로 초기화를 시도합니다.
660
- * WASM을 사용할 수 없으면 null을 반환합니다.
661
- *
662
- * 이 함수는 throw하지 않음 — 실패 시 null을 반환합니다.
663
- */
664
- declare function getWasmCodec(): WasmCodec | null;
665
- /**
666
- * WASM 코덱이 이미 초기화된 경우에만 반환합니다.
667
- * 온디맨드 초기화를 트리거하지 않습니다.
668
- * WASM이 준비되지 않았으면 null을 반환합니다.
669
- */
670
- declare function getWasmCodecSync(): WasmCodec | null;
671
-
672
- export { type CharSetConfig as C, Ddu64Core as D, type EncodingProfile as E, type KeyDerivationAlgorithm as K, type ObfuscationLayer as O, type PlatformAdapter as P, type TestVector as T, type WasmCodec as W, type DduConstructorOptions as a, type CharSetInfo as b, CharsetBuilder as c, type DduEncodeStats as d, type DduOptions as e, type DduProgressInfo as f, DduSetSymbol as g, type DduTextEncoding as h, type KeyDerivationOptions as i, getWasmCodec as j, getWasmCodecSync as k, preloadWasm as p };
685
+ export { type CharSetConfig as C, Ddu64Core as D, type EncodingProfile as E, type KeyDerivationAlgorithm as K, type ObfuscationLayer as O, type PlatformAdapter as P, type TestVector as T, type WasmCodec as W, type DduConstructorOptions as a, type CharSetInfo as b, CharsetBuilder as c, Ddu64AdapterError as d, Ddu64CharsetError as e, Ddu64ChecksumError as f, Ddu64CompressionError as g, Ddu64DecodeError as h, Ddu64DecompressionError as i, Ddu64DecryptionError as j, Ddu64EncodeError as k, Ddu64EncryptionError as l, Ddu64Error as m, Ddu64ErrorCode as n, type Ddu64ErrorOptions as o, Ddu64LimitError as p, Ddu64ObfuscationError as q, type Ddu64Operation as r, Ddu64StreamError as s, type DduEncodeStats as t, type DduOptions as u, type DduProgressInfo as v, DduSetSymbol as w, type DduTextEncoding as x, type KeyDerivationOptions as y, isDdu64Error as z };