react-native-windows 0.73.5 → 0.73.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -64,7 +64,7 @@
64
64
  string literals. It prevents code like
65
65
  wchar_t* str = L"hello";
66
66
  from compiling. -->
67
- <AdditionalOptions>%(AdditionalOptions) /Zc:strictStrings</AdditionalOptions>
67
+ <AdditionalOptions>%(AdditionalOptions) /Zc:strictStrings /await</AdditionalOptions>
68
68
  </ClCompile>
69
69
  <Link>
70
70
  <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
@@ -78,12 +78,17 @@
78
78
  </ItemDefinitionGroup>
79
79
  <ItemGroup>
80
80
  <ClCompile Include="Unicode.cpp" />
81
+ <ClCompile Include="Utilities.cpp" />
81
82
  </ItemGroup>
82
83
  <ItemGroup>
83
84
  <ClInclude Include="Unicode.h" />
84
85
  <ClInclude Include="Utilities.h" />
85
86
  </ItemGroup>
86
87
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
88
+ <ItemGroup>
89
+ <PackageReference Include="boost" Version="1.76.0.0" />
90
+ <PackageReference Include="Microsoft.Windows.CppWinRT" Version="$(CppWinRTVersion)" PrivateAssets="all" />
91
+ </ItemGroup>
87
92
  <ImportGroup Label="ExtensionTargets">
88
93
  </ImportGroup>
89
94
  <Target Name="Deploy" />
@@ -12,6 +12,9 @@
12
12
  <ClCompile Include="Unicode.cpp">
13
13
  <Filter>Source Files</Filter>
14
14
  </ClCompile>
15
+ <ClCompile Include="Utilities.cpp">
16
+ <Filter>Source Files</Filter>
17
+ </ClCompile>
15
18
  </ItemGroup>
16
19
  <ItemGroup>
17
20
  <ClInclude Include="Unicode.h">
