@finteqhub/sdk-js 0.7.1 → 0.9.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/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/src/consts.d.ts +4 -0
- package/dist/src/consts.js +4 -0
- package/dist/src/processing.js +2 -2
- package/dist/src/typings.d.ts +2 -0
- package/dist/src/utils.d.ts +32 -0
- package/dist/src/utils.js +56 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/src/processing.js
CHANGED
|
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { uuid } from "./utils";
|
|
10
|
+
import { getDeviceData, uuid } from "./utils";
|
|
11
11
|
export class FinteqHubProcessing {
|
|
12
12
|
constructor(apiUrl, fingerprintVisitorId, merchantId, sessionId) {
|
|
13
13
|
this.apiUrl = apiUrl;
|
|
@@ -44,7 +44,7 @@ export class FinteqHubProcessing {
|
|
|
44
44
|
submitForm(data) {
|
|
45
45
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
46
46
|
try {
|
|
47
|
-
const response = yield this.sendPost(`${this.apiUrl}/v1/transactions/submit-form`, data);
|
|
47
|
+
const response = yield this.sendPost(`${this.apiUrl}/v1/transactions/submit-form`, Object.assign({ session: Object.assign({ fingerprint: this.fingerprintVisitorId }, getDeviceData()) }, data));
|
|
48
48
|
const result = yield response.json();
|
|
49
49
|
if (result.error || response.status !== 200) {
|
|
50
50
|
reject(new Error(result.error));
|
package/dist/src/typings.d.ts
CHANGED
|
@@ -118,6 +118,7 @@ export declare type SubmitData = {
|
|
|
118
118
|
payer: Payer;
|
|
119
119
|
};
|
|
120
120
|
paymentMethod: string;
|
|
121
|
+
transactionType: string;
|
|
121
122
|
} | {
|
|
122
123
|
credentials: {
|
|
123
124
|
billingAddress: Address;
|
|
@@ -128,6 +129,7 @@ export declare type SubmitData = {
|
|
|
128
129
|
} | {
|
|
129
130
|
credentials: Record<string, string>;
|
|
130
131
|
paymentMethod: string;
|
|
132
|
+
transactionType: string;
|
|
131
133
|
};
|
|
132
134
|
export declare type ProcessOperationRedirectResponse = {
|
|
133
135
|
type: "redirect";
|
package/dist/src/utils.d.ts
CHANGED
|
@@ -1 +1,33 @@
|
|
|
1
|
+
export declare const DeviceType: {
|
|
2
|
+
Unknown: string;
|
|
3
|
+
Computer: string;
|
|
4
|
+
Tablet: string;
|
|
5
|
+
Phone: string;
|
|
6
|
+
Console: string;
|
|
7
|
+
Wearable: string;
|
|
8
|
+
TV: string;
|
|
9
|
+
};
|
|
1
10
|
export declare function uuid(): string;
|
|
11
|
+
export declare function getDeviceType(): string;
|
|
12
|
+
export declare function getDeviceData(): {
|
|
13
|
+
device: {
|
|
14
|
+
type: string;
|
|
15
|
+
browser: {
|
|
16
|
+
platform: string;
|
|
17
|
+
acceptHeader: string;
|
|
18
|
+
userAgent: string;
|
|
19
|
+
javaEnabled: boolean;
|
|
20
|
+
javaScriptEnabled: boolean;
|
|
21
|
+
language: string;
|
|
22
|
+
colorDepth: number;
|
|
23
|
+
screenHeight: number;
|
|
24
|
+
screenWidth: number;
|
|
25
|
+
windowHeight: number;
|
|
26
|
+
windowWidth: number;
|
|
27
|
+
windowInnerHeight: number;
|
|
28
|
+
windowInnerWidth: number;
|
|
29
|
+
timeZoneOffset: number;
|
|
30
|
+
timeZoneName: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
package/dist/src/utils.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
export const DeviceType = {
|
|
2
|
+
Unknown: "unknown",
|
|
3
|
+
Computer: "computer",
|
|
4
|
+
Tablet: "tablet",
|
|
5
|
+
Phone: "phone",
|
|
6
|
+
Console: "console",
|
|
7
|
+
Wearable: "wearable",
|
|
8
|
+
TV: "TV",
|
|
9
|
+
};
|
|
1
10
|
export function uuid() {
|
|
2
11
|
let seed = Date.now();
|
|
3
12
|
if (window.performance && typeof window.performance.now === "function") {
|
|
@@ -9,3 +18,50 @@ export function uuid() {
|
|
|
9
18
|
return (c === "x" ? random : random & (0x3 | 0x8)).toString(16);
|
|
10
19
|
});
|
|
11
20
|
}
|
|
21
|
+
export function getDeviceType() {
|
|
22
|
+
const userAgent = navigator.userAgent.toLowerCase();
|
|
23
|
+
if (/watch|wearable|galaxy watch|apple watch/i.test(userAgent)) {
|
|
24
|
+
return DeviceType.Wearable;
|
|
25
|
+
}
|
|
26
|
+
if (/ipad|tablet/i.test(userAgent)) {
|
|
27
|
+
return DeviceType.Tablet;
|
|
28
|
+
}
|
|
29
|
+
if (/smart[- ]?tv|hbbtv|netcast|viera|aquos|dtv|appletv|googletv|roku|hulu|smarttv/i.test(userAgent)) {
|
|
30
|
+
return DeviceType.TV;
|
|
31
|
+
}
|
|
32
|
+
if (/xbox|playstation|nintendo|switch/i.test(userAgent)) {
|
|
33
|
+
return DeviceType.Console;
|
|
34
|
+
}
|
|
35
|
+
if (/mobile|android|iphone|ipod|blackberry|phone/i.test(userAgent)) {
|
|
36
|
+
return DeviceType.Phone;
|
|
37
|
+
}
|
|
38
|
+
if (/windows|mac os|x11|ubuntu|fedora|debian/i.test(userAgent)) {
|
|
39
|
+
return DeviceType.Computer;
|
|
40
|
+
}
|
|
41
|
+
return DeviceType.Unknown;
|
|
42
|
+
}
|
|
43
|
+
export function getDeviceData() {
|
|
44
|
+
var _a, _b, _c;
|
|
45
|
+
return {
|
|
46
|
+
device: {
|
|
47
|
+
type: getDeviceType(),
|
|
48
|
+
browser: {
|
|
49
|
+
platform: (_c = (_b = (_a = navigator.userAgentData) === null || _a === void 0 ? void 0 : _a.platform) !== null && _b !== void 0 ? _b : navigator.platform) !== null && _c !== void 0 ? _c : "unknown",
|
|
50
|
+
acceptHeader: "application/json",
|
|
51
|
+
userAgent: navigator.userAgent,
|
|
52
|
+
javaEnabled: !!(navigator === null || navigator === void 0 ? void 0 : navigator.javaEnabled) && navigator.javaEnabled() ? navigator.javaEnabled() : false,
|
|
53
|
+
javaScriptEnabled: true,
|
|
54
|
+
language: navigator.language,
|
|
55
|
+
colorDepth: screen.colorDepth,
|
|
56
|
+
screenHeight: screen.height,
|
|
57
|
+
screenWidth: screen.width,
|
|
58
|
+
windowHeight: window.outerHeight,
|
|
59
|
+
windowWidth: window.outerWidth,
|
|
60
|
+
windowInnerHeight: window.innerHeight,
|
|
61
|
+
windowInnerWidth: window.innerWidth,
|
|
62
|
+
timeZoneOffset: new Date().getTimezoneOffset(),
|
|
63
|
+
timeZoneName: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|