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)
Oct 3 2024, 11:47 PM
Unknown Object (File)
Oct 3 2024, 11:47 PM
Unknown Object (File)
Oct 3 2024, 11:46 PM
Unknown Object (File)
Oct 3 2024, 11:45 PM
Unknown Object (File)
Sep 7 2024, 9:57 AM
Unknown Object (File)
Sep 6 2024, 10:38 PM
Unknown Object (File)
Sep 2 2024, 5:00 PM
Unknown Object (File)
Sep 2 2024, 5:00 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
No Lint Coverage
Unit
No Test Coverage

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.