From 5be63f12cdf6812caf7af280a0088afee121a200 Mon Sep 17 00:00:00 2001 From: surmon-china Date: Thu, 24 Nov 2022 03:53:22 +0800 Subject: [PATCH] feat: v0.4.0 --- CHANGELOG.md | 6 ++++++ package.json | 2 +- src/index.ts | 12 ++---------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dda0f03..5c40897 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to this project will be documented in this file. +### v0.4.0 (2022-11-24) + +**Breaking Change** + +- API key desensitization is no longer processed when an error occurs. + ### v0.3.0 (2022-11-24) **Breaking Change** diff --git a/package.json b/package.json index 8b630d9..b31c1cc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mongodb-data-api", - "version": "0.3.0", + "version": "0.4.0", "description": "MongoDB atlas data API SDK for Node.js", "author": "Surmon", "license": "MIT", diff --git a/src/index.ts b/src/index.ts index 7b43db3..d9dfac8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -134,8 +134,6 @@ export class MongoDBDataAPI { return `${endpoint}/action/${action}` } - const API_KEY_FIELD = 'api-key' - return this.#axios({ method: 'post', data: JSON.stringify(mergedParams), @@ -148,7 +146,7 @@ export class MongoDBDataAPI { headers: { 'Content-Type': 'application/json', 'Access-Control-Request-Headers': '*', - [API_KEY_FIELD]: this.#config.apiKey + 'api-key': this.#config.apiKey }, ...axiosConfig }) @@ -157,13 +155,7 @@ export class MongoDBDataAPI { }) .catch((error) => { // https://www.mongodb.com/docs/atlas/api/data-api-resources/#error-codes - if (_axios.isAxiosError(error)) { - const errorJSON: any = error.toJSON() - errorJSON.config.headers[API_KEY_FIELD] = '*****' - return Promise.reject(errorJSON) - } else { - return Promise.reject(error) - } + return Promise.reject(_axios.isAxiosError(error) ? error.toJSON() : error) }) }