abuse-sdk 1.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 +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +41 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";exports.AbuseSDK=class{constructor(t){this.cache=null,this.rawData=null,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 a=await fetch(this.r2Url);if(!a.ok)throw new Error(`Failed to fetch blacklist: ${a.status} ${a.statusText}`);const s=await a.json();this.rawData=s,this.cache=new Set(s.adids),this.lastFetchTime=t}async check(t){return await this.fetchData(),this.cache.has(t)}async getList(){return await this.fetchData(),this.rawData.adids}async getMetadata(){return await this.fetchData(),{version:this.rawData.version,updatedAt:this.rawData.updatedAt,count:this.rawData.adids.length}}async refresh(){this.cache=null,this.rawData=null,this.lastFetchTime=0,await this.fetchData()}};
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["export interface AbuseSDKOptions {\n r2Url: string;\n cacheTTL?: number;\n}\n\nexport interface BlacklistData {\n version: string;\n updatedAt: string;\n adids: string[];\n}\n\nexport class AbuseSDK {\n private readonly r2Url: string;\n private readonly cacheTTL: number;\n private cache: Set<string> | null = null;\n private rawData: BlacklistData | null = null;\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 data: BlacklistData = await response.json();\n this.rawData = data;\n this.cache = new Set(data.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.rawData!.adids;\n }\n\n async getMetadata(): Promise<{ version: string; updatedAt: string; count: number }> {\n await this.fetchData();\n return {\n version: this.rawData!.version,\n updatedAt: this.rawData!.updatedAt,\n count: this.rawData!.adids.length,\n };\n }\n\n async refresh(): Promise<void> {\n this.cache = null;\n this.rawData = null;\n this.lastFetchTime = 0;\n await this.fetchData();\n }\n}\n\n"],"names":["constructor","options","this","cache","rawData","lastFetchTime","r2Url","cacheTTL","fetchData","now","Date","response","fetch","ok","Error","status","statusText","data","json","Set","adids","check","adid","has","getList","getMetadata","version","updatedAt","count","length","refresh"],"mappings":"oCAkBE,WAAAA,CAAYC,GAJJC,KAAAC,MAA4B,KAC5BD,KAAAE,QAAgC,KAChCF,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,MAAMC,QAA4BN,EAASO,OAC3ChB,KAAKE,QAAUa,EACff,KAAKC,MAAQ,IAAIgB,IAAIF,EAAKG,OAC1BlB,KAAKG,cAAgBI,CACvB,CAEA,WAAMY,CAAMC,GAEV,aADMpB,KAAKM,YACJN,KAAKC,MAAOoB,IAAID,EACzB,CAEA,aAAME,GAEJ,aADMtB,KAAKM,YACJN,KAAKE,QAASgB,KACvB,CAEA,iBAAMK,GAEJ,aADMvB,KAAKM,YACJ,CACLkB,QAASxB,KAAKE,QAASsB,QACvBC,UAAWzB,KAAKE,QAASuB,UACzBC,MAAO1B,KAAKE,QAASgB,MAAMS,OAE/B,CAEA,aAAMC,GACJ5B,KAAKC,MAAQ,KACbD,KAAKE,QAAU,KACfF,KAAKG,cAAgB,QACfH,KAAKM,WACb"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface AbuseSDKOptions {
|
|
2
|
+
r2Url: string;
|
|
3
|
+
cacheTTL?: number;
|
|
4
|
+
}
|
|
5
|
+
export interface BlacklistData {
|
|
6
|
+
version: string;
|
|
7
|
+
updatedAt: string;
|
|
8
|
+
adids: string[];
|
|
9
|
+
}
|
|
10
|
+
export declare class AbuseSDK {
|
|
11
|
+
private readonly r2Url;
|
|
12
|
+
private readonly cacheTTL;
|
|
13
|
+
private cache;
|
|
14
|
+
private rawData;
|
|
15
|
+
private lastFetchTime;
|
|
16
|
+
constructor(options: AbuseSDKOptions);
|
|
17
|
+
private fetchData;
|
|
18
|
+
check(adid: string): Promise<boolean>;
|
|
19
|
+
getList(): Promise<string[]>;
|
|
20
|
+
getMetadata(): Promise<{
|
|
21
|
+
version: string;
|
|
22
|
+
updatedAt: string;
|
|
23
|
+
count: number;
|
|
24
|
+
}>;
|
|
25
|
+
refresh(): Promise<void>;
|
|
26
|
+
}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
class t{constructor(t){this.cache=null,this.rawData=null,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 a=await fetch(this.r2Url);if(!a.ok)throw new Error(`Failed to fetch blacklist: ${a.status} ${a.statusText}`);const s=await a.json();this.rawData=s,this.cache=new Set(s.adids),this.lastFetchTime=t}async check(t){return await this.fetchData(),this.cache.has(t)}async getList(){return await this.fetchData(),this.rawData.adids}async getMetadata(){return await this.fetchData(),{version:this.rawData.version,updatedAt:this.rawData.updatedAt,count:this.rawData.adids.length}}async refresh(){this.cache=null,this.rawData=null,this.lastFetchTime=0,await this.fetchData()}}export{t as AbuseSDK};
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["export interface AbuseSDKOptions {\n r2Url: string;\n cacheTTL?: number;\n}\n\nexport interface BlacklistData {\n version: string;\n updatedAt: string;\n adids: string[];\n}\n\nexport class AbuseSDK {\n private readonly r2Url: string;\n private readonly cacheTTL: number;\n private cache: Set<string> | null = null;\n private rawData: BlacklistData | null = null;\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 data: BlacklistData = await response.json();\n this.rawData = data;\n this.cache = new Set(data.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.rawData!.adids;\n }\n\n async getMetadata(): Promise<{ version: string; updatedAt: string; count: number }> {\n await this.fetchData();\n return {\n version: this.rawData!.version,\n updatedAt: this.rawData!.updatedAt,\n count: this.rawData!.adids.length,\n };\n }\n\n async refresh(): Promise<void> {\n this.cache = null;\n this.rawData = null;\n this.lastFetchTime = 0;\n await this.fetchData();\n }\n}\n\n"],"names":["AbuseSDK","constructor","options","this","cache","rawData","lastFetchTime","r2Url","cacheTTL","fetchData","now","Date","response","fetch","ok","Error","status","statusText","data","json","Set","adids","check","adid","has","getList","getMetadata","version","updatedAt","count","length","refresh"],"mappings":"MAWaA,EAOX,WAAAC,CAAYC,GAJJC,KAAAC,MAA4B,KAC5BD,KAAAE,QAAgC,KAChCF,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,MAAMC,QAA4BN,EAASO,OAC3ChB,KAAKE,QAAUa,EACff,KAAKC,MAAQ,IAAIgB,IAAIF,EAAKG,OAC1BlB,KAAKG,cAAgBI,CACvB,CAEA,WAAMY,CAAMC,GAEV,aADMpB,KAAKM,YACJN,KAAKC,MAAOoB,IAAID,EACzB,CAEA,aAAME,GAEJ,aADMtB,KAAKM,YACJN,KAAKE,QAASgB,KACvB,CAEA,iBAAMK,GAEJ,aADMvB,KAAKM,YACJ,CACLkB,QAASxB,KAAKE,QAASsB,QACvBC,UAAWzB,KAAKE,QAASuB,UACzBC,MAAO1B,KAAKE,QAASgB,MAAMS,OAE/B,CAEA,aAAMC,GACJ5B,KAAKC,MAAQ,KACbD,KAAKE,QAAU,KACfF,KAAKG,cAAgB,QACfH,KAAKM,WACb"}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "abuse-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "ADID blacklist checker SDK for Cloudflare R2",
|
|
5
|
+
"main": "./dist/index.cjs",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"require": "./dist/index.cjs",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "rollup -c rollup.config.mjs",
|
|
20
|
+
"prepublishOnly": "npm run build"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"adid",
|
|
24
|
+
"abuse",
|
|
25
|
+
"blacklist",
|
|
26
|
+
"cloudflare",
|
|
27
|
+
"r2"
|
|
28
|
+
],
|
|
29
|
+
"author": "",
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
33
|
+
"rollup": "^4.9.6",
|
|
34
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
35
|
+
"tslib": "^2.6.2",
|
|
36
|
+
"typescript": "^5.3.3"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=18.0.0"
|
|
40
|
+
}
|
|
41
|
+
}
|