abuse-sdk 2.0.0 → 3.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 +4 -0
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";let t=null;class i{constructor(t){this.cache=null,this.adidList=[],this.lastFetchTime=0,this.fetchPromise=null,this.r2Url=t.r2Url,this.cacheTTL=t.cacheTTL??36e5}async fetchData(){const t=Date.now();if(!(this.cache&&t-this.lastFetchTime<this.cacheTTL)){if(this.fetchPromise)return this.fetchPromise;this.fetchPromise=this.doFetch();try{await this.fetchPromise}finally{this.fetchPromise=null}}}async doFetch(){const t=await fetch(this.r2Url);if(!t.ok)throw new Error(`Failed to fetch blacklist: ${t.status} ${t.statusText}`);const i=(await t.text()).split("\n").map(t=>t.trim()).filter(t=>t.length>0);this.adidList=i,this.cache=new Set(i),this.lastFetchTime=Date.now()}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()}}exports.AbuseSDK=i,exports.getInstance=function(){if(!t)throw new Error("AbuseSDK is not initialized. Call init() first.");return t},exports.init=function(s){t||(t=new i(s))};
|
|
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 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 ??
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["export interface AbuseSDKOptions {\n r2Url: string;\n cacheTTL?: number;\n}\n\nlet instance: AbuseSDK | null = null;\n\nexport function init(options: AbuseSDKOptions): void {\n if (instance) {\n return;\n }\n instance = new AbuseSDK(options);\n}\n\nexport function getInstance(): AbuseSDK {\n if (!instance) {\n throw new Error('AbuseSDK is not initialized. Call init() first.');\n }\n return instance;\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 private fetchPromise: Promise<void> | null = null;\n\n constructor(options: AbuseSDKOptions) {\n this.r2Url = options.r2Url;\n this.cacheTTL = options.cacheTTL ?? 60 * 60 * 1000; // 기본 1시간\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 if (this.fetchPromise) {\n return this.fetchPromise;\n }\n\n this.fetchPromise = this.doFetch();\n\n try {\n await this.fetchPromise;\n } finally {\n this.fetchPromise = null;\n }\n }\n\n private async doFetch(): Promise<void> {\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 = Date.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":["instance","AbuseSDK","constructor","options","this","cache","adidList","lastFetchTime","fetchPromise","r2Url","cacheTTL","fetchData","now","Date","doFetch","response","fetch","ok","Error","status","statusText","adids","text","split","map","line","trim","filter","length","Set","check","adid","has","getList","refresh"],"mappings":"aAKA,IAAIA,EAA4B,WAgBnBC,EAQX,WAAAC,CAAYC,GALJC,KAAAC,MAA4B,KAC5BD,KAAAE,SAAqB,GACrBF,KAAAG,cAAwB,EACxBH,KAAAI,aAAqC,KAG3CJ,KAAKK,MAAQN,EAAQM,MACrBL,KAAKM,SAAWP,EAAQO,UAAY,IACtC,CAEQ,eAAMC,GACZ,MAAMC,EAAMC,KAAKD,MAEjB,KAAIR,KAAKC,OAASO,EAAMR,KAAKG,cAAgBH,KAAKM,UAAlD,CAIA,GAAIN,KAAKI,aACP,OAAOJ,KAAKI,aAGdJ,KAAKI,aAAeJ,KAAKU,UAEzB,UACQV,KAAKI,YACb,SACEJ,KAAKI,aAAe,IACtB,CAZA,CAaF,CAEQ,aAAMM,GACZ,MAAMC,QAAiBC,MAAMZ,KAAKK,OAElC,IAAKM,EAASE,GACZ,MAAM,IAAIC,MAAM,8BAA8BH,EAASI,UAAUJ,EAASK,cAG5E,MACMC,SADaN,EAASO,QAEzBC,MAAM,MACNC,IAAKC,GAASA,EAAKC,QACnBC,OAAQF,GAASA,EAAKG,OAAS,GAElCxB,KAAKE,SAAWe,EAChBjB,KAAKC,MAAQ,IAAIwB,IAAIR,GACrBjB,KAAKG,cAAgBM,KAAKD,KAC5B,CAEA,WAAMkB,CAAMC,GAEV,aADM3B,KAAKO,YACJP,KAAKC,MAAO2B,IAAID,EACzB,CAEA,aAAME,GAEJ,aADM7B,KAAKO,YACJP,KAAKE,QACd,CAEA,aAAM4B,GACJ9B,KAAKC,MAAQ,KACbD,KAAKE,SAAW,GAChBF,KAAKG,cAAgB,QACfH,KAAKO,WACb,oDAxEA,IAAKX,EACH,MAAM,IAAIkB,MAAM,mDAElB,OAAOlB,CACT,eAZM,SAAeG,GACfH,IAGJA,EAAW,IAAIC,EAASE,GAC1B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,14 +2,18 @@ export interface AbuseSDKOptions {
|
|
|
2
2
|
r2Url: string;
|
|
3
3
|
cacheTTL?: number;
|
|
4
4
|
}
|
|
5
|
+
export declare function init(options: AbuseSDKOptions): void;
|
|
6
|
+
export declare function getInstance(): AbuseSDK;
|
|
5
7
|
export declare class AbuseSDK {
|
|
6
8
|
private readonly r2Url;
|
|
7
9
|
private readonly cacheTTL;
|
|
8
10
|
private cache;
|
|
9
11
|
private adidList;
|
|
10
12
|
private lastFetchTime;
|
|
13
|
+
private fetchPromise;
|
|
11
14
|
constructor(options: AbuseSDKOptions);
|
|
12
15
|
private fetchData;
|
|
16
|
+
private doFetch;
|
|
13
17
|
check(adid: string): Promise<boolean>;
|
|
14
18
|
getList(): Promise<string[]>;
|
|
15
19
|
refresh(): Promise<void>;
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
let t=null;function i(i){t||(t=new e(i))}function s(){if(!t)throw new Error("AbuseSDK is not initialized. Call init() first.");return t}class e{constructor(t){this.cache=null,this.adidList=[],this.lastFetchTime=0,this.fetchPromise=null,this.r2Url=t.r2Url,this.cacheTTL=t.cacheTTL??36e5}async fetchData(){const t=Date.now();if(!(this.cache&&t-this.lastFetchTime<this.cacheTTL)){if(this.fetchPromise)return this.fetchPromise;this.fetchPromise=this.doFetch();try{await this.fetchPromise}finally{this.fetchPromise=null}}}async doFetch(){const t=await fetch(this.r2Url);if(!t.ok)throw new Error(`Failed to fetch blacklist: ${t.status} ${t.statusText}`);const i=(await t.text()).split("\n").map(t=>t.trim()).filter(t=>t.length>0);this.adidList=i,this.cache=new Set(i),this.lastFetchTime=Date.now()}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{e as AbuseSDK,s as getInstance,i as init};
|
|
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 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 ??
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["export interface AbuseSDKOptions {\n r2Url: string;\n cacheTTL?: number;\n}\n\nlet instance: AbuseSDK | null = null;\n\nexport function init(options: AbuseSDKOptions): void {\n if (instance) {\n return;\n }\n instance = new AbuseSDK(options);\n}\n\nexport function getInstance(): AbuseSDK {\n if (!instance) {\n throw new Error('AbuseSDK is not initialized. Call init() first.');\n }\n return instance;\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 private fetchPromise: Promise<void> | null = null;\n\n constructor(options: AbuseSDKOptions) {\n this.r2Url = options.r2Url;\n this.cacheTTL = options.cacheTTL ?? 60 * 60 * 1000; // 기본 1시간\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 if (this.fetchPromise) {\n return this.fetchPromise;\n }\n\n this.fetchPromise = this.doFetch();\n\n try {\n await this.fetchPromise;\n } finally {\n this.fetchPromise = null;\n }\n }\n\n private async doFetch(): Promise<void> {\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 = Date.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":["instance","init","options","AbuseSDK","getInstance","Error","constructor","this","cache","adidList","lastFetchTime","fetchPromise","r2Url","cacheTTL","fetchData","now","Date","doFetch","response","fetch","ok","status","statusText","adids","text","split","map","line","trim","filter","length","Set","check","adid","has","getList","refresh"],"mappings":"AAKA,IAAIA,EAA4B,KAE1B,SAAUC,EAAKC,GACfF,IAGJA,EAAW,IAAIG,EAASD,GAC1B,UAEgBE,IACd,IAAKJ,EACH,MAAM,IAAIK,MAAM,mDAElB,OAAOL,CACT,OAEaG,EAQX,WAAAG,CAAYJ,GALJK,KAAAC,MAA4B,KAC5BD,KAAAE,SAAqB,GACrBF,KAAAG,cAAwB,EACxBH,KAAAI,aAAqC,KAG3CJ,KAAKK,MAAQV,EAAQU,MACrBL,KAAKM,SAAWX,EAAQW,UAAY,IACtC,CAEQ,eAAMC,GACZ,MAAMC,EAAMC,KAAKD,MAEjB,KAAIR,KAAKC,OAASO,EAAMR,KAAKG,cAAgBH,KAAKM,UAAlD,CAIA,GAAIN,KAAKI,aACP,OAAOJ,KAAKI,aAGdJ,KAAKI,aAAeJ,KAAKU,UAEzB,UACQV,KAAKI,YACb,SACEJ,KAAKI,aAAe,IACtB,CAZA,CAaF,CAEQ,aAAMM,GACZ,MAAMC,QAAiBC,MAAMZ,KAAKK,OAElC,IAAKM,EAASE,GACZ,MAAM,IAAIf,MAAM,8BAA8Ba,EAASG,UAAUH,EAASI,cAG5E,MACMC,SADaL,EAASM,QAEzBC,MAAM,MACNC,IAAKC,GAASA,EAAKC,QACnBC,OAAQF,GAASA,EAAKG,OAAS,GAElCvB,KAAKE,SAAWc,EAChBhB,KAAKC,MAAQ,IAAIuB,IAAIR,GACrBhB,KAAKG,cAAgBM,KAAKD,KAC5B,CAEA,WAAMiB,CAAMC,GAEV,aADM1B,KAAKO,YACJP,KAAKC,MAAO0B,IAAID,EACzB,CAEA,aAAME,GAEJ,aADM5B,KAAKO,YACJP,KAAKE,QACd,CAEA,aAAM2B,GACJ7B,KAAKC,MAAQ,KACbD,KAAKE,SAAW,GAChBF,KAAKG,cAAgB,QACfH,KAAKO,WACb"}
|