@@ -72,8 +72,8 @@ describe('generateLicenseKey', () => {
7272 expect ( parts ) . toHaveLength ( 2 )
7373
7474 // Both parts should be base64 encoded
75- expect ( ( ) => atob ( parts [ 0 ] ) ) . not . toThrow ( )
76- expect ( ( ) => atob ( parts [ 1 ] ) ) . not . toThrow ( )
75+ expect ( ( ) => Buffer . from ( parts [ 0 ] , 'base64' ) ) . not . toThrow ( )
76+ expect ( ( ) => Buffer . from ( parts [ 1 ] , 'base64' ) ) . not . toThrow ( )
7777 } )
7878
7979 it ( 'embeds license data in the payload' , async ( ) => {
@@ -89,7 +89,7 @@ describe('generateLicenseKey', () => {
8989
9090 const key = await generateLicenseKey ( licenseData , privateKeyHex )
9191 const [ payloadBase64 ] = key . split ( '.' )
92- const payloadJson = atob ( payloadBase64 )
92+ const payloadJson = Buffer . from ( payloadBase64 , 'base64' ) . toString ( 'utf-8' )
9393 const decoded = JSON . parse ( payloadJson ) as LicenseData
9494
9595 expect ( decoded . email ) . toBe ( licenseData . email )
@@ -113,8 +113,8 @@ describe('generateLicenseKey', () => {
113113 const [ payloadBase64 , signatureBase64 ] = key . split ( '.' )
114114
115115 // Decode payload and signature
116- const payloadBytes = Uint8Array . from ( atob ( payloadBase64 ) , ( c ) => c . charCodeAt ( 0 ) )
117- const signatureBytes = Uint8Array . from ( atob ( signatureBase64 ) , ( c ) => c . charCodeAt ( 0 ) )
116+ const payloadBytes = new Uint8Array ( Buffer . from ( payloadBase64 , 'base64' ) )
117+ const signatureBytes = new Uint8Array ( Buffer . from ( signatureBase64 , 'base64' ) )
118118
119119 // Verify signature
120120 const isValid = await ed . verifyAsync ( signatureBytes , payloadBytes , publicKey )
@@ -145,7 +145,7 @@ describe('generateLicenseKey', () => {
145145 }
146146 const tamperedPayload = JSON . stringify ( tamperedData )
147147 const tamperedPayloadBytes = new TextEncoder ( ) . encode ( tamperedPayload )
148- const signatureBytes = Uint8Array . from ( atob ( signatureBase64 ) , ( c ) => c . charCodeAt ( 0 ) )
148+ const signatureBytes = new Uint8Array ( Buffer . from ( signatureBase64 , 'base64' ) )
149149
150150 // Signature should NOT verify for tampered payload
151151 const isValid = await ed . verifyAsync ( signatureBytes , tamperedPayloadBytes , publicKey )
@@ -166,7 +166,7 @@ describe('generateLicenseKey', () => {
166166
167167 const key = await generateLicenseKey ( licenseData , privateKeyHex )
168168 const [ payloadBase64 ] = key . split ( '.' )
169- const payloadJson = atob ( payloadBase64 )
169+ const payloadJson = Buffer . from ( payloadBase64 , 'base64' ) . toString ( 'utf-8' )
170170 const decoded = JSON . parse ( payloadJson ) as LicenseData
171171
172172 expect ( decoded . organizationName ) . toBe ( 'Acme Corporation' )
@@ -188,7 +188,7 @@ describe('generateLicenseKey', () => {
188188
189189 const key = await generateLicenseKey ( licenseData , privateKeyHex )
190190 const [ payloadBase64 ] = key . split ( '.' )
191- const payloadJson = atob ( payloadBase64 )
191+ const payloadJson = Buffer . from ( payloadBase64 , 'base64' ) . toString ( 'utf-8' )
192192 const decoded = JSON . parse ( payloadJson ) as LicenseData
193193
194194 expect ( decoded . organizationName ) . toBeUndefined ( )
@@ -218,7 +218,7 @@ describe('generateLicenseKey', () => {
218218 }
219219 const tamperedPayload = JSON . stringify ( tamperedData )
220220 const tamperedPayloadBytes = new TextEncoder ( ) . encode ( tamperedPayload )
221- const signatureBytes = Uint8Array . from ( atob ( signatureBase64 ) , ( c ) => c . charCodeAt ( 0 ) )
221+ const signatureBytes = new Uint8Array ( Buffer . from ( signatureBase64 , 'base64' ) )
222222
223223 // Signature should NOT verify for tampered org name
224224 const isValid = await ed . verifyAsync ( signatureBytes , tamperedPayloadBytes , publicKey )
0 commit comments