@finteqhub/sdk-js 0.12.0 → 0.13.1

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 ADDED
@@ -0,0 +1,41 @@
1
+ # Changelog
2
+
3
+ Notable changes to `@finteqhub/sdk-js`. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
4
+
5
+ ## 0.13.1
6
+
7
+ ### Changed
8
+
9
+ - `CHANGELOG.md` is now included in the published npm package (previously only `dist/` and `README.md` shipped).
10
+ - Added `repository`, `homepage` and `bugs` fields to `package.json`, so the npm page links to the GitHub repository, relative links in the README resolve there, and dependency bots can find the release notes.
11
+
12
+ No code changes: the SDK behaves exactly as in 0.13.0 (only the version reported in the `x-pgw-sdk` header differs).
13
+
14
+ ## 0.13.0
15
+
16
+ ### Breaking changes
17
+
18
+ - The SDK identification header sent with every request was renamed from `X-Finteqhub-SDK` to `x-pgw-sdk`, now spelled in lower case to match the other headers the SDK sends. Header names are case-insensitive, so only the name itself changed; the value format (`sdk-js/<version>`) is unchanged.
19
+
20
+ ## 0.12.0
21
+
22
+ ### Breaking changes
23
+
24
+ - The constructor validates its arguments and throws a `TypeError` when `apiUrl`, `fingerprintVisitorId`, `merchantId` or `sessionId` is missing, empty or not a string, when `isSecure` is not a boolean, or when `retryOptions` is malformed (not an object, `retryCount` not a non-negative integer, `retryStatusCode` not a function). Previously invalid arguments were accepted silently.
25
+ - Failed requests now reject with a `RequestError` (subclass of `Error`) instead of a plain `Error`. Existing `catch` blocks keep working, but error messages changed for some failure classes:
26
+ - network failures reject with `request to <url> failed after N attempt(s): <reason>` (previously the raw `fetch` error, e.g. `Failed to fetch`);
27
+ - non-200 responses without an `error` field in the body reject with `unexpected response status <code>` (previously the message was empty);
28
+ - responses with a non-JSON body reject with `request to <url> returned invalid JSON (status <code>)` (previously the raw `JSON.parse` error).
29
+
30
+ Code that matches on `error.message` for these cases needs updating; code that only reads `error.message` for display keeps working.
31
+
32
+ - To keep the 0.11.0 behaviour of a single request per call, pass `{ retryCount: 0 }` as the sixth constructor argument. The `RequestError` type, the changed error messages and the `console.error` dump apply regardless of whether retries are enabled.
33
+
34
+ ### Added
35
+
36
+ - Failed HTTP requests are retried automatically with exponential backoff (`100ms → 200ms → 500ms → 1000ms → 2000ms`), 5 retries by default. Network errors are always retried; responses are retried when the status is `< 200`, `408`, or `>= 500` (400 is not retried: the API returns it for deterministic validation failures and duplicate-submit rejections). Configurable via the new optional `retryOptions` constructor argument (`retryCount`, `retryStatusCode`), passed after `isSecure` — see the README for details.
37
+ - `RequestError.diagnostics` carries a full diagnostic payload: failure kind (`network` / `http_error` / `invalid_json`), SDK version, request info with a per-attempt log, sanitized response body for non-200 responses (truncated, digit runs masked), the `error` field of the response body, and environment info (`navigator.onLine`, `document.visibilityState`, `navigator.connection`). The same payload is logged with `console.error` together with the error message; each retry is reported with `console.warn`.
38
+ - New exports: `RequestError`, `RetryOptions`, `RequestDiagnostics`, `RequestAttempt`.
39
+ - `publish-beta` GitHub workflow: publishes `<version>-beta.<run number>` to npm under the `beta` dist-tag without touching `latest`.
40
+
41
+ Releases before 0.12.0 are not backfilled here — see the git history.
package/README.md CHANGED
@@ -56,7 +56,7 @@ Diagnostics are collected regardless of whether retries are enabled.
56
56
  Every request the SDK makes carries an extra header:
57
57
 
58
58
  ```
59
- X-Finteqhub-SDK: sdk-js/<version>
59
+ x-pgw-sdk: sdk-js/<version>
60
60
  ```
61
61
 
62
62
  The value contains the SDK name and version (kept in sync with `package.json` by a test) — for example `sdk-js/0.11.0`. FinteqHub 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.
@@ -109,7 +109,7 @@ processing
109
109
 
110
110
  ## Releasing
111
111
 
112
- On every version bump update **both** `package.json` `version` and `SDK_VERSION` in `src/version.ts` — they must stay in sync so the `X-Finteqhub-SDK` header reports the right version. `src/version.test.ts` fails CI if they drift (`node scripts/sync-version.js` updates `src/version.ts` from `package.json`). Describe the release in [CHANGELOG.md](CHANGELOG.md), including migration notes for breaking changes.
112
+ On every version bump update **both** `package.json` `version` and `SDK_VERSION` in `src/version.ts` — they must stay in sync so the `x-pgw-sdk` header reports the right version. `src/version.test.ts` fails CI if they drift (`node scripts/sync-version.js` updates `src/version.ts` from `package.json`). Describe the release in [CHANGELOG.md](CHANGELOG.md), including migration notes for breaking changes.
113
113
 
114
114
  ### Beta releases
115
115
 
@@ -1,3 +1,3 @@
1
- export declare const SDK_HEADER_NAME = "X-Finteqhub-SDK";
2
- export declare const SDK_VERSION = "0.12.0";
1
+ export declare const SDK_HEADER_NAME = "x-pgw-sdk";
2
+ export declare const SDK_VERSION = "0.13.1";
3
3
  export declare const SDK_HEADER_VALUE: string;
@@ -1,3 +1,3 @@
1
- export const SDK_HEADER_NAME = "X-Finteqhub-SDK";
2
- export const SDK_VERSION = "0.12.0";
1
+ export const SDK_HEADER_NAME = "x-pgw-sdk";
2
+ export const SDK_VERSION = "0.13.1";
3
3
  export const SDK_HEADER_VALUE = `sdk-js/${SDK_VERSION}`;
package/package.json CHANGED
@@ -1,13 +1,22 @@
1
1
  {
2
2
  "name": "@finteqhub/sdk-js",
3
- "version": "0.12.0",
3
+ "version": "0.13.1",
4
4
  "description": "SDK for interacting with FinteqHub processing API",
5
5
  "main": "./dist/index.js",
6
6
  "typings": "./dist/index.d.ts",
7
7
  "files": [
8
- "dist/*"
8
+ "dist/*",
9
+ "CHANGELOG.md"
9
10
  ],
10
11
  "author": "FinteqHub",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/finteqhub/sdk-js.git"
15
+ },
16
+ "homepage": "https://github.com/finteqhub/sdk-js#readme",
17
+ "bugs": {
18
+ "url": "https://github.com/finteqhub/sdk-js/issues"
19
+ },
11
20
  "devDependencies": {
12
21
  "@types/jest": "^29.1.1",
13
22
  "jest": "^29.1.2",