@@ -0,0 +1,59 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ #include "Utilities.h"
5
+
6
+ // Boost Library
7
+ #include <boost/archive/iterators/base64_from_binary.hpp>
8
+ #include <boost/archive/iterators/binary_from_base64.hpp>
9
+ #include <boost/archive/iterators/ostream_iterator.hpp>
10
+ #include <boost/archive/iterators/transform_width.hpp>
11
+
12
+ // Windows API
13
+ #include <winrt/Windows.Security.Cryptography.h>
14
+
15
+ // Standard Library
16
+ #include <sstream>
17
+
18
+ using std::string;
19
+ using std::string_view;
20
+ using std::wstring_view;
21
+ using winrt::array_view;
22
+
23
+ using winrt::Windows::Security::Cryptography::BinaryStringEncoding;
24
+ using winrt::Windows::Security::Cryptography::CryptographicBuffer;
25
+
26
+ namespace Microsoft::React::Utilities {
27
+
28
+ string DecodeBase64(string_view base64) noexcept {
29
+ typedef array_view<char const> av_t;
30
+ auto bytes = av_t(base64.data(), static_cast<av_t::size_type>(base64.size()));
31
+
32
+ using namespace boost::archive::iterators;
33
+ typedef transform_width<binary_from_base64<const char *>, 8, 6> decode_base64;
34
+ std::ostringstream oss;
35
+ std::copy(decode_base64(bytes.cbegin()), decode_base64(bytes.cend()), ostream_iterator<char>(oss));
36
+
37
+ return oss.str();
38
+ }
39
+
40
+ // https://www.boost.org/doc/libs/1_76_0/libs/serialization/doc/dataflow.html
41
+ string EncodeBase64(string_view text) noexcept {
42
+ typedef array_view<char const> av_t;
43
+ auto bytes = av_t(text.data(), static_cast<av_t::size_type>(text.size()));
44
+
45
+ using namespace boost::archive::iterators;
46
+ typedef base64_from_binary<transform_width<const char *, 6, 8>> encode_base64;
47
+ std::ostringstream oss;
48
+ std::copy(encode_base64(bytes.cbegin()), encode_base64(bytes.cend()), ostream_iterator<char>(oss));
49
+
50
+ // https://unix.stackexchange.com/questions/631501
51
+ auto padLength = (4 - (oss.tellp() % 4)) % 4;
52
+ for (auto i = 0; i < padLength; ++i) {
53
+ oss << '=';
54
+ }
55
+
56
+ return oss.str();
57
+ }
58
+
59
+ } // namespace Microsoft::React::Utilities
@@ -1,7 +1,20 @@
1
1
  {
2
2
  "version": 1,
3
3
  "dependencies": {
4
- "native,Version=v0.0": {},
4
+ "native,Version=v0.0": {
5
+ "boost": {
6
+ "type": "Direct",
7
+ "requested": "[1.76.0, )",
8
+ "resolved": "1.76.0",
9
+ "contentHash": "p+w3YvNdXL8Cu9Fzrmexssu0tZbWxuf6ywsQqHjDlKFE5ojXHof1HIyMC3zDLfLnh80dIeFcEUAuR2Asg/XHRA=="
10
+ },
11
+ "Microsoft.Windows.CppWinRT": {
12
+ "type": "Direct",
13
+ "requested": "[2.0.211028.7, )",
14
+ "resolved": "2.0.211028.7",
15
+ "contentHash": "JBGI0c3WLoU6aYJRy9Qo0MLDQfObEp+d4nrhR95iyzf7+HOgjRunHDp/6eGFREd7xq3OI1mll9ecJrMfzBvlyg=="
16
+ }
17
+ },
5
18
  "native,Version=v0.0/win10-arm": {},
6
19
  "native,Version=v0.0/win10-arm-aot": {},
7
20
  "native,Version=v0.0/win10-arm64-aot": {},
@@ -2,6 +2,9 @@
2
2
  // Licensed under the MIT License.
3
3
 
4
4
  #pragma once
5
+
6
+ // Standard Library
7
+ #include <string>
5
8
  #include <type_traits>
6
9
  #include <utility>
7
10
 
@@ -37,3 +40,11 @@ constexpr std::size_t ArraySize(T (&)[N]) noexcept {
37
40
  }
38
41
 
39
42
  } // namespace Microsoft::Common::Utilities
43
+
44
+ namespace Microsoft::React::Utilities {
45
+
46
+ std::string DecodeBase64(std::string_view text) noexcept;
47
+
48
+ std::string EncodeBase64(std::string_view text) noexcept;
49
+
50
+ } // namespace Microsoft::React::Utilities
@@ -10,11 +10,11 @@
10
10
  -->
11
11
  <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
12
12
  <PropertyGroup>
13
- <ReactNativeWindowsVersion>0.73.5</ReactNativeWindowsVersion>
13
+ <ReactNativeWindowsVersion>0.73.6</ReactNativeWindowsVersion>
14
14
  <ReactNativeWindowsMajor>0</ReactNativeWindowsMajor>
15
15
  <ReactNativeWindowsMinor>73</ReactNativeWindowsMinor>
16
- <ReactNativeWindowsPatch>5</ReactNativeWindowsPatch>
16
+ <ReactNativeWindowsPatch>6</ReactNativeWindowsPatch>
17
17
  <ReactNativeWindowsCanary>false</ReactNativeWindowsCanary>
18
- <ReactNativeWindowsCommitId>8f4160298ca131e01fb8c1bd6900394735a32c58</ReactNativeWindowsCommitId>
18
+ <ReactNativeWindowsCommitId>d1b6abda55649a09a35f36da61b5b184089b0db9</ReactNativeWindowsCommitId>
19
19
  </PropertyGroup>
20
20
  </Project>
@@ -3,10 +3,7 @@
3
3
 
4
4
  #include "BaseFileReaderResource.h"
5
5
 
6
- // Boost Library
7
- #include <boost/archive/iterators/base64_from_binary.hpp>
8
- #include <boost/archive/iterators/ostream_iterator.hpp>
9
- #include <boost/archive/iterators/transform_width.hpp>
6
+ #include <utilities.h>
10
7
 
11
8
  // Windows API
12
9
  #include <winrt/base.h>
@@ -73,18 +70,9 @@ void BaseFileReaderResource::ReadAsDataUrl(
73
70
  result += type;
74
71
  result += ";base64,";
75
72
 
76
- // https://www.boost.org/doc/libs/1_76_0/libs/serialization/doc/dataflow.html
77
- using namespace boost::archive::iterators;
78
- typedef base64_from_binary<transform_width<const char *, 6, 8>> encode_base64;
79
- std::ostringstream oss;
80
- std::copy(encode_base64(bytes.cbegin()), encode_base64(bytes.cend()), ostream_iterator<char>(oss));
81
- result += oss.str();
82
-
83
- // https://unix.stackexchange.com/questions/631501
84
- auto padLength = 4 - (oss.tellp() % 4);
85
- for (auto i = 0; i < padLength; ++i) {
86
- result += '=';
87
- }
73
+ auto chars = reinterpret_cast<const char *>(bytes.data());
74
+ auto view = std::string_view(chars, bytes.size());
75
+ result += Utilities::EncodeBase64(view);
88
76
 
89
77
  resolver(std::move(result));
90
78
  }
@@ -5,12 +5,6 @@
5
5
 
6
6
  #include <CreateModules.h>
7
7
  #include <ReactPropertyBag.h>
8
- #include <sstream>
9
-
10
- // Boost Library
11
- #include <boost/archive/iterators/base64_from_binary.hpp>
12
- #include <boost/archive/iterators/ostream_iterator.hpp>
13
- #include <boost/archive/iterators/transform_width.hpp>
14
8
 
15
9
  // React Native
16
10
  #include <cxxreact/JsArgumentHelpers.h>
@@ -5,6 +5,7 @@
5
5
 
6
6
  #include <Modules/IHttpModuleProxy.h>
7
7
  #include <Modules/IWebSocketModuleProxy.h>
8
+ #include <utilities.h>
8
9
 
9
10
  // Boost Libraries
10
11
  #include <boost/uuid/uuid_io.hpp>
@@ -95,11 +96,9 @@ void DefaultBlobResource::SendOverSocket(string &&blobId, int64_t offset, int64_
95
96
  return m_callbacks.OnError(e.what());
96
97
  }
97
98
 
98
- auto buffer = CryptographicBuffer::CreateFromByteArray(data);
99
- auto base64Hstring = CryptographicBuffer::EncodeToBase64String(std::move(buffer));
100
- auto base64String = winrt::to_string(base64Hstring);
101
-
102
- wsProxy->SendBinary(std::move(base64String), socketId);
99
+ auto chars = reinterpret_cast<const char *>(data.data());
100
+ auto view = std::string_view(chars, data.size());
101
+ wsProxy->SendBinary(Utilities::EncodeBase64(view), socketId);
103
102
  }
