Граф коммитов

151 Коммитов

Автор SHA1 Сообщение Дата
Julio César Rocha 5a2f8d9941
Port Desktop DLL to ARM64EC (#13320)
* Add ARM64EC Platform

* Add property sheets

* Add packages.lock.json

* Upgrade WinSDK version for C/C++ projects
Older SDK versions do not contain softintrin.h
See http://www.emulators.com/docs/abc_arm64ec_explained.htm

* Do not build Integration Test projects for ARM64EC

* Make V8Platform x64 for ARM64EC

* Override HermesPlatform for ARM64EC

* Override WinAppSDK platforms for ARM64EC

* Exclude OpenSSL on Desktop DLL for ARM64EC

* Override WinAppSDK _MrtCoreRuntimeIdentifier

* Update packages.lock.json

* Add explicit LIB dependencies for ARM64EC

* Skip React.Windows.IntegrationTests on ARM64EC

* Change files

* Simplify condition for WindowsAppSDKOverrides

* Switch from ARM64 to ARM64EC in Desktop CI

* Update prepare-build-env.yml

* Enable ARM64EC on PullRequest env

* Remove OpenSSL from Desktop LIB and DLL

* /t:Vars - Log SolutionName
2024-06-10 15:55:29 -07:00
Julio César Rocha 53fe43a72a
Remove OpenSSL from Desktop LIB and DLL (#13321)
* Remove OpenSSL from Desktop LIB and DLL

* Change files
2024-06-10 20:41:58 +00:00
Julio César Rocha 25be51926c
Upgrade to Windows SDK 10.0.22621.0 (#13287)
## Description
Bumps and aligns the SDK version from `10.0.19041.0` to `10.0.22621.0`.

### Type of Change
- Bug fix (non-breaking change which fixes an issue)

### Why
- There is a requirement to build the Desktop DLL (`react-native-win32.dll`) for ARM64EC.\
  This makes Windows SDK 10.0.22621.0 necessary due to the dependency on intrinsics-related headers not available in version 10.0.19041.0.
- There is the added benefit of using the default SDK version installed by Visual Studio 2022, reducing the number of development dependencies.

Replaces #10869

### What
- Bumps all Win SDK references to version 22621.
- Adds installation of version 22621 in both installation scripts and CI.
2024-06-04 09:43:32 -07:00
Andrew Coates adc4d096eb
[Fabric] Support blob: images, and provide better image.onError callbacks (#13285)
* [Fabric] Support blob: images, and provide better image.onError callbacks

* Change files

* Remove some test code

* Add user-agent

* Add public API to set default User-Agent header

* various fixes

* fix snapshots

* Rename Networking -> HttpSettings

* Change files

* fix

* Http.UserAgent RuntimeOption needs to be set before the HttpResource is created
2024-06-03 17:15:34 -07:00
Julio César Rocha a09af289ff
Enable integration test web application (#12714)
* Create TestServices project
2024-03-20 22:42:33 +00:00
Jon Thysell 1adf98db52
Bump Microsoft.Windows.CppWinRT to 2.0.230706.1 (#12798)
## Description

This PR updates RNW to default version of `Microsoft.Windows.CppWinRT` to `2.0.230706.1`, the same version used by the VS 2022's WinAppSDK new app template.

This PR also makes sure that we use the 64bit toolset by default, because CppWinRT projectd require lots of resources to build, and compiling some configurations with the new version (namely for us, ARM64 new arch) requires more RAM than the 32-bit tools (compiler and linker) can access.

### Type of Change
- Bug fix (non-breaking change which fixes an issue)

### Why
We haven't update CppWinRT in several years, and as we build towards the new architecture on top of WinAppSDK we don't want to be using an outdated configuration.

### What
See above.

## Screenshots
N/A

## Testing
N/A

_Optional_: Describe the tests that you ran locally to verify your changes.

## Changelog
Should this change be included in the release notes: _yes_

Projects now depend on Microsoft.Windows.CppWinRT >= 2.0.230706.1
2024-03-19 16:36:05 -07:00
Jon Thysell 9bd3906f3b
Update WinAppSDK versions to latest public builds (#12747)
## Description

This PR updates the default versions of `Microsoft.WindowsAppSDK` used to 1.4.240211001 when `<UseWinUI3>true</UseWinUI3>` is specified, and 1.5.240124002-experimental2 when `<UseExperimentalWinUI3>true</UseExperimentalWinUI3>` is specified.

This PR also updates all of the `packages.lock json` files to the defaults.

### Type of Change

- Bug fix (non-breaking change which fixes an issue)

### Why
To keep up with the latest public versions of WinAppSDK.

### What
See above.

## Screenshots
N/A

## Testing
Ran both PR and new Secure PR checks to make sure that everything still builds and works.

## Changelog
Should this change be included in the release notes: yes

Updated WindowsAppSDK dependency to 1.4.240211001
2024-02-21 10:37:56 -08:00
Julio César Rocha d9bd78f3dd
Fix Base64 duplicate padding (#12689)
* Remove unused Boost headers from FR module source

* Declare encode/decode base64 utility methods

* Implement Encode methods

* Update packages.lock.json

* Update packages.lock.json

* Use string as return value to ensure lifetime

See https://learn.microsoft.com/en-us/cpp/code-quality/c26816?view=msvc-170

* Apply padding for Boost variant

* Remove decode from base64 wstring variant

* Cover 4*3 (plus empty) cases in unit tests

* Make output padding size match to input size % 4

* clang format

* Implement DecodeBase64

* Replace scattered usage of Boost base64_from_binary

* Remove Boost includes from BaseFrRc

* Change files

* Remove EncodeBase64(wstring_view)

* Add test for non-text values

* Pass string_view by value

* Ensure binary data lifetime in test
2024-02-08 20:27:30 +00:00
Vladimir Morozov 922e3bfb34
Change Hermes package version to 0.1.18 (#12405)
* Change Hermes package version to 0.1.18

* Change files

* Add missing package.lock.json files
2023-11-16 22:12:40 +00:00
Vladimir Morozov ac1f93b961
Cherry pick PRs #12143 #12211 (#12355)
* Cherry pick PRs #12143 #12211

* Change files

* Avoid jsi::Value duplication

* Restore conversion to double

* Add more (double) casts
2023-11-07 10:12:07 -08:00
Nick Gerleman 1c34a86dd0
C++ 20: Preprocessor definitions (#12324)
* C++ 20: Preprocessor definitions

This sets a couple new preprocessor conditions:
1. `FOLLY_CFG_NO_COROUTINES` to prevent types like `folly::optional` from bringing in Folly's coroutine stack when Folly detects C++ 20 coroutines as available.
2. `_SILENCE_CXX20_U8PATH_DEPRECATION_WARNING`: Because the deprecation came before a suitable replacement API. This is more scoped than the `_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS` used by `React.Cpp.props`.

* Change files
2023-11-01 20:27:41 +00:00
Julio César Rocha 7f45f2add4
Test disabling HTTP caching (#12103)
* Disable HTTP client caching

* Change files

* Add test GetDisableThenReenableCacheSucceeds

* Revert filter-level cache disable

* Update change file
2023-09-20 16:05:30 -07:00
Jon Thysell 5fd67d7ce5
Point Desktop.IntegrationTests::HttpResourceIntegrationTests to a non-rate limited API (#12056)
## Description

There are three tests in `Desktop.Integration`'s `HttpResourceIntegrationTests` which verify that requests against a server that requires a `User-Agent` will succeed with the header present and fail when it's missing.

To do this we're using a standard unauthenticated GitHub API endpoint.

However, we can also hit rate limiting on this endpoint, causing the tests to fail. This PR improves the stability of those tests by instead hitting an API with the same Header requirement, but without rate limiting.

### Type of Change

- Bug fix (non-breaking change which fixes an issue)

### Why

Stop good PRs from failing due to rate limiting causing tests to fail sporadically.

### What

Instead of hitting random GitHub API endpoints (and getting caught in unauthenticated rate limiting), instead change to calling the `/rate_limit` API, which has no rate limit itself.

## Screenshots
N/A

## Testing

Ran integration tests.

## Changelog
Should this change be included in the release notes: No
2023-08-22 14:00:59 -07:00
Jon Thysell 9917e3b45f
Enable NuGet restore lock files for all projects (#12002)
## Description

This PR specifies that all projects should set the msbuild property `RestorePackagesWithLockFile` to `true` by default, not just the C# ones.

This way we can ensure that PR/CI will build reliably because every locked version should be available in the react-native-public ADO feed. Changes to NuGet dependencies in PRs should now explicilty fail if the new package version is not in the ADO feed, and therefore require us to manually approve the addition to the feed (as required by compliance).

Closes #11998

### Type of Change
- Bug fix (non-breaking change which fixes an issue)
- Breaking change (fix or feature that would cause existing functionality to not work as expected)

### Why

This way we can ensure that PR/CI will build reliably because every locked version should be available in the react-native-public ADO feed. Changes to NuGet dependencies in PRs should now explicilty fail if the new package version is not in the ADO feed, and therefore require us to manually approve the addition to the feed (as required by compliance).

Closes #11998

### What
This PR specifies that all projects should set the msbuild property `RestorePackagesWithLockFile` to `true` by default, not just the C# ones.

## Screenshots
N/A

## Testing
N/A

## Changelog
Should this change be included in the release notes: no
2023-08-11 15:58:36 -07:00
Julio César Rocha bde337f669
Allow disabling Blob Cxx module (#11979)
* Define FetchTest

* Implement fetch test

* Allow disabling Blob Cxx module

* Change files

* Format FetchTest.js

* yarn lint
2023-08-04 15:33:53 -07:00
Julio César Rocha 791786e503
Attempt AddNetworkingHandler if HTTP module was not ready (#11926)
* Update packages.lock

* Remove HttpModule.h from OInstance.cpp

* Remove runtime option Blob.EnableModule

* Call SetupHttpResource only once

* Attempt AddNetworkingHandler if HTTP module was not ready

* Change files
2023-07-24 12:34:24 -07:00
Julio César Rocha 873bbb0a1f
Define HTTP TurboModule (#11825)
* Declare TurboModule

* Generate NativeNetworkingWindows spec

* Define HttpTurboModule

* Begin resource setup

* Initialize: Up to SetOnData

* Define wchar_t event names

* Migrate IRequestBodyHandler to JSValue

IMPORTANT: Migrate and fix RequestArgs::Data

* Migrate IResponseHandler to JSValue

* Rename m_onDataDynamic as m_onDataObject

* Implement Microsoft::React::Modules::ToJSValue

* Migrate IHttpResource to JSValue

* Fix Playground flavors ordering

* Finish implementing Initialize

* Define ToDynamic

* Change files

* Revert module.g.cpp

* Revert "Revert module.g.cpp"

This reverts commit 2f6c88a0a4.

* Define target SetCppWinRTReferences

* clang format

* Revert temporary symbol exports

* Fix RedirectHttpFilterUnitTest import order

* Preserve include ordering in RedirectHttpFilterUnitTest.cpp

* Fix JSValueArray list constructor

* Drop RCTNetworkingNative in favor of NativeNetworkingWindows

* Add NativeNetworkingWindows to overrides

* Fix overrides.json newline

* Desktop int. tests: set RN_PLATFORM to win32

* Use iterator to lookup content types

* Revert module.g.cpp to main

* Use iterator for ToRequestBody content type

* Drop namespace from JSValueObject usage

* Finish HttpTurboModule

* clang format

* Use iOS HTTP spec

* Use DynamicReader and DynamicWriter for folly conversions

* Revert overrides.json

* Don't add newline to overrides.json

* Make RCTNetworking.windows.js a copy of RCTNetworking.ios.js

* Override upgrade
2023-07-03 11:44:04 -07:00
Julio César Rocha 8e12ccc82e
Remove unused Beast-dependent code (#11517)
* Remove unused Beast production code

* Change files

* clang format

---------

Co-authored-by: Andrew Coates <30809111+acoates-ms@users.noreply.github.com>
2023-05-25 17:20:08 -07:00
Jon Thysell fe7d786b74
Fix typos and add `cspell` configuration (#11536)
## Description

This PR adds configuration files for `cspell`, which is available as a recommended VS Code plugin for this repo. This PR also fixes most "non-breaking" typos (comments, error messages, local names) for code files within the repo.

This PR **does not** add any kind of spell-checking enforcement on the repo.

### Type of Change
N/A

### Why

Clear up misunderstandings in comments / error messages.

### What
What changes were made to the codebase to solve the bug, add the functionality, etc. that you specified above.

## Screenshots
N/A

## Testing
N/A
2023-05-05 13:12:29 -07:00
Jon Thysell 657672e5ab
Fix Secure Supply Chain compliance issues (#11548)
## Description

Resolves Secure Supply Chain warnings.

### Type of Change
- Bug fix (non-breaking change which fixes an issue)

### Why

To meet compliance requirements.

Closes #11209
Closes #10374

### What

* Removed invalid `nuget.config` configurations
* Removed unnecessary `.npmrc` files
* Temporarily left nuget.org feed in config (tracking: #11557)

## Screenshots
N/A

## Testing
N/A
2023-05-04 14:45:12 -07:00
Andrew Coates ffef376555
Remove AsyncStorage (#10995)
* Remove AsyncStorage

* remove extra ,

* Change files

* Remove now unused winsqlite3.dll from delay load dlls
2023-01-09 16:14:42 -08:00
Julio César Rocha 594689bd2c
Always instantiate Blob module in UWP (#10848)
* Always instantiate Blob module inUWP

* Change files

* Remove legacy HTTP module from DLL boundary
2022-11-14 15:15:59 -08:00
Jon Thysell 5885ee4477
Upgrade to VS 2022 (#9916)
*Description*

This PR updates RNW to build with (and require) Visual Studio 2022. This includes upgrading the `Microsoft.ReactNative.Managed.CodeGen` project to .NET 6.0

This PR does not change the minimum / target Windows SDK versions for RNW or RNW apps.

This PR does not change the language versions of C++ (17) and C# (8.0) used.

*Type of Change*
- Breaking change (fix or feature that would cause existing functionality to not work as expected)
- This change requires a documentation update

*Why*
Visual Studio 2022 is the currently supported version of Visual Studio and what is available to download without an MSDN subscription to access older versions. As Visual Studio 2019 support is reduced/deprecated, we need to migrate. 

Closes #8750
Closes #9499 
Closes #10130

*What*

What's changed:

* All VS project files have been updated to require a minimum of VS 2022 (aka version 17.0).
    * NuGet-based dependencies that are tied to VS version have been upgraded.
* The `Microsoft.ReactNative.Managed.CodeGen` project has been updated to .NET 6.0
    * The snapshots for the codegen tests have been updated to pass
* The E2E Test app has been updated to the latest version of `react-native-xaml` (needed to fix build issues)
    * Snapshots for E2E tests have been updated to pass

*Testing*

Builds and tests All tests
2022-10-31 11:00:09 -07:00
Julio César Rocha 9ded99c24f
Set User-Agent header in Origin Policy filter (#10695)
* Set User-Agent and Origin in OP filter

* Fix Shared filters

* Change files

* Set the implicit User-Agent in RedirectHttpFilter
2022-10-07 23:35:57 +00:00
Julio César Rocha db790ad9d8
Implement HTTP redirection (#10534)
* Define WinRTHttpResult::CreateRequest

* Use request produced by CreateRequest()

TODO: Have PerformSendRequest receive raw method and uri instead of
HttpRequestMessage.

* Exit if request is not created successfully

* Enabled FullCorsCrossOriginToAnotherCrossOriginRedirectWithPreflightSucceeds

* Single retry

* Add test RedirectPatchSucceeds

* Rename tests to SimpleRedirect<VERB>Succeeds

* Use method and URI intead of full HTTPReqMsg in PerformSendReq

* Move HttpResourceIntegrationTest into workspace

* Add WinInet-based test

* Get request complete variables

* Define RequestContext struct

* Get response content

* Add synchronization logic

* Refer CoreFX reference PR and version

* Disable SimpleRedirectWinInetSucceeds

* Define RedirectHttpFilter

- Meant to be the default internal filter for WinRTHttpResource.

* Use redirect filter for OP and default clients in factory

* Implement RedirectHttpFilter::SendRequestAsync

TODO: Deal with IDS_REQUEST_ALREADY_SENT by making CreateRequest coroutine available to both the resource and filter classes.

* Expose resource as IWinRTHttpRequestFactory

- Allows redir filter to access resource's request factory method.

* Re-arrange resource instantiation in Make factory

* Re-enable disabled Origin Policy tests

* Make redir filter constructors noexcept

* Attempt to implement IHttpBaseProtocolFilter

* Make redir filter implement IHttpBaseProtocolFilter

* Enable inheritance of IHttpBPFilter via unsetting WINRT_LEAN_AND_MEAN

* Implement IHttpBPfilter based on inner filter

* Add RedirHttpFilterUTs class

* Fix comment

* Consume mocks in MockBaseFilter

* Implement mocks in ManualRedirectSucceeds

* Implement manual redir test with coroutines

* Complete [Manual|Automatic]RedirectSucceeds

* Allow setting max redirect # in constructor
- Add test TooManyRedirectsFails

* Add test MaxAllowedRedirectsSucceeds

* Minor requestArgs factoring

* Define and consume IRedirectEventSource

* Add IRedirectEventSource.idl to unit test project

* Update Shared vcx filters

* Partially implement OPFilter::OnRedirecting

* Update Shared filters

* Make OPFilter drop redirection for preflights

* Allow empty string, non-null req content

* Allow non-movable responses in test server (OPIntTests)

* Always clear Http.OmitCredentials rt option

* Update outdated comment

* Removed commented code

* Clean up stale/commented code

* Throw E_INVALIDARG if redirect gets null request handle

* Throw ERROR_HTTP_REDIRECT_FAILED on too many redirects

* Remove/ignore incorrect tests

* clang format

* Change files

* Update packages lock

* Remove Redir filter constructor from DLL boundary

* Drop unused libs/include dirs

* Restore ut project IncludePath

* Remove /*const*/ comments from HTTP mocks

* Explicitly capture `constexpr`

Implicit capture only available starting MSVC 14.3

* Declare redirect counts as size_t

* Update packages.lock.json

* Update packages lock

* Replace IInspectable with WinRT IMap (request props) in CreateRequest

* Make TaintedOrigin a direct request property.

The `RequestArgs` struct should not hold Origin POlicy specific data.

* clang format

* Fix compilation of filter and resource in MSRN

* Rename local variables

* Fix relative include of WinRTTypes

* Simplify redirect count tests

* Propagate isTimeout to JS layer

* Comment alternative HRESULTs for timeout

* Address feedback for internal MIDL type

* Update packages lock

* Use std::stol to parse Content-Length

* Use constexpr for default max redirects

* Drop WinRT/Http/Filters header from PCH

- This prevents including the header with WINRT_LEAN_AND_MEAN macro conflict.
- Only DevSupportManager required it. Performance loss is negligible.

* Add interface IRedirectEventSource2

* Remove IDL IRedirectEventSource

* Rename IRedirectEventSource2 to IRedirectEventSource

* Revert packages lock

* Remove stale IDL reference

* Throw on RedirectHttpFilter::AllowUI
2022-09-16 20:10:43 +00:00
Jon Thysell 864bbb2718
Update nuget feed declarations (#10332)
This PR changes our `NuGet.Config` files to be compliant. It assumes the following paradigm:

1. The NuGet.org feed contains all of the packages that RNW Universal/WinAppSDK projects require.
2. The `react-native-public` ADO feed contains all of the packages that RNW Desktop projects requires.

With this in mind, the `NuGet.Config` files have been updated as follows:

* The root and `vnext` `NuGet.Config` files no longer specify any package sources, so restores will default to the user's default, (usually NuGet.org).
* The Desktop* projects specify only the `react-native-public` ADO feed as a package source.

From an app/module customer point-of-view, unless they're trying to test canary builds of our `Microsoft.ReactNative.*`, they shouldn't need to use our ADO feeds at all. And even if they do, that's still fine. These changes are just making sure that when we build the official nugets in our pipelines, we're compliant. These `NuGet.Config` files aren't published to npm at all.

Closes #9992
Closes #9993
Closes #9996
Closes #9997
2022-08-03 15:40:47 -07:00
Julio César Rocha be2f3c3f4d
Implement HTTP client timeout (#10261)
* Implement hard-coded timeout

* Create timeout from JS args

* Timeout only for values greater than 0

* Change files

* Remove variable sendRequestAny

* Remove unused captures
2022-07-18 17:13:40 -07:00
Julio César Rocha 2983a5b601
Do not use Blob/FileReader modules in UWP (#10079)
* Do not use Blob/FileReader modules on UWP

* Change files

* Upgrade packages.lock.json

* Use runtime option Blob.EnableModule to condition instantiation
2022-06-08 17:34:31 -07:00
Julio César Rocha b412977a80
Implement Blob module (#9352)
* Added BlobModule and IWSModuleContHandler headers

* Implement Blob module

* Avoid raw self pointer in BlobModule

* Implement WebSocketModule msg processing

* clang format

* Don't return until websocketMessage event is sent

* Define CreateBlobModule()

* Add DEF exports

* Add Blob JS tests

* Add Blob JS tests

* Change files

* yarn lint

* Add overrides

* Register BlobModule in DesktopTestRunner

* Keep ignoring WebSocketBlob test by default

* Add BlobModule to default modules list

* Allow 'blob' responseType in HTTP module

* Ensure React Instance can be accessed when using older versions of react-native

* Emit error message on createFromParts failure

* Remove redundant extra modules in Desktop integration tests

* Declare IWebSocketModuleProxy

* Remove Blob and WS module factories from DLL boundary

* Implement IWebSocketModuleProxy

* clang format

* Update packages.lock

* Use winrt::array_view directly in ResolveMessage

* Define InstanceImpl::m_transitionalModuleProperties

* Include CreateModules.h in projects accessing MSRN.Cxx

* Define WinRT class WebSocketModuleContentHandler

- Have BlobModule constructor register the content handler in transitive
  property bag CxxNativeModule/WebSocketModuleContentHandler

* Have WebSocketModule use IInspectable as props arg

* Use property bag instead of global singletons for blob helpers

* Store blob helpers in prop bag as weak_ptr

* Replace remaining lock_guard<mutex> in BlobModule

* Define IUriHandler, IReqBodyHandler, IRespHandler.

* IHttpResource::SendRequest - add folly::dynamic data arg

* Add data arg to test SendRequest calls

* First implementation for BlobModuleUriHandler

* Remove WebSocketModuleContentHandler WinRT class

* Implement IBlobPersistor, MemoryBlobPersistor

* clang format

* Update yarn.lock

* Update RctRootVieTagGen location

* Implement addNetworkingHandler

* Fix createFromParts buffer persistence

* Drop WebSocketModule s_sharedState in favor of property bag

* Disable back WebSocketBlob test

* Rename iProperties to inspectableProperties

* Pass ReactContext properties to CreateHttpModule in InstanceWin

* Remove WebSocketModule constructor from x86 DLL boundary

* yarn lint

* Update packages.lock

* Make transitional property bag non-member

* Use blobURIScheme wherever possible

* Pass request content as folly::dynaic.

- Pass request ID directly from JavaScript layer.

* Use constexpr for folly indexes

* Implement GetMimeTypeFromUri

* Finish BlobModule handler implementations.

* Remove unused includes

* Ensure HttpModule::m_resource is set

* clang format

* clang format

* Allow blob responseType

* Use winrt::to_hstring instead of Utf8ToUtf16

* Pass inspectableProperties down to WinRTHttpResource

* Implement IHttpModuleProxy via WinRTHttpResource

* Consume URI handler

- IHttpResource
  - Rename SetOnRequest to SetOnRequestSuccess
  - Declare SetOnBlobData to pass complex (non-string) response data

* Consume IRequestBodyHandler

* Consume IResponseHandler

* Ensure properties exist in bag before using value

* Update packages lock

* Add missing call to Modules::SendEvent

* Fix Shared filters

* Rename SetOnBlobData to SetOnData (different args)

* Correctly retrieve blob slices

* Correctly retrieve blob slices

* Clang format

* Update project filters

* Drop BlobModuleUriHandler

* Continue handling requests when not blob-supported

* Add BlobTest

* Update packages.lock.json

* Define FileReaderModule

* Implement FileReaderModule

* Complete BlobTest

* Make IBlobPersistor::ResolveMessage throw std::invalid_argument

* Fail on Content-Encoding parsing even if no error handler

* Remove MIME mappings. Currently unused

* MemoryBlobPersistor::ResolveMessage throw on out of bounds

* lint

* Enable BlobTest by default

* Disable Blob test in CI (may hang)
2022-05-20 19:48:48 -07:00
Julio César Rocha cee6f05fac
Handle abrupt WebSocket connection interruption (#9829)
* Add UnplugServer test

* Handle exceptions in args.GetDataReader()

* Consolidate catch clauses in MessageReceived

* Change files
2022-04-21 04:58:45 +00:00
Julio César Rocha 25d76fc058
Implement Origin Policy filter (#9771)
* Move all awaitable code into PerformSendRequest

* Await coroutine methods

* Remove blank lines

* Simplify co_return UntrackResponse

* Use dynamic body for server internal request

* Defne SetOnOptions

* Move url before headers in Response type

* Add dummy preflight filter

* Update x64 exports

* Use strand for server IO context

* Use HTTP message aliases

* Use HTTP message aliases

* Do not keep session references

Allows dropping server scope in tests.

* Comment out server scopes

* Use DynamicRequest|Response alias

* Format

* Use thread vector

* Drop outdated boost package validation in ReactCommon

* Define experimental write strand

* Drop server scope in default test

* Also pass server context to sessions

* Disable resource in default test

* Use Beast example

* Remove unused sample code

* Create HttpServer as listener wrapper

* Pass callbacks down to session

* Strong-name response as DynamicResponse

* Use DynamicRequest in handle_request

* Define HandleRequest as member function

* Lambda-based Respond()

* #if-out original sample code

* Keep count on get: ReaGetSucceeds

* Implement lambda_ using std::function

* Run context in io thread

* Join threads in Stop method

* Port send lambda to MS::R::T::HttpServer

* Update other basic tests

* Ensure Get+Options sequencing

* Clean up comments

* Use Callbacks() method

* Add concurrency argument

* Reduce macro usage

* Fix default OPTIONS handler

* Ensure number of headers

* Define ResponseType

* Use ResponseWrapper for polymorphism

* Define remaining wrapped types (File, String)

* Clean up server code

* (WIP) add test PreflightSucceeds

* catch hresult_error

* Use ProcessRequest result in PreformSendReq

* Rename test header value to Requested

* Propagate orror in ProcessRequest

* Rename OPReqFilter to PrototypeReqFilter

* Port request filter to WinRT IHttpFilter subtype

* Define allowed/forbidden methods and headers

* Define MSRN::Networking::OriginPolicyHttpFilter

* Move networking types into Shared\Networking folder

* Refactor: Move network types to Microsoft::React::Networking

* Clean up commented inline

* Make OPFilter::SendAsync non const

* Remove PrototypeHttpFilter

* Temporarily have desk.ITs depend on CppWinRT

* Define test OriginPolicyHttpFilterTest::UrlsHaveSameOrigin

* Add more same origin tests

* Start implementing ValidateRequest

* Finish ValidateRequest()

* Rename SingleOrigin to SameOrigin

* Implement SendPreflightAsync

* Fix OP assignment and GetOrigin rendering

* Parse Access-Control-Allow-Headers

* Done extracting access control values

* Use request as argument of ValidatePreflightResponse

* clang format

* Pass RequestArgs to request properties

* Pass RequestArgs to ValidateAllowOrigin

* Remove prototype non-WinRT filter

* Implement CorsUnsafeNotForbiddenRequestHeaderNames

* Test WinRT RequestHeader case sensitivity

* Fix ValidateAllowOrigin 4.10.5

* Add HttpOriginPolicyIntegrationTest

* Use boost:iequals to compare method names

* Add server support for CONNECT and TRACE methods

* Make HttpServer port uint16_t

* Prelfight only when OP is CORS.

- Add test SimpleCorsSameOriginSucceededs
- Add test NoCorsCrossOriginPatchSucceededs
- Add test NoCorsCrossOriginFetchRequestSucceeds
- Add test HTTP Server support for PATCH

* Use runtime option Http.StrictScheme

* Drop namespace from OriginPolicy

* Remove Origin from request heders

* Clean includes and usings in WinRTHttpResource.cpp

* Update preflight cache issue references (#9770)

* Pass origin in IHttpResource constructor

* clang format

* Prevent nullptr access when iterating preflight request headers

* Include request content headers in preflight headers list

* Send preflight to original request URL.

- Change test origin URL to non-existing http://example.rnw
- Have OriginPolicyHttpFilter::SendRequestAsync catch hresult_error to
  avoid losing info in (...) clause.

* Export APIs Set/GetRuntimeOptionString

- Switch to class-level static origin Uri.
- Define static (global) origin Uri via runtime option
  "Http.GlobalOrigin".

* clang format

* Implement TestOriginPolicy to parameterize OP tests

* Clean up non-parameterized tests

* Use constant for dummy cross origin

* Simplify test param constructors

* Start implementing ValidateResponse

* Add more tests

- FullCorsCrossOriginMissingCorsHeadersFails
- FullCorsCrossOriginMismatchedCorsHeaderFails

* clang format

* Change files

* Update namespaces in MSRN solution

* Move RequestArgs and ResponseType into new header

* Implement ExtractAccessControlValues

- Validate test result against ServerParams::Response::result

* Report specific origin mismatch errors in ValidatePreflightResponse

* Declare FullCorsCrossOriginCheckFailsOnPreflightRedirectFails

* Add ABI-safe runtime options free functions.

- Microsoft_React_SetRuntimeOptionBool
- Microsoft_React_SetRuntimeOptionInt
- Microsoft_React_SetRuntimeOptionString
- Microsoft_React_GetRuntimeOptionBool
- Microsoft_React_GetRuntimeOptionInt
- Microsoft_React_GetRuntimeOptionString

* Drop namespaced GetRuntimeOptionString

* Use case-insensitive comparison

* Drop newline from error message

* Return unmanaged copy in GetRuntimeOptionString

* Update FullCorsCrossOriginCheckFailsOnPreflightRedirectFails args

* Disallow preflight redirect.

See https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors/CORSExternalRedirectNotAllowed

* Replace winrt::get_self<D,I> with .as<D>

* Drop LF from error messages

* Use self-managed variable port in tests

* Start writing FullCorsCorsCheckFailsOnResponseRedirectFails

* Scope disabling autoredirect to preflight request only

* Update TODOs with open issues

* Compute originAllowed

* Add test FullCorsSameOriginToSameOriginRedirectSucceeds

* Test FullCorsSameOriginToCrossOriginRedirectSucceeds

* Test FullCorsCrossOriginToOriginalOriginRedirectFails

* Declare FullCorsCrossOriginToAnotherCrossOriginRedirectSucceeds

* Implement OriginPolicyHttpFilter::ConstWcharComparer

* Use _wcsicmp instead of boost::iequals in ConstWcharComparer

* Correct SimpleCORS value search

* Disable FullCorsCrossOriginWithCredentialsSucceeds for now

* Rename type alias ResponseType to ResponseOperation

* clang format

* Handle originPolicy a request property instead of a member variable

* Avoid iterating response headers while removing items

* Gracefully fail when adding bad request headers

- Write remaining integration tests

* Use boost::iequals in PerformSendRequest

* clang format

* Use s_port for redirServer args

* Rename TestOriginPolicy to TestOriginPolicyWithRedirect

* Temporarily disabled tests

- FullCorsCrossOriginToAnotherCrossOriginRedirectWithPreflightSucceeds -
  pending redirect
- FullCorsRequestWithHostHeaderFails - Host request header is probematic

* Use std::queue for nonSimpleNames

* Finish ValidateResponse

* Clean up comments

* Add Test ExcludeHttpOnlyCookies

* Add tests KeepNonHttpOnlyCookies, RemoveAllCookies

* Address TODO comments

* Always allow simple-CORS methods in preflight

* Avoid auto for loop indexe sused against container .size()

* Update Desktop.Test.DLL exports for ARM64

* Skip test FullCorsCrossOriginToAnotherCrossOriginRedirectSucceeds

* Disable FullCorsCrossOriginToAnotherCrossOriginRedirectWithPreflightFails

* Ignore SimpleCorsForbiddenMethodFails

* Ignore SimpleCorsCrossOriginFetchFails

* RequestWithProxyAuthorizationHeaderFails

* Ignore SimpleCorsSameOriginSucceededs

* Ignore NoCorsCrossOriginFetchRequestSucceeds

* Revert "Ignore NoCorsCrossOriginFetchRequestSucceeds"

This reverts commit b5445fb5af.

* Revert "Ignore SimpleCorsSameOriginSucceededs"

This reverts commit ab75c37373.

* Revert "RequestWithProxyAuthorizationHeaderFails"

This reverts commit 70148b17de.

* Revert "Ignore SimpleCorsCrossOriginFetchFails"

This reverts commit 982e4508b9.

* Revert "Ignore SimpleCorsForbiddenMethodFails"

This reverts commit 869bda9782.

* Revert "Disable FullCorsCrossOriginToAnotherCrossOriginRedirectWithPreflightFails"

This reverts commit e9e178a07a.

* Revert "Skip test FullCorsCrossOriginToAnotherCrossOriginRedirectSucceeds"

This reverts commit 6688e7dce5.

* Skip OP integration tests

* Empty commit

* Use scoped_lock for runtime options

* Testing signature

* Have C++ Rt Option functions call ABI-safe ones

* Ensure different ports for each netwk test class

* Remove remaining hard-coded ports from WS tests

* Use ABI-safe callback for GetRtOptString

* Only insert boolean rt options when true

* Use static variable for port in HttpResourceIntegrationTest

* Add HttpResourceIntegrationTest::SimpleRedirectSucceeds

* Move C++ Rt Optio APIs to new header CppRuntimeOptions.h

* Implement internal Set/GetRuntimeOptionString

* clang format

* Rename Microsoft_React_* functions to MicrosoftReact*

* Update nuspec
2022-04-20 23:49:37 +00:00
Julio César Rocha 3634bfaded
Implement IHttpResource (#9484)
* Added HttpResource skeleton

* Import WINRT namespaces

* Use custom struct instead of folly:dynamic in IHttpResource

* Drop factory method from Beast HTTP resource

* Move WinRT conversion utils into header

* Move WinRT conversion utils into header

* Define class WinRTHttpResource

* Update HttpModule

* Define IHttpResource::Response

* Implement callback members

* Implement AbortRequest

* Implement multiple request handling

* Drop client argument from PerformSendRequest

* Use background thread in PerformSendRequest

* Add WinRTConversions.cpp

* Init resource in module

* Implement test RequestGetSucceeds

* Complete RequestGetSucceeds

* Complete RequestGetFails

* Add HttpModule to default modules

* Move resume_in_queue back to WebSocket resource

* Simplify WinRTConversions includes

* Rename runtime option to Http.UseResourcedModule

* clang format

* Change files

* Update x86 DLL boundary

* Using SetRtOpt in InitModule

* Add test RequestGetHeadersSucceeds

* Allow aborting server

* Use case-insensitive comparison for headers

* Collect both response and content headers

* Address feedback

* Remove member function HttpModule::SendEvent

* Remove SetOnRequest

* Delete Beast HTTP resource

* Catch specific exceptions where applicable

* Rename Add/Remove Request to Track/Untrack Response

* Use r-value references where applicable

* Set runtime option Http.UseMonolithicModule

* Define GetHttpModuleName and GetWebSocketModuleName

* Remove WS, HTTP and Timing from Desktop test runner

* Update XHRTest

* Implement cxxCallback

* Pass request ID to callbacks

* Set default TestStatus for TestResult

* Update XHR test

* Format XHR test
2022-02-12 13:44:34 +00:00
Anandraj 5c04d6d91a
Hermes inspector is not starting when Hermes engine is used (#9426)
* Fixing hermes inspector [#9407](https://github.com/microsoft/react-native-windows/issues/)

The check to start the hermes inspector assumed that the jsiEngineOverride field to be set in the devSetting.
But, the field won't be set when using the override jsi runtime provided by the host.

The fix requires us to dynamically inspect the jsi runtime instance to find the engine type. This change adds
a field into the runtime implementation to explicitly provide the runtime type.

One alternative solution is to use RTTI which is not enabled in RNW builds.
Another alternative is to use the jsi::Runtime::description() value. We can't easily use this field as the usage of it is restricted to JS thread.

* Change files

* Incorporating feedbacks

* Fixing desktop build

* Fixing build break in Desktop integration tests
2022-01-27 22:34:18 -08:00
Andrew Coates 3c045eb9e7
[NetUI] Remove IUIManager.h (#9338)
* Remove unused iuimanager.h

* Change files

* build fix
2022-01-07 15:52:50 -08:00
Julio César Rocha 02f8b9f177
Avoid capturing raw `this` pointer in WebSocket module (#9247)
* Use implicit (brace) constructor for getMethods()

* Define CxxModuleHolder

* Make m_asyncStorageManager shared_ptr

* Change files

* Initialize m_holder

* Implement WebSocketModule::SharedState

* Move ResourceFactory into shared state

* Revert AsyncStorage changes

* Add URL argument to IWebSocketResource::Connect

* Drop URL from factory method

* Update BeastWebSocketResource

* Handle malformed Uris within ::Connect()

* Remove urlString argument from IWebSocketResource::Make

* Use constexpr for commont test URLs

* Remove redundant move in to_hstring

* Add/remove std::move where applicable

Co-authored-by: Nick Gerleman <ngerlem@microsoft.com>
2021-12-10 01:21:43 +00:00
Julio César Rocha bcdf9ad68e
Use PackageReference for C++ dependencies (#8195)
* Migrate `vnext` projects to `PackageReference`.

* Allow `run-windows` to directly restore `package.config` files when conflicting with `PackageReference` items.

* Allow parameterizing package names and versions which can be handled as any MSBuild property.

* Migrate C++ templates to `PackageReference`.

* Drop `packages` directory for `vnext` projects NuGet dependencies.\
  Dependencies will be accessed directly at the downloaded NuGet `globalPackagesFolder` using `msbuild /restore`.\
  This removes redundant copies of downloaded packages.
2021-12-03 23:19:47 -08:00
Nick Gerleman 98948c6eb8
Warn if `ReactNativeWindowsDir` Not Set Before Importing RNW Props (#9067)
* Remove extra definition of ReactNativeWindowsDir

ReactNativeWindowDir is normally defined in the top-level app/lib project, using logic that emulates node resolution. There is a second definition in external property sheets, that may be defined if folks have a custom project without defining ReactNativeWindowsDir. This falls down, since we use ReactNativeWindowsDir before it is defined in the file.

This change removes the second copy of ReactNativeWindowsDir, and adds an error to try to catch folks homebrewing their own project.

* Change files

* Convert Error to target and add more details

* Working warning logic

* Revert test change

* lowercase for style

* aka

* indentation

* dir cleanup

* ProjectName

* no-caps

* path consistency in repo

* logging

* Fix

* No extra slash

* Remove BaseOutDir Usage

* revert

* remove usages
2021-11-07 11:27:08 -08:00
Julio César Rocha 6810b7bc0b
Drop ChakraCore dependency (#9056)
* Remove references to ChakraCore NuGet packages

* Reorder MSRN sln platforms

* Define USE_EDGEMODE_JSRT in Desktop

* Enforce USE_EDGEMODE_JSRT

* Change files

* Remove Microsoft.ChakraCore.ARM64 nuget files

* Remove ChakraCoreRuntime.h

* Remove remaining ChakraCore references

* Drop delayload hook to switch Chakra variants

* clang format

* Remove ChakraCore-exclsive ByteCode tests

* Remove unused references to USE_EDGEMODE_JSRT

* Centralize USE_EDGEMODE_JSRT
2021-11-06 02:05:21 +00:00
Andrew Coates 36a6cf3723
Removing unused code (MemoryTracker) (#8504)
* Remove MemoryTracker

* Change files

* Remove one more line of unneeded code

* build fix
2021-08-31 02:29:18 +00:00
Julio César Rocha 5bb8b1d591
Set ToolsVersion to "Current" (#8212)
* Set ToolsVersion to Current

* Change files

* Log MSBuild tools version and path in Vars target
2021-07-13 16:19:08 -07:00
Julio César Rocha 9bfaf3e08d
Use in-process WebSocket server for RNTesterIntegrationTests (#8111)
* Use in-process WS server for RNTesterIntegrationtests

* Define UseNodeWsServer parameter
2021-06-28 16:49:02 -07:00
Julio César Rocha 50e13c8cc7
Upgrade to Boost 1.76 (#8106)
* Upgrade to boost 1.76.0.0

* Update DEF files

* Update x64 DEF

* Change files

* Upgrade Playground Win32 app

* Change files

* Fix sanitize.test.ts
2021-06-26 01:00:21 +00:00
Julio César Rocha 933eee3787
Upgrade TargetPlatformVersion to 10.0.19041.0 (#7779)
* Upgrade Windows SDK to 10.0.19041.0

* Change files

* Move configuration-dependent properties to the appropriate props file

* Update links and comments

* Set V8AppPlatform in Desktop integration tests

* Fix integration-test.yml targetPath

* Default solution to x64

* Make class TestTransaction non-final
2021-05-29 05:02:17 -07:00
Andrew Coates fe6d6a12c1
Remove react::uwp namespace (#7715)
* Remove macro that was used for react::uwp namespace replacement

* Change files

* Rename the rest of the react::uwp namespaces

* Fix def file
2021-05-04 07:26:56 +00:00
dannyvv 960b7411dd
Add missing include folder to fix CI (#7652)
* Fix CI after change to Format library

* Change files

* Move to shared location in React.Cpp.props

* Format on Save is terrible for msbuild files...
2021-04-26 11:04:41 -07:00
Jon Thysell f277b8e015
Update Microsoft.ChakraCore to 1.11.24 (#7628)
* Update Microsoft.ChakraCore to 1.11.24
2021-04-26 09:35:44 -07:00
Andrew Coates 0517a5d170
Replace fmt stub with real implementation (#7635)
* Replace fmt stub with real implementation

* change file

* Fix file list

* Change files

* build fixes

* Include fmt dir in published package
2021-04-23 09:19:34 +00:00
Julio César Rocha 5b10531290
Allow swapping to System Chakra at runtime. (#7509)
* Forward-port from 0.63-stable

* Change files

* Add runtime checks to ChakraApi

* yarn format

* Add _edgemode.cpp to component tests.

* Rename option name to JSI.ForceSystemChakra

* Use JSIEngineOverride to set the runtime option
2021-04-08 23:44:51 -07:00
Alexander Sklar 286adbe692
Update to newer cppwinrt, 2-3% reduction in binary size (#7352)
* update to newer cppwinrt, 2-3% reduction in binary size

* Change files

* more packages.config

* props/targets

* update template project cppwinrt version

* Change files

* Update packages to new cppwinrt version

* Change files

* restore comment in packages.config

* Add HostingContract to playground-win32

* Remove AppX from win32 project

* Use new nuget

* Workaround for cppwinrt bug #452
2021-03-14 04:43:28 +00:00
Julio César Rocha 40399fa903
Drop WebSocketModule integration tests (#7159)
* Drop WebSocketModule integration tests

* Change files

* Remove WebSocketModule tests from filter
2021-02-18 12:15:57 +00:00