-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcollection.bru
123 lines (112 loc) · 3.98 KB
/
collection.bru
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
headers {
X-Fresns-Space-Id: {{apiSpaceId}}
X-Fresns-App-Id: {{appId}}
X-Fresns-Client-Platform-Id: {{clientPlatformId}}
X-Fresns-Client-Version: {{clientVersion}}
X-Fresns-Client-Device-Info:
X-Fresns-Client-Timezone:
X-Fresns-Client-Lang-Tag: {{clientLangTag}}
X-Fresns-Client-Content-Format: {{clientContentFormat}}
X-Fresns-Aid: {{aid}}
X-Fresns-Aid-Token: {{aidToken}}
X-Fresns-Uid: {{uid}}
X-Fresns-Uid-Token: {{uidToken}}
X-Fresns-Signature:
X-Fresns-Signature-Timestamp:
}
auth {
mode: none
}
script:pre-request {
const CryptoJS = require("crypto-js");
// Device Info (IPv4 or IPv6 is required, the rest can be empty)
const deviceInfoObj = {
"agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
"type": "Desktop",
"platformName": "Mac 10.15.7",
"platformFamily": "Mac",
"platformVersion": "10.15.7",
"browserName": "Chrome 126",
"browserFamily": "Chrome",
"browserVersion": "126",
"browserEngine": "Blink",
"deviceFamily": "Apple",
"deviceModel": "Mac",
"deviceMac": "2c:89:dc:71:b6:12",
"appImei": null,
"appAndroidId": null,
"appOaid": null,
"appIdfa": null,
"simImsi": null,
"networkType": "wifi",
"networkIpv4": "137.132.250.10",
"networkIpv6": null,
"networkPort": "8080",
"networkTimezone": "Asia/Singapore",
"networkOffset": 28800,
"networkIsp": "National University of Singapore",
"networkOrg": "National University of Singapore",
"networkAs": "AS7472 NUS Information Technology",
"networkAsName": "NUS-AS-AP",
"networkReverse": null,
"networkMobile": false,
"networkProxy": false,
"networkHosting": false,
"mapId": 2, // Dictionary data: Map service provider number
"latitude": 1.29758,
"longitude": 103.773,
"continent": "Asia",
"continentCode": "AS",
"country": "Singapore",
"countryCode": "SG",
"region": "Central Singapore",
"regionCode": "01",
"city": "Singapore",
"cityCode": "SG",
"district": "Queenstown",
"address": null,
"zip": "119259"
};
const deviceInfoString = JSON.stringify(deviceInfoObj);
const deviceInfoWordArray = CryptoJS.enc.Utf8.parse(deviceInfoString);
const deviceInfoBase64 = CryptoJS.enc.Base64.stringify(deviceInfoWordArray);
// Client Timezone
const date = new Date();
const timezoneOffsetInHours = date.getTimezoneOffset() / -60;
const utcTimezone = (timezoneOffsetInHours > 0 ? '+' : '') + timezoneOffsetInHours.toString();
// Signature Timestamp (UTC+0)
const signTimestamp = String(Date.now());
// Headers
const headers = {
'X-Fresns-Space-Id': bru.getEnvVar("apiSpaceId"),
'X-Fresns-App-Id': bru.getEnvVar("appId"),
'X-Fresns-Client-Platform-Id': bru.getEnvVar("clientPlatformId"),
'X-Fresns-Client-Version': bru.getEnvVar("clientVersion"),
'X-Fresns-Aid': bru.getEnvVar("aid"),
'X-Fresns-Aid-Token': bru.getEnvVar("aidToken"),
'X-Fresns-Uid': bru.getEnvVar("uid"),
'X-Fresns-Uid-Token': bru.getEnvVar("uidToken"),
'X-Fresns-Signature-Timestamp': signTimestamp,
};
// App Key
const appKey = bru.getEnvVar("appKey");
// Signature
const strA = [
'X-Fresns-Space-Id',
'X-Fresns-App-Id',
'X-Fresns-Client-Platform-Id',
'X-Fresns-Client-Version',
'X-Fresns-Aid',
'X-Fresns-Aid-Token',
'X-Fresns-Uid',
'X-Fresns-Uid-Token',
'X-Fresns-Signature-Timestamp',
].filter((v) => headers[v]).sort();
const stringSignTemp = strA.map((key) => `${key}=${headers[key]}`).join('&') + `&AppKey=${appKey}`;
const signature = CryptoJS.SHA256(stringSignTemp);
// Header Settings
req.setHeader("X-Fresns-Client-Device-Info", deviceInfoBase64);
req.setHeader("X-Fresns-Client-Timezone", utcTimezone);
req.setHeader("X-Fresns-Signature", signature);
req.setHeader("X-Fresns-Signature-Timestamp", signTimestamp);
}