@@ -61,39 +61,15 @@ export const localizeCurrency =
61
61
62
62
export const waitForTimeout = timeout => new Promise ( resolve => setTimeout ( resolve , timeout ) ) ;
63
63
64
- export function btoa ( str ) {
65
- const buffer = Buffer . from ( str . toString ( ) , 'binary' ) ;
66
- return buffer . toString ( 'base64' ) ;
67
- }
68
-
69
- export function toBinary ( string ) {
70
- const codeUnits = new Uint16Array ( string . length ) ;
71
- for ( let i = 0 ; i < codeUnits . length ; i ++ ) {
72
- codeUnits [ i ] = string . charCodeAt ( i ) ;
73
- }
74
- return String . fromCharCode ( ...new Uint8Array ( codeUnits . buffer ) ) ;
75
- }
76
-
77
- export const createMockZoidMarkup = ( { component, scriptUID, port, encodedData } ) => {
64
+ export const createMockZoidMarkup = ( { component, scriptUID, port, jsonData } ) => {
78
65
const setupFunctionName = component === 'message' ? 'crc.setupMessage' : 'crc.setupModal' ;
79
66
80
67
const interfaceScript = `<script>var interface = (window.opener ?? window.parent).document.querySelector('[data-uid-auto="${ scriptUID } "]').outerHTML; document.write(interface);</script>` ;
81
68
const componentScript = `<script src="//localhost.paypal.com:${ port } /smart-credit-${ component } .js"></script>` ;
82
- const initializerScript = `<script>${ setupFunctionName } (JSON.parse(fromBinary(atob(document.firstChild.nodeValue))))</script>` ;
83
- const utilScript = `
84
- <script>
85
- function fromBinary(binary) {
86
- const bytes = new Uint8Array(binary.length);
87
- for (let i = 0; i < bytes.length; i++) {
88
- bytes[i] = binary.charCodeAt(i);
89
- }
90
- return String.fromCharCode.apply(null, new Uint16Array(bytes.buffer));
91
- }
92
- </script>
93
- ` ;
69
+ const initializerScript = `<script>${ setupFunctionName } (JSON.parse(document.firstChild.nodeValue))</script>` ;
94
70
95
71
return `
96
- <!--${ encodedData } -->
72
+ <!--${ jsonData } -->
97
73
<!DOCTYPE html>
98
74
<html lang="en">
99
75
<head>
@@ -104,7 +80,6 @@ export const createMockZoidMarkup = ({ component, scriptUID, port, encodedData }
104
80
<body>
105
81
${ component !== 'modal-v2-lander' ? interfaceScript : '' }
106
82
${ componentScript }
107
- ${ utilScript }
108
83
${ initializerScript }
109
84
</body>
110
85
</html>
0 commit comments