Skip to content

Commit f07bacd

Browse files
Merge remote-tracking branch 'origin/master' into release
2 parents 7f7a535 + 7438d25 commit f07bacd

File tree

331 files changed

+1052
-1260
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

331 files changed

+1052
-1260
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## [21.10.0] - Aspose Words Cloud for Dart 21.10 Release Notes
2+
3+
- Removed 'GraphicsQualityOptions' image save option as it no longer supported.
4+
- Added query parameter 'displayIntermediateResults' for batch requests. If 'false', the last response in batch will be returned only. Default is 'true'
5+
- Added 'JsonDataLoadOptions' and 'XmlDataLoadOptions' to 'ReportEngineSettings'
6+
7+
18
## [21.8.0] - Aspose Words Cloud for Dart 21.8 Release Notes
29

310
- Added new api methods to get, insert, update or delete custom xml parts from documents.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Add this dependency to your *pubspec.yaml*:
2727

2828
```yaml
2929
dependencies:
30-
aspose_words_cloud: 21.9.0
30+
aspose_words_cloud: 21.10.0
3131
```
3232
3333
## Getting Started

lib/aspose_words_cloud.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ export 'src/models/form_field_response.dart';
122122
export 'src/models/form_field_text_input.dart';
123123
export 'src/models/form_fields_response.dart';
124124
export 'src/models/gif_save_options_data.dart';
125-
export 'src/models/graphics_quality_options_data.dart';
126125
export 'src/models/header_footer.dart';
127126
export 'src/models/header_footer_link.dart';
128127
export 'src/models/header_footer_link_collection.dart';
@@ -136,6 +135,7 @@ export 'src/models/hyperlinks.dart';
136135
export 'src/models/hyperlinks_response.dart';
137136
export 'src/models/image_save_options_data.dart';
138137
export 'src/models/jpeg_save_options_data.dart';
138+
export 'src/models/json_data_load_options.dart';
139139
export 'src/models/link.dart';
140140
export 'src/models/link_element.dart';
141141
export 'src/models/list_format.dart';
@@ -227,7 +227,6 @@ export 'src/models/split_document_result.dart';
227227
export 'src/models/stat_data_response.dart';
228228
export 'src/models/storage_file.dart';
229229
export 'src/models/story_child_nodes.dart';
230-
export 'src/models/string_format_data.dart';
231230
export 'src/models/style.dart';
232231
export 'src/models/style_apply.dart';
233232
export 'src/models/style_copy.dart';
@@ -276,6 +275,7 @@ export 'src/models/words_response.dart';
276275
export 'src/models/xaml_fixed_save_options_data.dart';
277276
export 'src/models/xaml_flow_save_options_data.dart';
278277
export 'src/models/xml_color.dart';
278+
export 'src/models/xml_data_load_options.dart';
279279
export 'src/models/xps_save_options_data.dart';
280280
export 'src/requests/accept_all_revisions_online_request.dart';
281281
export 'src/requests/accept_all_revisions_request.dart';

lib/src/api_client.dart

Lines changed: 56 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ import 'dart:typed_data';
3232

3333
import 'package:http/http.dart' as http;
3434
import 'package:uuid/uuid.dart';
35+
import 'package:convert/convert.dart';
36+
import 'package:pointycastle/export.dart';
3537

3638
import '../aspose_words_cloud.dart';
3739
import './api_request_data.dart';
@@ -41,13 +43,52 @@ import './requests/batch_request.dart';
4143

