abuse-sdk 1.0.0 → 2.0.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.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -11
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -3
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";exports.AbuseSDK=class{constructor(t){this.cache=null,this.
|
|
1
|
+
"use strict";exports.AbuseSDK=class{constructor(t){this.cache=null,this.adidList=[],this.lastFetchTime=0,this.r2Url=t.r2Url,this.cacheTTL=t.cacheTTL??3e5}async fetchData(){const t=Date.now();if(this.cache&&t-this.lastFetchTime<this.cacheTTL)return;const s=await fetch(this.r2Url);if(!s.ok)throw new Error(`Failed to fetch blacklist: ${s.status} ${s.statusText}`);const a=(await s.text()).split("\n").map(t=>t.trim()).filter(t=>t.length>0);this.adidList=a,this.cache=new Set(a),this.lastFetchTime=t}async check(t){return await this.fetchData(),this.cache.has(t)}async getList(){return await this.fetchData(),this.adidList}async refresh(){this.cache=null,this.adidList=[],this.lastFetchTime=0,await this.fetchData()}};
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["export interface AbuseSDKOptions {\n r2Url: string;\n cacheTTL?: number;\n}\n\nexport
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["export interface AbuseSDKOptions {\n r2Url: string;\n cacheTTL?: number;\n}\n\nexport class AbuseSDK {\n private readonly r2Url: string;\n private readonly cacheTTL: number;\n private cache: Set<string> | null = null;\n private adidList: string[] = [];\n private lastFetchTime: number = 0;\n\n constructor(options: AbuseSDKOptions) {\n this.r2Url = options.r2Url;\n this.cacheTTL = options.cacheTTL ?? 5 * 60 * 1000; // 기본 5분\n }\n\n private async fetchData(): Promise<void> {\n const now = Date.now();\n\n if (this.cache && now - this.lastFetchTime < this.cacheTTL) {\n return;\n }\n\n const response = await fetch(this.r2Url);\n\n if (!response.ok) {\n throw new Error(`Failed to fetch blacklist: ${response.status} ${response.statusText}`);\n }\n\n const text = await response.text();\n const adids = text\n .split('\\n')\n .map((line) => line.trim())\n .filter((line) => line.length > 0);\n\n this.adidList = adids;\n this.cache = new Set(adids);\n this.lastFetchTime = now;\n }\n\n async check(adid: string): Promise<boolean> {\n await this.fetchData();\n return this.cache!.has(adid);\n }\n\n async getList(): Promise<string[]> {\n await this.fetchData();\n return this.adidList;\n }\n\n async refresh(): Promise<void> {\n this.cache = null;\n this.adidList = [];\n this.lastFetchTime = 0;\n await this.fetchData();\n }\n}\n"],"names":["constructor","options","this","cache","adidList","lastFetchTime","r2Url","cacheTTL","fetchData","now","Date","response","fetch","ok","Error","status","statusText","adids","text","split","map","line","trim","filter","length","Set","check","adid","has","getList","refresh"],"mappings":"oCAYE,WAAAA,CAAYC,GAJJC,KAAAC,MAA4B,KAC5BD,KAAAE,SAAqB,GACrBF,KAAAG,cAAwB,EAG9BH,KAAKI,MAAQL,EAAQK,MACrBJ,KAAKK,SAAWN,EAAQM,UAAY,GACtC,CAEQ,eAAMC,GACZ,MAAMC,EAAMC,KAAKD,MAEjB,GAAIP,KAAKC,OAASM,EAAMP,KAAKG,cAAgBH,KAAKK,SAChD,OAGF,MAAMI,QAAiBC,MAAMV,KAAKI,OAElC,IAAKK,EAASE,GACZ,MAAM,IAAIC,MAAM,8BAA8BH,EAASI,UAAUJ,EAASK,cAG5E,MACMC,SADaN,EAASO,QAEzBC,MAAM,MACNC,IAAKC,GAASA,EAAKC,QACnBC,OAAQF,GAASA,EAAKG,OAAS,GAElCtB,KAAKE,SAAWa,EAChBf,KAAKC,MAAQ,IAAIsB,IAAIR,GACrBf,KAAKG,cAAgBI,CACvB,CAEA,WAAMiB,CAAMC,GAEV,aADMzB,KAAKM,YACJN,KAAKC,MAAOyB,IAAID,EACzB,CAEA,aAAME,GAEJ,aADM3B,KAAKM,YACJN,KAAKE,QACd,CAEA,aAAM0B,GACJ5B,KAAKC,MAAQ,KACbD,KAAKE,SAAW,GAChBF,KAAKG,cAAgB,QACfH,KAAKM,WACb"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,25 +2,15 @@ export interface AbuseSDKOptions {
|
|
|
2
2
|
r2Url: string;
|
|
3
3
|
cacheTTL?: number;
|
|
4
4
|
}
|
|
5
|
-
export interface BlacklistData {
|
|
6
|
-
version: string;
|
|
7
|
-
updatedAt: string;
|
|
8
|
-
adids: string[];
|
|
9
|
-
}
|
|
10
5
|
export declare class AbuseSDK {
|
|
11
6
|
private readonly r2Url;
|
|
12
7
|
private readonly cacheTTL;
|
|
13
8
|
private cache;
|
|
14
|
-
private
|
|
9
|
+
private adidList;
|
|
15
10
|
private lastFetchTime;
|
|
16
11
|
constructor(options: AbuseSDKOptions);
|
|
17
12
|
private fetchData;
|
|
18
13
|
check(adid: string): Promise<boolean>;
|
|
19
14
|
getList(): Promise<string[]>;
|
|
20
|
-
getMetadata(): Promise<{
|
|
21
|
-
version: string;
|
|
22
|
-
updatedAt: string;
|
|
23
|
-
count: number;
|
|
24
|
-
}>;
|
|
25
15
|
refresh(): Promise<void>;
|
|
26
16
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
class t{constructor(t){this.cache=null,this.
|
|
1
|
+
class t{constructor(t){this.cache=null,this.adidList=[],this.lastFetchTime=0,this.r2Url=t.r2Url,this.cacheTTL=t.cacheTTL??3e5}async fetchData(){const t=Date.now();if(this.cache&&t-this.lastFetchTime<this.cacheTTL)return;const s=await fetch(this.r2Url);if(!s.ok)throw new Error(`Failed to fetch blacklist: ${s.status} ${s.statusText}`);const a=(await s.text()).split("\n").map(t=>t.trim()).filter(t=>t.length>0);this.adidList=a,this.cache=new Set(a),this.lastFetchTime=t}async check(t){return await this.fetchData(),this.cache.has(t)}async getList(){return await this.fetchData(),this.adidList}async refresh(){this.cache=null,this.adidList=[],this.lastFetchTime=0,await this.fetchData()}}export{t as AbuseSDK};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["export interface AbuseSDKOptions {\n r2Url: string;\n cacheTTL?: number;\n}\n\nexport
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["export interface AbuseSDKOptions {\n r2Url: string;\n cacheTTL?: number;\n}\n\nexport class AbuseSDK {\n private readonly r2Url: string;\n private readonly cacheTTL: number;\n private cache: Set<string> | null = null;\n private adidList: string[] = [];\n private lastFetchTime: number = 0;\n\n constructor(options: AbuseSDKOptions) {\n this.r2Url = options.r2Url;\n this.cacheTTL = options.cacheTTL ?? 5 * 60 * 1000; // 기본 5분\n }\n\n private async fetchData(): Promise<void> {\n const now = Date.now();\n\n if (this.cache && now - this.lastFetchTime < this.cacheTTL) {\n return;\n }\n\n const response = await fetch(this.r2Url);\n\n if (!response.ok) {\n throw new Error(`Failed to fetch blacklist: ${response.status} ${response.statusText}`);\n }\n\n const text = await response.text();\n const adids = text\n .split('\\n')\n .map((line) => line.trim())\n .filter((line) => line.length > 0);\n\n this.adidList = adids;\n this.cache = new Set(adids);\n this.lastFetchTime = now;\n }\n\n async check(adid: string): Promise<boolean> {\n await this.fetchData();\n return this.cache!.has(adid);\n }\n\n async getList(): Promise<string[]> {\n await this.fetchData();\n return this.adidList;\n }\n\n async refresh(): Promise<void> {\n this.cache = null;\n this.adidList = [];\n this.lastFetchTime = 0;\n await this.fetchData();\n }\n}\n"],"names":["AbuseSDK","constructor","options","this","cache","adidList","lastFetchTime","r2Url","cacheTTL","fetchData","now","Date","response","fetch","ok","Error","status","statusText","adids","text","split","map","line","trim","filter","length","Set","check","adid","has","getList","refresh"],"mappings":"MAKaA,EAOX,WAAAC,CAAYC,GAJJC,KAAAC,MAA4B,KAC5BD,KAAAE,SAAqB,GACrBF,KAAAG,cAAwB,EAG9BH,KAAKI,MAAQL,EAAQK,MACrBJ,KAAKK,SAAWN,EAAQM,UAAY,GACtC,CAEQ,eAAMC,GACZ,MAAMC,EAAMC,KAAKD,MAEjB,GAAIP,KAAKC,OAASM,EAAMP,KAAKG,cAAgBH,KAAKK,SAChD,OAGF,MAAMI,QAAiBC,MAAMV,KAAKI,OAElC,IAAKK,EAASE,GACZ,MAAM,IAAIC,MAAM,8BAA8BH,EAASI,UAAUJ,EAASK,cAG5E,MACMC,SADaN,EAASO,QAEzBC,MAAM,MACNC,IAAKC,GAASA,EAAKC,QACnBC,OAAQF,GAASA,EAAKG,OAAS,GAElCtB,KAAKE,SAAWa,EAChBf,KAAKC,MAAQ,IAAIsB,IAAIR,GACrBf,KAAKG,cAAgBI,CACvB,CAEA,WAAMiB,CAAMC,GAEV,aADMzB,KAAKM,YACJN,KAAKC,MAAOyB,IAAID,EACzB,CAEA,aAAME,GAEJ,aADM3B,KAAKM,YACJN,KAAKE,QACd,CAEA,aAAM0B,GACJ5B,KAAKC,MAAQ,KACbD,KAAKE,SAAW,GAChBF,KAAKG,cAAgB,QACfH,KAAKM,WACb"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "abuse-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "ADID blacklist checker SDK for Cloudflare R2",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -29,13 +29,16 @@
|
|
|
29
29
|
"author": "",
|
|
30
30
|
"license": "MIT",
|
|
31
31
|
"devDependencies": {
|
|
32
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
32
33
|
"@rollup/plugin-typescript": "^11.1.6",
|
|
33
34
|
"rollup": "^4.9.6",
|
|
34
|
-
"@rollup/plugin-terser": "^0.4.4",
|
|
35
35
|
"tslib": "^2.6.2",
|
|
36
36
|
"typescript": "^5.3.3"
|
|
37
37
|
},
|
|
38
38
|
"engines": {
|
|
39
39
|
"node": ">=18.0.0"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"abuse-sdk": "^1.0.0"
|
|
40
43
|
}
|
|
41
|
-
}
|
|
44
|
+
}
|