Skip to content

Commit 43fa995

Browse files
author
evgeny.ivanov
committed
SDK regenerated by CI server [ci skip]
1 parent dde5de9 commit 43fa995

File tree

5 files changed

+198
-0
lines changed

5 files changed

+198
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Feel free to explore the [Developer's Guide](https://docs.aspose.cloud/display/w
2020

2121
- ImlRenderingMode option introduced witch is used to determine how ink (InkML) objects are rendered
2222
- MaxCharactersPerLine option introduced which is used to specify the maximum number of characters per one line
23+
- Added new API method to get a RSA public key to encrypt document passwords
24+
- Added encryptedPassword common query option to pass an encrypted document password
2325

2426

2527
## Enhancements in Version 21.6

src/api.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2671,6 +2671,24 @@ export class WordsApi {
26712671
return Promise.resolve(result);
26722672
}
26732673

2674+
/**
2675+
* Get assymetric public key.
2676+
* @param requestObj contains request parameters
2677+
*/
2678+
public async getPublicKey(requestObj: model.GetPublicKeyRequest): Promise< model.WordsIncomingMessage< model.PublicKeyResponse > > {
2679+
if (requestObj === null || requestObj === undefined) {
2680+
throw new Error('Required parameter "request" was null or undefined when calling getPublicKey.');
2681+
}
2682+
2683+
const requestOptions = requestObj.createRequestOptions(this.configuration);
2684+
2685+
const response = await invokeApiMethod(requestOptions, this.configuration);
2686+
const result = new model.WordsIncomingMessage< model.PublicKeyResponse >();
2687+
result.response = response;
2688+
result.body = requestObj.createResponse(response.body);
2689+
return Promise.resolve(result);
2690+
}
2691+
26742692
/**
26752693
* Reads range text from the document.
26762694
* @param requestObj contains request parameters

src/model/model.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ import * as importedProtectionData from './protectionData';
184184
import * as importedProtectionDataResponse from './protectionDataResponse';
185185
import * as importedProtectionRequest from './protectionRequest';
186186
import * as importedPsSaveOptionsData from './psSaveOptionsData';
187+
import * as importedPublicKeyResponse from './publicKeyResponse';
187188
import * as importedRangeDocument from './rangeDocument';
188189
import * as importedRangeDocumentDto from './rangeDocumentDto';
189190
import * as importedRangeTextResponse from './rangeTextResponse';
@@ -425,6 +426,7 @@ export * from './protectionData';
425426
export * from './protectionDataResponse';
426427
export * from './protectionRequest';
427428
export * from './psSaveOptionsData';
429+
export * from './publicKeyResponse';
428430
export * from './rangeDocument';
429431
export * from './rangeDocumentDto';
430432
export * from './rangeTextResponse';
@@ -767,6 +769,7 @@ const typeMap = {
767769
ProtectionDataResponse: importedProtectionDataResponse.ProtectionDataResponse,
768770
ProtectionRequest: importedProtectionRequest.ProtectionRequest,
769771
PsSaveOptionsData: importedPsSaveOptionsData.PsSaveOptionsData,
772+
PublicKeyResponse: importedPublicKeyResponse.PublicKeyResponse,
770773
RangeDocument: importedRangeDocument.RangeDocument,
771774
RangeDocumentDto: importedRangeDocumentDto.RangeDocumentDto,
772775
RangeTextResponse: importedRangeTextResponse.RangeTextResponse,
@@ -15339,6 +15342,45 @@ export class GetParagraphTabStopsOnlineRequest implements RequestInterface {
1533915342
}
1534015343
}
1534115344

15345+
/**
15346+
* Request model for GetPublicKey operation.
15347+
* Get assymetric public key.
15348+
*/
15349+
export class GetPublicKeyRequest implements RequestInterface {
15350+
15351+
public constructor(init?: Partial< GetPublicKeyRequest >) {
15352+
Object.assign(this, init);
15353+
}
15354+
15355+
15356+
/**
15357+
* create the requst options for this request
15358+
* @param configuration a configuration for the request
15359+
*/
15360+
createRequestOptions(configuration: Configuration) : request.OptionsWithUri {
15361+
const localVarPath = configuration.getApiBaseUrl() + "/words/encryption/publickey"
15362+
.replace("//", "/");
15363+
const queryParameters: any = {};
15364+
15365+
const requestOptions: request.Options = {
15366+
method: "GET",
15367+
qs: queryParameters,
15368+
uri: localVarPath,
15369+
json: true,
15370+
};
15371+
15372+
15373+
return requestOptions;
15374+
}
15375+
15376+
/**
15377+
* create response from string
15378+
*/
15379+
createResponse(_response: Buffer, _boundary?: string): any {
15380+
return ObjectSerializer.deserialize(_response, "PublicKeyResponse");
15381+
}
15382+
}
15383+
1534215384
/**
1534315385
* Request model for GetRangeText operation.
1534415386
* Reads range text from the document.

src/model/publicKeyResponse.ts

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* --------------------------------------------------------------------------------
3+
* <copyright company="Aspose" file="publicKeyResponse.ts">
4+
* Copyright (c) 2021 Aspose.Words for Cloud
5+
* </copyright>
6+
* <summary>
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in all
15+
* copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
* SOFTWARE.
24+
* </summary>
25+
* --------------------------------------------------------------------------------
26+
*/
27+
28+
import { AttributeInfo } from '../internal/attributeInfo';
29+
import { WordsResponse } from './wordsResponse';
30+
31+
export const importsMapPublicKeyResponse = {
32+
WordsResponse,
33+
};
34+
35+
/**
36+
* REST response for RSA public key info.
37+
*/
38+
export class PublicKeyResponse extends WordsResponse {
39+
/**
40+
* Attribute type map
41+
*/
42+
public static attributeTypeMap: Array<AttributeInfo> = [
43+
{
44+
name: "exponent",
45+
baseName: "Exponent",
46+
type: "string",
47+
},
48+
{
49+
name: "modulus",
50+
baseName: "Modulus",
51+
type: "string",
52+
}
53+
];
54+
55+
/**
56+
* Returns attribute type map
57+
*/
58+
public static getAttributeTypeMap() {
59+
return super.getAttributeTypeMap().concat(PublicKeyResponse.attributeTypeMap);
60+
}
61+
62+
/**
63+
* Gets or sets RSA key exponent as Base64 string.
64+
*/
65+
public exponent: string;
66+
67+
/**
68+
* Gets or sets RSA key modulus as Base64 string.
69+
*/
70+
public modulus: string;
71+
72+
public constructor(init?: Partial< PublicKeyResponse >) {
73+
super(init);
74+
Object.assign(this, init);
75+
}
76+
}
77+
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* --------------------------------------------------------------------------------
3+
* <copyright company="Aspose" file="passwordEncryptionTests.ts">
4+
* Copyright (c) 2021 Aspose.Words for Cloud
5+
* </copyright>
6+
* <summary>
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in all
15+
* copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
* SOFTWARE.
24+
* </summary>
25+
* --------------------------------------------------------------------------------
26+
*/
27+
28+
import { expect } from "chai";
29+
import "mocha";
30+
31+
import * as fs from "fs";
32+
import * as model from "../../src/model/model";
33+
import * as BaseTest from "../baseTest";
34+
35+
// Example of how to handle an encrypted document.
36+
describe("passwordEncryption", () => {
37+
expect(fs);
38+
const remoteDataFolder = BaseTest.remoteBaseTestDataFolder + "/DocumentActions/PasswordEncryption";
39+
const localFile = "Common/test_multi_pages.docx";
40+
41+
// Test for getting a public key for password encryption.
42+
describe("getPublicKey test", () => {
43+
it("should return response with code 200", () => {
44+
const wordsApi = BaseTest.initializeWordsApi();
45+
const request = new model.GetPublicKeyRequest({
46+
});
47+
48+
// Act
49+
return wordsApi.getPublicKey(request)
50+
.then((resultApi) => {
51+
// Assert
52+
expect(resultApi.response.statusCode).to.equal(200);
53+
expect(resultApi.body.exponent).to.exist;
54+
expect(resultApi.body.modulus).to.exist;
55+
});
56+
57+
});
58+
});
59+
});

0 commit comments

Comments
 (0)