104
103
 
105
104
  void DefaultBlobResource::CreateFromParts(msrn::JSValueArray &&parts, string &&blobId) noexcept /*override*/ {
@@ -7,6 +7,9 @@
7
7
  #include <Utils/CppWinrtLessExceptions.h>
8
8
  #include <Utils/WinRTConversions.h>
9
9
 
10
+ // Boost Libraries
11
+ #include <boost/algorithm/string.hpp>
12
+
10
13
  // MSO
11
14
  #include <dispatchQueue/dispatchQueue.h>
12
15
 
@@ -16,9 +19,6 @@
16
19
  #include <winrt/Windows.Foundation.Collections.h>
17
20
  #include <winrt/Windows.Security.Cryptography.h>
18
21
 
19
- // Standard Library
20
- #include <sstream>
21
-
22
22
  using Microsoft::Common::Utilities::CheckedReinterpretCast;
23
23
 
24
24
  using std::function;
@@ -352,8 +352,12 @@ void WinRTWebSocketResource::Connect(string &&url, const Protocols &protocols, c
352
352
 
353
353
  m_readyState = ReadyState::Connecting;
354
354
 
355
+ bool hasOriginHeader = false;
355
356
  for (const auto &header : options) {
356
357
  m_socket.SetRequestHeader(header.first, winrt::to_hstring(header.second));
358
+ if (boost::iequals(header.first, L"Origin")) {
359
+ hasOriginHeader = true;
360
+ }
357
361
  }
358
362
 
359
363
  winrt::Windows::Foundation::Collections::IVector<winrt::hstring> supportedProtocols =
@@ -362,11 +366,26 @@ void WinRTWebSocketResource::Connect(string &&url, const Protocols &protocols, c
362
366
  supportedProtocols.Append(winrt::to_hstring(protocol));
363
367
  }
364
368
 
365
- m_connectRequested = true;
366
-
367
369
  Uri uri{nullptr};
368
370
  try {
369
371
  uri = Uri{winrt::to_hstring(url)};
372
+
373
+ // #12626 - If Origin header is not provided, set to connect endpoint.
374
+ if (!hasOriginHeader) {
375
+ auto scheme = uri.SchemeName();
376
+ auto host = uri.Host();
377
+ auto port = uri.Port();
378
+
379
+ if (scheme == L"ws") {
380
+ scheme = L"http";
381
+ } else if (scheme == L"wss") {
382
+ scheme = L"https";
383
+ }
384
+
385
+ auto origin = winrt::hstring{scheme + L"://" + host + L":" + winrt::to_hstring(port)};
386
+ m_socket.SetRequestHeader(L"Origin", std::move(origin));
387
+ }
388
+
370
389
  } catch (hresult_error const &e) {
371
390
  if (m_errorHandler) {
372
391
  m_errorHandler({Utilities::HResultToString(e), ErrorType::Connection});
@@ -380,6 +399,8 @@ void WinRTWebSocketResource::Connect(string &&url, const Protocols &protocols, c
380
399
  return;
381
400
  }
382
401
 
402
+ m_connectRequested = true;
403
+
383
404
  PerformConnect(std::move(uri));
384
405
  }
385
406
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-windows",
3
- "version": "0.73.5",
3
+ "version": "0.73.6",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",