@jolibox/implement 1.1.13-beta.3 → 1.1.13-beta.4
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/.rush/temp/package-deps_build.json +5 -5
- package/dist/common/ads/anti-cheating.d.ts +5 -0
- package/dist/index.js +3 -3
- package/dist/index.native.js +5 -5
- package/implement.build.log +2 -2
- package/package.json +4 -4
- package/src/common/ads/anti-cheating.test.ts +4 -2
- package/src/common/ads/anti-cheating.ts +10 -4
- package/src/h5/http/utils/__tests__/xua.test.ts +1 -1
- package/src/native/api/ads.ts +1 -1
package/implement.build.log
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Invoking: npm run clean && npm run build:esm && tsc
|
|
2
2
|
|
|
3
|
-
> @jolibox/implement@1.1.13-beta.
|
|
3
|
+
> @jolibox/implement@1.1.13-beta.4 clean
|
|
4
4
|
> rimraf ./dist
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
> @jolibox/implement@1.1.13-beta.
|
|
7
|
+
> @jolibox/implement@1.1.13-beta.4 build:esm
|
|
8
8
|
> BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=esm
|
|
9
9
|
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jolibox/implement",
|
|
3
3
|
"description": "This project is Jolibox JS-SDk implement for Native && H5",
|
|
4
|
-
"version": "1.1.13-beta.
|
|
4
|
+
"version": "1.1.13-beta.4",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@jolibox/common": "1.1.13-beta.
|
|
10
|
-
"@jolibox/types": "1.1.13-beta.
|
|
11
|
-
"@jolibox/native-bridge": "1.
|
|
9
|
+
"@jolibox/common": "1.1.13-beta.4",
|
|
10
|
+
"@jolibox/types": "1.1.13-beta.4",
|
|
11
|
+
"@jolibox/native-bridge": "1.1.13-beta.4",
|
|
12
12
|
"localforage": "1.10.0",
|
|
13
13
|
"@jolibox/ui": "1.0.0",
|
|
14
14
|
"web-vitals": "4.2.4"
|
|
@@ -20,7 +20,9 @@ describe('createLeadingNotifiableDebounce', () => {
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
it('should ban initial call', async () => {
|
|
23
|
-
|
|
23
|
+
(window as any).__joliboxLocalStorage__ = window.localStorage;
|
|
24
|
+
|
|
25
|
+
(window as any).__joliboxLocalStorage__.clear();
|
|
24
26
|
|
|
25
27
|
const adsAntiCheating = new AdsAntiCheating(track, http, () => true, config);
|
|
26
28
|
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
@@ -32,7 +34,7 @@ describe('createLeadingNotifiableDebounce', () => {
|
|
|
32
34
|
});
|
|
33
35
|
|
|
34
36
|
it('should ban continous calling', async () => {
|
|
35
|
-
|
|
37
|
+
(window as any).__joliboxLocalStorage__.clear();
|
|
36
38
|
|
|
37
39
|
const adsAntiCheating = new AdsAntiCheating(track, http, () => true, config);
|
|
38
40
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
@@ -24,6 +24,12 @@ export interface IAdsAntiCheatingConfig {
|
|
|
24
24
|
highFreqThreshold?: number; // default 2000 (2s)
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
declare global {
|
|
28
|
+
interface Window {
|
|
29
|
+
__joliboxLocalStorage__: Storage;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
27
33
|
export class AdsAntiCheating {
|
|
28
34
|
private checkShouldBanInitial: ReturnType<typeof createInitialStrategy>;
|
|
29
35
|
private checkShouldBanHighFreq: ReturnType<typeof createHighFreqStrategy>;
|
|
@@ -177,7 +183,7 @@ const createBanForTimeStrategy = (
|
|
|
177
183
|
_records: [] as CallAdsHistory[],
|
|
178
184
|
init() {
|
|
179
185
|
try {
|
|
180
|
-
const fromStorage = JSON.parse(window.
|
|
186
|
+
const fromStorage = JSON.parse(window.__joliboxLocalStorage__.getItem(TIMESTAMP_STORAGE_KEY) ?? '[]');
|
|
181
187
|
if (Array.isArray(fromStorage)) {
|
|
182
188
|
this._records = fromStorage;
|
|
183
189
|
} else {
|
|
@@ -192,7 +198,7 @@ const createBanForTimeStrategy = (
|
|
|
192
198
|
},
|
|
193
199
|
set values(value: CallAdsHistory[]) {
|
|
194
200
|
try {
|
|
195
|
-
window.
|
|
201
|
+
window.__joliboxLocalStorage__.setItem(TIMESTAMP_STORAGE_KEY, JSON.stringify(value));
|
|
196
202
|
} catch {
|
|
197
203
|
// console.error('Failed to save timestamps');
|
|
198
204
|
// do nothing
|
|
@@ -205,7 +211,7 @@ const createBanForTimeStrategy = (
|
|
|
205
211
|
_record: false,
|
|
206
212
|
init() {
|
|
207
213
|
try {
|
|
208
|
-
const fromStorage = JSON.parse(window.
|
|
214
|
+
const fromStorage = JSON.parse(window.__joliboxLocalStorage__.getItem(BAN_FOR_TIME_KEY) ?? 'false');
|
|
209
215
|
if (typeof fromStorage === 'boolean') {
|
|
210
216
|
this._record = fromStorage;
|
|
211
217
|
}
|
|
@@ -228,7 +234,7 @@ const createBanForTimeStrategy = (
|
|
|
228
234
|
},
|
|
229
235
|
set value(value: boolean) {
|
|
230
236
|
try {
|
|
231
|
-
window.
|
|
237
|
+
window.__joliboxLocalStorage__.setItem(BAN_FOR_TIME_KEY, JSON.stringify(value));
|
|
232
238
|
} catch {
|
|
233
239
|
// do nothing
|
|
234
240
|
}
|
|
@@ -4,7 +4,7 @@ import { isValidUUIDV4 } from '@jolibox/common';
|
|
|
4
4
|
|
|
5
5
|
describe('xua', () => {
|
|
6
6
|
it('test xua', () => {
|
|
7
|
-
|
|
7
|
+
(window as any).__joliboxLocalStorage__ = window.localStorage;
|
|
8
8
|
const xua = xUserAgent();
|
|
9
9
|
const deviceInfoRegex = /.* (\(.*\) ).*/;
|
|
10
10
|
const deviceInfoMatch = xua.match(deviceInfoRegex);
|
package/src/native/api/ads.ts
CHANGED