@basis-theory/basis-theory-js 1.67.2 → 1.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/common/constants.d.ts +2 -1
- package/common/constants.js +3 -1
- package/common/utils.js +5 -0
- package/package.json +1 -1
- package/types/sdk/services/shared.d.ts +1 -0
package/README.md
CHANGED
|
@@ -36,7 +36,8 @@ const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED'); // replac
|
|
|
36
36
|
|
|
37
37
|
### Per-request configuration
|
|
38
38
|
|
|
39
|
-
All of the service methods accept an optional `RequestOptions` object. This is used if you want to set a
|
|
39
|
+
All of the service methods accept an optional `RequestOptions` object. This is used if you want to set a per-request `BT-TRACE-ID`, `BT-API-KEY` and/or
|
|
40
|
+
`BT-IDEMPOTENCY-KEY`.
|
|
40
41
|
|
|
41
42
|
```javascript
|
|
42
43
|
import { v4 as uuid } from 'uuid';
|
|
@@ -46,6 +47,7 @@ await bt.applications.list(
|
|
|
46
47
|
{
|
|
47
48
|
apiKey: 'key_N88mVGsp3sCXkykyN2EFED',
|
|
48
49
|
correlationId: 'aa5d3379-6385-4ef4-9fdb-ca1341572153',
|
|
50
|
+
idempotencyKey: 'bb5d3379-6385-4ef4-9fdb-ca1341572154',
|
|
49
51
|
}
|
|
50
52
|
);
|
|
51
53
|
```
|
package/common/constants.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { BasisTheoryServicesBasePathMap } from '../types/sdk';
|
|
2
2
|
declare const API_KEY_HEADER = "BT-API-KEY";
|
|
3
3
|
declare const BT_TRACE_ID_HEADER = "bt-trace-id";
|
|
4
|
+
declare const BT_IDEMPOTENCY_KEY_HEADER = "bt-idempotency-key";
|
|
4
5
|
declare const CONTENT_TYPE_HEADER = "Content-Type";
|
|
5
6
|
declare const USER_AGENT_HEADER = "User-Agent";
|
|
6
7
|
declare const CLIENT_USER_AGENT_HEADER = "BT-CLIENT-USER-AGENT";
|
|
@@ -12,4 +13,4 @@ declare const BROWSER_LIST: {
|
|
|
12
13
|
browserName: string;
|
|
13
14
|
browserUA: string;
|
|
14
15
|
}[];
|
|
15
|
-
export { API_KEY_HEADER, BT_TRACE_ID_HEADER, CONTENT_TYPE_HEADER, USER_AGENT_HEADER, CLIENT_USER_AGENT_HEADER, USER_AGENT_CLIENT, DEFAULT_BASE_URL, DEFAULT_ELEMENTS_BASE_URL, CLIENT_BASE_PATHS, BROWSER_LIST, };
|
|
16
|
+
export { API_KEY_HEADER, BT_TRACE_ID_HEADER, BT_IDEMPOTENCY_KEY_HEADER, CONTENT_TYPE_HEADER, USER_AGENT_HEADER, CLIENT_USER_AGENT_HEADER, USER_AGENT_CLIENT, DEFAULT_BASE_URL, DEFAULT_ELEMENTS_BASE_URL, CLIENT_BASE_PATHS, BROWSER_LIST, };
|
package/common/constants.js
CHANGED
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.USER_AGENT_HEADER = exports.USER_AGENT_CLIENT = exports.DEFAULT_ELEMENTS_BASE_URL = exports.DEFAULT_BASE_URL = exports.CONTENT_TYPE_HEADER = exports.CLIENT_USER_AGENT_HEADER = exports.CLIENT_BASE_PATHS = exports.BT_TRACE_ID_HEADER = exports.BROWSER_LIST = exports.API_KEY_HEADER = void 0;
|
|
6
|
+
exports.USER_AGENT_HEADER = exports.USER_AGENT_CLIENT = exports.DEFAULT_ELEMENTS_BASE_URL = exports.DEFAULT_BASE_URL = exports.CONTENT_TYPE_HEADER = exports.CLIENT_USER_AGENT_HEADER = exports.CLIENT_BASE_PATHS = exports.BT_TRACE_ID_HEADER = exports.BT_IDEMPOTENCY_KEY_HEADER = exports.BROWSER_LIST = exports.API_KEY_HEADER = void 0;
|
|
7
7
|
const API_KEY_HEADER = 'BT-API-KEY';
|
|
8
8
|
exports.API_KEY_HEADER = API_KEY_HEADER;
|
|
9
9
|
const BT_TRACE_ID_HEADER = 'bt-trace-id';
|
|
10
10
|
exports.BT_TRACE_ID_HEADER = BT_TRACE_ID_HEADER;
|
|
11
|
+
const BT_IDEMPOTENCY_KEY_HEADER = 'bt-idempotency-key';
|
|
12
|
+
exports.BT_IDEMPOTENCY_KEY_HEADER = BT_IDEMPOTENCY_KEY_HEADER;
|
|
11
13
|
const CONTENT_TYPE_HEADER = 'Content-Type';
|
|
12
14
|
exports.CONTENT_TYPE_HEADER = CONTENT_TYPE_HEADER;
|
|
13
15
|
const USER_AGENT_HEADER = 'User-Agent';
|
package/common/utils.js
CHANGED
|
@@ -224,6 +224,7 @@ const createRequestConfig = (options, transformers) => {
|
|
|
224
224
|
const {
|
|
225
225
|
apiKey,
|
|
226
226
|
correlationId,
|
|
227
|
+
idempotencyKey,
|
|
227
228
|
query,
|
|
228
229
|
headers
|
|
229
230
|
} = options;
|
|
@@ -233,9 +234,13 @@ const createRequestConfig = (options, transformers) => {
|
|
|
233
234
|
const correlationIdHeader = correlationId ? {
|
|
234
235
|
[_constants.BT_TRACE_ID_HEADER]: correlationId
|
|
235
236
|
} : {};
|
|
237
|
+
const idempotencyKeyHeader = idempotencyKey ? {
|
|
238
|
+
[_constants.BT_IDEMPOTENCY_KEY_HEADER]: idempotencyKey
|
|
239
|
+
} : {};
|
|
236
240
|
return {
|
|
237
241
|
headers: { ...apiKeyHeader,
|
|
238
242
|
...correlationIdHeader,
|
|
243
|
+
...idempotencyKeyHeader,
|
|
239
244
|
...(typeof headers !== 'undefined' && { ...headers
|
|
240
245
|
})
|
|
241
246
|
},
|
package/package.json
CHANGED