diff --git a/package.json b/package.json index 05508e2..995bf8f 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/core/dispatch-request.ts b/src/core/dispatch-request.ts index beeb6e1..f0061d7 100644 --- a/src/core/dispatch-request.ts +++ b/src/core/dispatch-request.ts @@ -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, diff --git a/src/core/index.ts b/src/core/index.ts index 70940fb..08bf96e 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -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( { diff --git a/src/models/service.ts b/src/models/service.ts index 13f7de2..3c74ca0 100644 --- a/src/models/service.ts +++ b/src/models/service.ts @@ -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 { diff --git a/src/tools/v4.ts b/src/tools/v4.ts index 21d4e6b..449e2ca 100644 --- a/src/tools/v4.ts +++ b/src/tools/v4.ts @@ -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 { @@ -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 };