Prototype: use jose with breaking async/WebCrypto APIs - #39783
Draft
Jeremy Meng (jeremymeng) wants to merge 2 commits into
Draft
Prototype: use jose with breaking async/WebCrypto APIs#39783Jeremy Meng (jeremymeng) wants to merge 2 commits into
Jeremy Meng (jeremymeng) wants to merge 2 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1c3d3029-218c-4152-ba5f-09e19ef12976
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1c3d3029-218c-4152-ba5f-09e19ef12976
7 tasks
|
Azure Pipelines: Successfully started running 1 pipeline(s). 9 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Copilot agent
(on behalf of Jeremy Meng (@jeremymeng)): This is a throwaway alternative prototype for issue #39762 that evaluates replacing the
@azure/attestationproduction JWS implementation withjosewhen major-version breaking API and platform changes are allowed. It is intentionally a draft exploration, not a production-ready replacement while unpolyfilled React Native remains supported.Addresses #39762. Compare with the merge-ready synchronous compatibility approach in #39766.
Breaking API changes and propagation
AttestationToken.getTokenProblems(...)changes fromstring[]toPromise<string[]>.createAttestationPolicyToken(...)changes fromAttestationPolicyTokentoPromise<AttestationPolicyToken>.AttestationTokenImpl.create, JWS creation/verification, signing-key validation, and certificate key-type detection become asynchronous.AttestationClientresponse-validation paths, sixAttestationAdministrationClientresponse-validation paths, four administration request-token creation paths, two certificate-management key-type checks, samples, snippets/README, and tests.getBody(),serialize(), and token property getters remain synchronous.jose and X.509 design
importPKCS8,importX509,CompactSign, andcompactVerifywith explicit algorithm allowlists.alg: noneuses jose base64url primitives because jose compact signing rejectsnone, whileUnsecuredJWTwould reserialize claims and cannot preserve raw or empty payloads.importX509covers public-key import and RSA/P-256 detection, so@peculiar/x509is not required.Evidence
@noble/curves+node-forge-> zero-dependency MITjose@^6.2.9.Runtime and validation
Run all prototype evidence from the repository root:
Platform and security decision
The browser and Node paths are viable and materially smaller. React Native 0.84 does not provide
crypto.subtle: its target compiles, but runtime signing and verification require a tested WebCrypto native bridge/polyfill or a platform-specific fallback. A jose-only replacement therefore cannot preserve out-of-box React Native support.Security benefits include maintained JOSE code, native WebCrypto, explicit RS256/ES256 allowlists, no private-key export, canonical compact-JWS checks, and substantially less custom crypto/DER code. Tradeoffs include runtime-dependent WebCrypto behavior, retained unsecured-token semantics, no certificate trust validation, and an extra verification operation during signing to prove key/certificate ownership.
This draft remains pending decisions on the major-version async API change and whether WebCrypto may become a platform prerequisite, React Native may be dropped, or a tested React Native bridge/fallback is acceptable.