File tree Expand file tree Collapse file tree 4 files changed +60
-4
lines changed Expand file tree Collapse file tree 4 files changed +60
-4
lines changed Original file line number Diff line number Diff line change @@ -195,6 +195,23 @@ export class DataTransformInterceptor implements NestInterceptor {
195195 private decodeValue ( value : unknown ) : unknown {
196196 if ( typeof value !== "string" ) return value ;
197197
198+ // Handle compressed data with 'comp:' prefix
199+ if ( value . startsWith ( "comp:" ) ) {
200+ try {
201+ const base64Data = value . slice ( 5 ) ; // Remove 'comp:' prefix
202+ const decoded = Buffer . from ( base64Data , "base64" ) . toString ( "utf8" ) ;
203+
204+ try {
205+ return JSON . parse ( decoded ) ;
206+ } catch {
207+ return decoded ;
208+ }
209+ } catch {
210+ return value ;
211+ }
212+ }
213+
214+ // Handle regular base64 encoded data
198215 try {
199216 const decoded = Buffer . from ( value , "base64" ) . toString ( "utf8" ) ;
200217
Original file line number Diff line number Diff line change @@ -164,9 +164,24 @@ function encodeValue(value: unknown): string {
164164function decodeValue ( value : unknown ) : unknown {
165165 if ( ! value || typeof value !== "string" ) return value ;
166166
167+ // Support 'comp:' prefix used by the web encoder for large strings
168+ if ( value . startsWith ( "comp:" ) ) {
169+ try {
170+ const base64Data = value . slice ( 5 ) ;
171+ const decoded = Buffer . from ( base64Data , "base64" ) . toString ( "utf8" ) ;
172+ try {
173+ return JSON . parse ( decoded ) ;
174+ } catch {
175+ return decoded ;
176+ }
177+ } catch {
178+ return value ;
179+ }
180+ }
181+
182+ // Regular base64 decode
167183 try {
168184 const decoded = Buffer . from ( value , "base64" ) . toString ( "utf8" ) ;
169-
170185 try {
171186 return JSON . parse ( decoded ) ;
172187 } catch {
Original file line number Diff line number Diff line change 33export function decodeIfBase64 ( value : string | null ) : string | null {
44 if ( ! value ) return null ;
55
6+ // Support 'comp:' prefix used by the web client for large strings
7+ if ( value . startsWith ( "comp:" ) ) {
8+ try {
9+ const base64Data = value . slice ( 5 ) ;
10+ const decoded = Buffer . from ( base64Data , "base64" ) . toString ( "utf8" ) ;
11+ return decoded ;
12+ } catch {
13+ return value ;
14+ }
15+ }
16+
617 try {
718 const decoded = Buffer . from ( value , "base64" ) . toString ( "utf8" ) ;
8-
919 const reEncoded = Buffer . from ( decoded , "utf8" ) . toString ( "base64" ) ;
10-
1120 return reEncoded === value ? decoded : value ;
1221 } catch {
1322 return value ;
Original file line number Diff line number Diff line change @@ -211,9 +211,24 @@ export class DataTransformMiddleware implements NestMiddleware {
211211 private decodeValue ( value : unknown ) : unknown {
212212 if ( typeof value !== "string" ) return value ;
213213
214+ // Handle compressed payloads with the 'comp:' prefix (matches web encoder)
215+ if ( value . startsWith ( "comp:" ) ) {
216+ try {
217+ const base64Data = value . slice ( 5 ) ; // strip 'comp:'
218+ const decoded = Buffer . from ( base64Data , "base64" ) . toString ( "utf8" ) ;
219+ try {
220+ return JSON . parse ( decoded ) as unknown ;
221+ } catch {
222+ return decoded ;
223+ }
224+ } catch {
225+ return value ;
226+ }
227+ }
228+
229+ // Fallback: regular base64 encoded strings
214230 try {
215231 const decoded = Buffer . from ( value , "base64" ) . toString ( "utf8" ) ;
216-
217232 try {
218233 return JSON . parse ( decoded ) as unknown ;
219234 } catch {
You can’t perform that action at this time.
0 commit comments