Page MenuHomePhabricator

[lib] Add function to create HTTP Authorization header
ClosedPublic

Authored by bartek on Feb 2 2024, 12:00 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 27, 2:02 PM
Unknown Object (File)
Sat, Nov 23, 11:56 PM
Unknown Object (File)
Sat, Nov 23, 11:48 PM
Unknown Object (File)
Sun, Nov 17, 5:29 PM
Unknown Object (File)
Fri, Nov 8, 10:03 PM
Unknown Object (File)
Fri, Nov 8, 7:15 PM
Unknown Object (File)
Fri, Nov 8, 7:15 PM
Unknown Object (File)
Fri, Nov 8, 1:36 PM
Subscribers
None

Details

Summary

Follow up discussion from https://phab.comm.dev/D10908?id=36504#inline-66205

  • Added base-64 dependency to lib (it already was in native)
  • Extracted createHTTPAuthorizationHeader function from D10908 - the header format is described in ENG-4657
  • Used base-64 in the function instead of passing platform-specific b64 implementations
Test Plan
  • Repeated test plan from D10908 (also repeated test plans for web and native from future diffs to make sure it works on all platforms)
  • Added unit test

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bartek published this revision for review.Feb 2 2024, 12:23 AM

Adding @ashoat because of dependency changes.
This dep was already in native, I copy-pasted it to lib, so no yarn.lock changes

Makes sense. I suppose we could use native implementations in some places (eg. Node.js), but not sure it matters too much for performance.

This revision is now accepted and ready to land.Feb 2 2024, 8:18 AM

Makes sense. I suppose we could use native implementations in some places (eg. Node.js), but not sure it matters too much for performance.

I did a quick benchmark: the base-64 lib vs Node Buffer vs web btoa and the differences are negligible for such small payloads (the Authorization payload is ~600-700 bytes long). All times were under 1ms.

Performance matters for encrypted multimedia, where payloads' sizes are hundreds of kB to dozens of MB.