4244
class ApiClient {
4345
String _authToken;
46+
bool _encryptorInitialized = false;
47+
48+
final _publicKeyRequester;
49+
final PKCS1Encoding _encrypter = PKCS1Encoding(RSAEngine());
4450
final _starting = ByteData.view(utf8.encoder.convert('--').buffer);
4551
final _newline = ByteData.view(utf8.encoder.convert('\r\n').buffer);
4652
final _newline2x = ByteData.view(utf8.encoder.convert('\r\n\r\n').buffer);
4753

4854
final Configuration configuration;
4955

50-
ApiClient(final this.configuration);
56+
ApiClient(final this.configuration, final this._publicKeyRequester);
57+
58+
Future _initializeEncrypter() async {
59+
if (_encryptorInitialized == true) {
60+
return;
61+
}
62+
63+
_encryptorInitialized = true;
64+
try {
65+
final rsaPublicKey = await _publicKeyRequester(GetPublicKeyRequest());
66+
if (rsaPublicKey == null || rsaPublicKey.modulus == null || rsaPublicKey.exponent == null) {
67+
throw ApiException(400, 'Invalid public key response.');
68+
}
69+
70+
final modulus = BigInt.parse(hex.encode(base64Decode(rsaPublicKey.modulus as String)), radix: 16);
71+
final exponent = BigInt.parse(hex.encode(base64Decode(rsaPublicKey.exponent as String)), radix: 16);
72+
var pubKey = RSAPublicKey(modulus, exponent);
73+
74+
_encrypter.init(true, PublicKeyParameter<RSAPublicKey>(pubKey));
75+
}
76+
catch(_) {
77+
_encryptorInitialized = false;
78+
rethrow;
79+
}
80+
}
81+
82+
Future<String> encryptPassword(final String password) async {
83+
await _initializeEncrypter();
84+
return base64Encode(
85+
_encrypter.process(
86+
Uint8List.fromList(
87+
utf8.encode(password)
88+
)
89+
)
90+
);
91+
}
5192

5293
void _handleResponse(final int statusCode, final String reasonPhrase, final ByteData body) {
5394
if (statusCode != 200) {
@@ -364,7 +405,7 @@ class ApiClient {
364405
}
365406

366407
Future<dynamic> call(final RequestBase request) async {
367-
var requestData = request.createRequestData(this);
408+
var requestData = await request.createRequestData(this);
368409
var response = await _callWithChecks(requestData);
369410
if (response == null) {
370411
return null;
@@ -373,32 +414,29 @@ class ApiClient {
373414
return request.deserializeResponse(this, response);
374415
}
375416

376-
Future< List<dynamic> > callBatch(final List<BatchRequest> requests) async {
377-
var bodyParts = requests
378-
.map((request) => request.createRequestData(this))
379-
.map((requestData) => serializeBatchPart(requestData))
380-
.toList();
417+
Future< List<dynamic> > callBatch(final List<BatchRequest> requests, final bool displayIntermediateResults) async {
418+
var bodyParts = <ApiRequestPart>[];
419+
for (final request in requests) {
420+
bodyParts.add(serializeBatchPart(await request.createRequestData(this)));
421+
}
381422
var boundary = Uuid().v4();
382-
var batchUrl = '${configuration.getApiRootUrl()}/words/batch';
423+
var batchUrl = '${configuration.getApiRootUrl()}/words/batch?displayIntermediateResults=$displayIntermediateResults';
383424
var batchHeaders = <String, String>{};
384425
var batchBody = serializeMultipart(bodyParts, boundary);
385426
batchHeaders['Content-Type'] = 'multipart/form-data; boundary="$boundary"';
386427

387428
var batchRequestData = ApiRequestData('PUT', batchUrl, batchHeaders, batchBody);
388429
var response = await _callWithChecks(batchRequestData);
389430
var responseParts = deserializeMultipartBatch(response);
390-
if (responseParts.length != requests.length) {
391-
throw ApiException(400, 'Response and request parts mismatch.');
392-
}
393-
394-
var result = List<dynamic>.filled(requests.length, null);
395-
for (var i = 0; i < requests.length; i++) {
396-
if (!responseParts.containsKey(requests[i].getRequestId())) {
431+
var result = <dynamic>[];
432+
responseParts.forEach((key, value) {
433+
var request = requests.firstWhere((element) => element.getRequestId() == key);
434+
if (request == null) {
397435
throw ApiException(400, 'Failed to deserialize batch multipart response.');
398436
}
399437

400-
result[i] = deserializeBatchPart(requests[i].getRequest(), responseParts[requests[i].getRequestId()]);
401-
}
438+
result.add(deserializeBatchPart(request.getRequest(), value));
439+
});
402440

403441
return result;
404442
}
@@ -433,7 +471,7 @@ class ApiClient {
433471

434472
var httpRequest = http.Request(requestData.method, Uri.parse(requestData.url));
435473
httpRequest.headers['x-aspose-client'] = 'dart sdk';
436-
httpRequest.headers['x-aspose-client-version'] = '21.9';
474+
httpRequest.headers['x-aspose-client-version'] = '21.10';
437475
httpRequest.headers['Authorization'] = await _getAuthToken();
438476
if (requestData.headers != null) {
439477
httpRequest.headers.addAll(requestData.headers);

0 commit comments

Comments
 (0)