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)
Mon, Jul 1, 12:43 PM
Unknown Object (File)
Mon, Jul 1, 12:43 PM
Unknown Object (File)
Mon, Jul 1, 12:41 PM
Unknown Object (File)
Mon, Jul 1, 12:39 PM
Unknown Object (File)
Fri, Jun 28, 2:54 PM
Unknown Object (File)
Tue, Jun 25, 3:21 PM
Unknown Object (File)
Mon, Jun 24, 7:43 PM
Unknown Object (File)
Mon, Jun 24, 9:45 AM
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.