@vergelijkdirect/insurance-transmission-client 1.3.67 → 1.3.68

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 CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Partner-facing JavaScript/TypeScript client for the Vergelijkdirect Insurance Transmission API.
4
4
 
5
+ This repository also contains the **Partner API server** (`server/`) — a Node.js HTTP API on https://partner-api.vergelijkdirect.com that runs the same comparison flow server-side: partners send one request and receive a comparison id plus calculated rates. See [server/README.md](server/README.md). The browser client below is unaffected and keeps working as before.
6
+
5
7
  Use this client to request insurance rates from all partner-enabled providers in one flow, receive one combined `RateCollection`, work with normalized rate models, store selected offers, and call supporting API services for comparison sessions, vehicle data, documents, validation, packages, loans, partner data, and lookups.
6
8
 
7
9
  ## What It Can Do
package/package.json CHANGED
@@ -1,11 +1,13 @@
1
1
  {
2
2
  "name": "@vergelijkdirect/insurance-transmission-client",
3
- "version": "1.3.67",
3
+ "version": "1.3.68",
4
4
  "description": "",
5
5
  "main": "./src/js/index.js",
6
6
  "scripts": {
7
7
  "test": "jest --config jestconfig.json",
8
8
  "compile": "export NODE_OPTIONS=--openssl-legacy-provider; tsc",
9
+ "compile:server": "tsc -p server/tsconfig.json",
10
+ "start:server": "node server/js/index.js",
9
11
  "_browserify": "browserify src/tests/browser/${npm_config_arg}.webtest.js -o src/tests/browser/bundle.js",
10
12
  "browserify": "npm run _browserify"
11
13
  },
@@ -20,6 +22,7 @@
20
22
  "license": "ISC",
21
23
  "homepage": "https://bitbucket.org/vergelijkdirect/insurance-transmission-client#readme",
22
24
  "devDependencies": {
25
+ "@types/node": "^20.19.43",
23
26
  "jest": "^29.6.1",
24
27
  "jest-localstorage-mock": "^2.4.0",
25
28
  "ts-jest": "^29.1.1",
@@ -1 +1,2 @@
1
1
  export { default as LocalStorageAdapter } from "./local-storage.adapter";
2
+ export { default as MemoryStorageAdapter } from "./memory-storage.adapter";
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LocalStorageAdapter = void 0;
3
+ exports.MemoryStorageAdapter = exports.LocalStorageAdapter = void 0;
4
4
  var local_storage_adapter_1 = require("./local-storage.adapter");
5
5
  Object.defineProperty(exports, "LocalStorageAdapter", { enumerable: true, get: function () { return local_storage_adapter_1.default; } });
6
+ var memory_storage_adapter_1 = require("./memory-storage.adapter");
7
+ Object.defineProperty(exports, "MemoryStorageAdapter", { enumerable: true, get: function () { return memory_storage_adapter_1.default; } });
@@ -0,0 +1,14 @@
1
+ import { StorageInterface } from '../interfaces';
2
+ declare class MemoryStorageAdapter implements StorageInterface {
3
+ protected storage: {
4
+ [key: string]: any;
5
+ };
6
+ save(key: string, data: any): this;
7
+ put(key: string, data: any): this;
8
+ get(key: string): any;
9
+ remove(key: string): this;
10
+ all(): {
11
+ [key: string]: any;
12
+ };
13
+ }
14
+ export default MemoryStorageAdapter;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var MemoryStorageAdapter = /** @class */ (function () {
4
+ function MemoryStorageAdapter() {
5
+ this.storage = {};
6
+ }
7
+ MemoryStorageAdapter.prototype.save = function (key, data) {
8
+ if (this.storage[key] === undefined) {
9
+ this.storage[key] = [];
10
+ }
11
+ this.storage[key].push(data);
12
+ return this;
13
+ };
14
+ MemoryStorageAdapter.prototype.put = function (key, data) {
15
+ this.storage[key] = data;
16
+ return this;
17
+ };
18
+ MemoryStorageAdapter.prototype.get = function (key) {
19
+ if (this.storage[key] === undefined) {
20
+ return [];
21
+ }
22
+ return this.storage[key];
23
+ };
24
+ MemoryStorageAdapter.prototype.remove = function (key) {
25
+ delete this.storage[key];
26
+ return this;
27
+ };
28
+ MemoryStorageAdapter.prototype.all = function () {
29
+ return this.storage;
30
+ };
31
+ return MemoryStorageAdapter;
32
+ }());
33
+ exports.default = MemoryStorageAdapter;
@@ -86,16 +86,13 @@ var HttpClient = /** @class */ (function () {
86
86
  };
87
87
  };
88
88
  HttpClient.prototype.getDefaultHeaders = function () {
89
- var _a, _b;
90
- var headers = {
91
- 'Content-Type': 'application/json',
92
- 'ITC': 'true',
93
- };
94
- var credentials = (_a = this.environment) === null || _a === void 0 ? void 0 : _a.api.credentials;
89
+ var _a, _b, _c, _d;
90
+ var headers = __assign({ 'Content-Type': 'application/json', 'ITC': 'true' }, ((_b = (_a = this.environment) === null || _a === void 0 ? void 0 : _a.api.headers) !== null && _b !== void 0 ? _b : {}));
91
+ var credentials = (_c = this.environment) === null || _c === void 0 ? void 0 : _c.api.credentials;
95
92
  if (!credentials) {
96
93
  return headers;
97
94
  }
98
- var authType = (_b = credentials.authType) !== null && _b !== void 0 ? _b : 'headers';
95
+ var authType = (_d = credentials.authType) !== null && _d !== void 0 ? _d : 'headers';
99
96
  if (authType === 'headers' || authType === 'both') {
100
97
  headers['X-Partner-Access-Key'] = credentials.accessKey;
101
98
  headers['X-Partner-Secret'] = credentials.secret;
@@ -9,6 +9,14 @@ interface EnvironmentInterface {
9
9
  baseUrl: string;
10
10
  version: string;
11
11
  credentials?: PartnerCredentialsInterface;
12
+ /**
13
+ * Extra headers sent with every request. Server-side integrations use
14
+ * this to pass the partner context explicitly instead of relying on
15
+ * the API resolving it from the calling host.
16
+ */
17
+ headers?: {
18
+ [name: string]: string;
19
+ };
12
20
  };
13
21
  }
14
22
  export default EnvironmentInterface;
@@ -44,7 +44,7 @@ var Comparison = /** @class */ (function () {
44
44
  this.funnel = funnel;
45
45
  this.data = data;
46
46
  this.user = user;
47
- this.location = window.location;
47
+ this.location = typeof window !== 'undefined' ? window.location : { href: '' };
48
48
  this.updated_at = updated_at;
49
49
  this.created_at = created_at;
50
50
  }
@@ -31,7 +31,8 @@ var BikeResource = /** @class */ (function (_super) {
31
31
  'laka',
32
32
  'enra',
33
33
  'vergelijkdirect',
34
- 'fietszeker'
34
+ 'fietszeker',
35
+ 'moneyview',
35
36
  ];
36
37
  };
37
38
  // enra should not be in rates request as we have enra rate in db
@@ -122,7 +122,8 @@ var PackageService = /** @class */ (function () {
122
122
  return __generator(this, function (_a) {
123
123
  switch (_a.label) {
124
124
  case 0:
125
- if (localStorage.getItem('supplierID') && localStorage.getItem('placementID')) {
125
+ if (typeof localStorage !== 'undefined'
126
+ && localStorage.getItem('supplierID') && localStorage.getItem('placementID')) {
126
127
  criteria['SupplierID'] = localStorage.getItem('supplierID');
127
128
  criteria['PlacementID'] = localStorage.getItem('placementID');
128
129
  }
@@ -30,6 +30,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
30
30
  exports.supplierPlacementTracker = void 0;
31
31
  exports.supplierPlacementTracker = {
32
32
  setParams: function () {
33
+ if (typeof window === 'undefined' || typeof localStorage === 'undefined') {
34
+ return;
35
+ }
33
36
  var urlParams = new URLSearchParams(window.location.search);
34
37
  var supplierID = urlParams.get('supplierID');
35
38
  var placementID = urlParams.get('placementID');
@@ -39,16 +42,25 @@ exports.supplierPlacementTracker = {
39
42
  }
40
43
  },
41
44
  removeParams: function () {
45
+ if (typeof localStorage === 'undefined') {
46
+ return;
47
+ }
42
48
  localStorage.removeItem('supplierID');
43
49
  localStorage.removeItem('placementID');
44
50
  },
45
51
  getSubId: function () {
52
+ if (typeof window === 'undefined') {
53
+ return '';
54
+ }
46
55
  var urlParams = new URLSearchParams(window.location.search);
47
56
  var subID = urlParams.get('subid') || this.getCookie('ivanhoe_id');
48
57
  return (subID && subID.includes('ivan')) ? subID : '';
49
58
  },
50
59
  getCookie: function (name) {
51
60
  var e_1, _a;
61
+ if (typeof document === 'undefined') {
62
+ return '';
63
+ }
52
64
  var cookies = document.cookie.split(';');
53
65
  try {
54
66
  for (var cookies_1 = __values(cookies), cookies_1_1 = cookies_1.next(); !cookies_1_1.done; cookies_1_1 = cookies_1.next()) {