@finteqhub/sdk-js 0.17.0-beta.1 → 0.17.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/CHANGELOG.md +8 -8
- package/README.md +3 -3
- package/dist/src/utils.js +7 -0
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +2 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
Notable changes to
|
|
3
|
+
Notable changes to the SDK. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
4
4
|
|
|
5
5
|
## 0.17.0
|
|
6
6
|
|
|
7
7
|
### Breaking changes
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
- The constructor takes a single options object instead of positional arguments. The object is validated like the positional arguments were; passing positional arguments throws `TypeError: sdk-js: constructor expects an options object`. The new `ProcessingOptions` type is exported.
|
|
9
|
+
- The SDK class is now exported as `Processing`; the previous class name is no longer exported.
|
|
10
|
+
- The constructor takes a single options object instead of positional arguments. The object is validated like the positional arguments were; passing positional arguments throws `TypeError: sdk-js: constructor expects an options object`. Unknown keys are rejected too (`TypeError: sdk-js: unknown option "issecure"`), so a misspelled option, or a `merchantId` left over from 0.15.0, fails loudly instead of silently falling back to the default. The new `ProcessingOptions` type is exported.
|
|
11
11
|
|
|
12
12
|
Migration:
|
|
13
13
|
|
|
14
14
|
```
|
|
15
|
-
// 0.16.0
|
|
16
|
-
|
|
15
|
+
// 0.16.0: positional arguments
|
|
16
|
+
(apiUrl, fingerprintVisitorId, sessionId, isSecure, retryOptions)
|
|
17
17
|
|
|
18
|
-
// 0.17.0
|
|
18
|
+
// 0.17.0: an options object
|
|
19
19
|
new Processing({ apiUrl, fingerprintVisitorId, sessionId, isSecure, retryOptions });
|
|
20
20
|
```
|
|
21
21
|
|
|
@@ -26,7 +26,7 @@ new Processing({ apiUrl, fingerprintVisitorId, sessionId, isSecure, retryOptions
|
|
|
26
26
|
### Breaking changes
|
|
27
27
|
|
|
28
28
|
- The SDK no longer sends the `x-merchant-id` header (previously on every request) or the `x-project-id` header (previously on `submit-form` and `operations` requests, taken from the session response). This release requires a backend that no longer expects these headers; against older backends `submit-form` and `sessions` requests are rejected with 400.
|
|
29
|
-
- The `merchantId` constructor argument was removed together with the header. The constructor
|
|
29
|
+
- The `merchantId` constructor argument was removed together with the header. The constructor arguments are now `(apiUrl, fingerprintVisitorId, sessionId, isSecure?, retryOptions?)` — every argument after `fingerprintVisitorId` shifts one position to the left. Callers must drop the third argument; a call site that still passes it fails argument validation (`isSecure` receives the session id, which is not a boolean, and the constructor throws a `TypeError`).
|
|
30
30
|
|
|
31
31
|
### Changed
|
|
32
32
|
|
|
@@ -60,7 +60,7 @@ No code changes: the SDK behaves exactly as in 0.13.0 (only the version reported
|
|
|
60
60
|
|
|
61
61
|
### Breaking changes
|
|
62
62
|
|
|
63
|
-
- The SDK identification header sent with every request was renamed
|
|
63
|
+
- The SDK identification header sent with every request was renamed to `x-pgw-sdk`, spelled in lower case to match the other headers the SDK sends. Backends that read the header by its previous name must switch to `x-pgw-sdk`; the value format (`sdk-js/<version>`) is unchanged.
|
|
64
64
|
|
|
65
65
|
## 0.12.0
|
|
66
66
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# processing-sdk
|
|
2
2
|
|
|
3
|
-
Use `new Processing(options: ProcessingOptions)` to create an instance of the Processing object. The Processing object is your entrypoint to
|
|
3
|
+
Use `new Processing(options: ProcessingOptions)` to create an instance of the Processing object. The Processing object is your entrypoint to the processing SDK.
|
|
4
4
|
|
|
5
5
|
```
|
|
6
6
|
interface ProcessingOptions {
|
|
@@ -18,7 +18,7 @@ const processing = new Processing({
|
|
|
18
18
|
});
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
The constructor validates its options and throws a `TypeError` when they are not an object, when `apiUrl`, `fingerprintVisitorId` or `sessionId` is missing, empty or not a string, when `isSecure` is not a boolean, or when `retryOptions` is malformed (see [Retries and error diagnostics](#retries-and-error-diagnostics)).
|
|
21
|
+
The constructor validates its options and throws a `TypeError` when they are not an object, when they contain an unknown key (for example a misspelled `issecure`), when `apiUrl`, `fingerprintVisitorId` or `sessionId` is missing, empty or not a string, when `isSecure` is not a boolean, or when `retryOptions` is malformed (see [Retries and error diagnostics](#retries-and-error-diagnostics)).
|
|
22
22
|
|
|
23
23
|
## Retries and error diagnostics
|
|
24
24
|
|
|
@@ -77,7 +77,7 @@ Every request the SDK makes carries an extra header:
|
|
|
77
77
|
x-pgw-sdk: sdk-js/<version>
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
-
The value contains the SDK name and version (kept in sync with `package.json` by a test) — for example `sdk-js/0.11.0`.
|
|
80
|
+
The value contains the SDK name and version (kept in sync with `package.json` by a test) — for example `sdk-js/0.11.0`. The backend uses this header to identify traffic coming from the official SDK integration — for example to notify affected merchants when a security fix is released. It does not affect authentication or request routing.
|
|
81
81
|
|
|
82
82
|
The header is added automatically to every request and cannot be disabled.
|
|
83
83
|
|
package/dist/src/utils.js
CHANGED
|
@@ -50,11 +50,18 @@ export function getDeviceType() {
|
|
|
50
50
|
return DeviceType.Unknown;
|
|
51
51
|
}
|
|
52
52
|
const REQUIRED_STRINGS = ["apiUrl", "fingerprintVisitorId", "sessionId"];
|
|
53
|
+
const KNOWN_OPTIONS = [...REQUIRED_STRINGS, "isSecure", "retryOptions"];
|
|
53
54
|
export function validateArguments(options) {
|
|
54
55
|
// catches callers still using the positional signature from 0.16.0 and earlier
|
|
55
56
|
if (typeof options !== "object" || options === null) {
|
|
56
57
|
throw new TypeError("sdk-js: constructor expects an options object");
|
|
57
58
|
}
|
|
59
|
+
// a misspelled key (e.g. `issecure`) would otherwise silently fall back to the default
|
|
60
|
+
for (const key of Object.keys(options)) {
|
|
61
|
+
if (!KNOWN_OPTIONS.includes(key)) {
|
|
62
|
+
throw new TypeError(`sdk-js: unknown option "${key}"`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
58
65
|
for (const key of REQUIRED_STRINGS) {
|
|
59
66
|
if (typeof options[key] !== "string" || options[key] === "") {
|
|
60
67
|
throw new TypeError(`sdk-js: ${key} must be a non-empty string`);
|
package/dist/src/version.d.ts
CHANGED
package/dist/src/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@finteqhub/sdk-js",
|
|
3
|
-
"version": "0.17.0
|
|
4
|
-
"description": "SDK for interacting with
|
|
3
|
+
"version": "0.17.0",
|
|
4
|
+
"description": "SDK for interacting with the processing API",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"typings": "./dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist/*",
|
|
9
9
|
"CHANGELOG.md"
|
|
10
10
|
],
|
|
11
|
-
"author": "FinteqHub",
|
|
12
11
|
"repository": {
|
|
13
12
|
"type": "git",
|
|
14
13
|
"url": "git+https://github.com/finteqhub/sdk-js.git"
|