Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"url": "https://github.com/TTvcloud/vcloud-sdk-nodejs"
},
"dependencies": {
"@byted/aws-signers-v4": "^0.0.8",
"ajv": "^6.5.4",
"aws-sdk": "^2.297.0",
"debug": "^4.1.1",
"deepmerge": "^2.1.1",
"node-fetch": "2.6.0",
Expand Down
1 change: 0 additions & 1 deletion src/core/dispatch-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const debug = _debug('openapi-request');
function dispatchRequest(options: FetchOptions) {
return () => {
const { method, url, headers, body, logId = '', timeout } = options;

const reqOptions: RequestInit = {
body: method === 'GET' || method === 'HEAD' ? undefined : body,
method,
Expand Down
10 changes: 4 additions & 6 deletions src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,21 +135,19 @@ class Client {

const fetchOptions: FetchOptions = {
timeout: this._configs.timeout!,
pathname: () => '/',
pathname: '/',
path: '/',
...options,
region: this._configs.region || REGION.CnNorth1,
method: method,
search: () => `${AWS.queryParamsToString(query)}`,
query: util.formatQuery(query),
query,
url,
body,
};

fetchOptions.params = fetchOptions.query;
debug('fetchOptions: %o', fetchOptions);

const signer = new AWS.AWSSignersV4(fetchOptions, service, {});

fetchOptions.query = util.formatQuery(query);
debug('this._configs', this._configs);
signer.addAuthorization(
{
Expand Down
7 changes: 5 additions & 2 deletions src/models/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,15 @@ export interface Statement {
}

export type FetchOptions = RequestOptions & {
pathname: () => string;
search: () => string;
pathname: string | (() => string);
search?: () => string;
path: string;
region: string;
url: string;
timeout: number;
params?: {
[key: string]: any;
};
};

export interface ExtendRequestInit extends RequestInit {
Expand Down
5 changes: 3 additions & 2 deletions src/tools/v4.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import AWS from 'aws-sdk/global';
// import AWS from 'aws-sdk/global';
import AWSSignersV4 from '@byted/aws-signers-v4';

const uriEscape = (str: string) => {
try {
Expand Down Expand Up @@ -39,6 +40,6 @@ const queryParamsToString = (params: { [key: string]: any }) =>
.filter(v => v)
.join('&');

const AWSSignersV4 = (AWS as any).Signers.V4;
// const AWSSignersV4 = (AWS as any).Signers.V4;

export { queryParamsToString, AWSSignersV4 };