linkedin-secret-sauce 0.12.1 → 0.12.2
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/README.md +50 -21
- package/dist/cosiall-client.d.ts +1 -1
- package/dist/cosiall-client.js +1 -1
- package/dist/enrichment/index.d.ts +1 -1
- package/dist/enrichment/index.js +11 -2
- package/dist/enrichment/matching.d.ts +16 -2
- package/dist/enrichment/matching.js +387 -65
- package/dist/enrichment/providers/bounceban.d.ts +82 -0
- package/dist/enrichment/providers/bounceban.js +447 -0
- package/dist/enrichment/providers/bouncer.d.ts +1 -1
- package/dist/enrichment/providers/bouncer.js +19 -21
- package/dist/enrichment/providers/construct.d.ts +1 -1
- package/dist/enrichment/providers/construct.js +22 -38
- package/dist/enrichment/providers/cosiall.d.ts +1 -1
- package/dist/enrichment/providers/cosiall.js +3 -4
- package/dist/enrichment/providers/dropcontact.d.ts +15 -9
- package/dist/enrichment/providers/dropcontact.js +188 -19
- package/dist/enrichment/providers/hunter.d.ts +8 -1
- package/dist/enrichment/providers/hunter.js +52 -28
- package/dist/enrichment/providers/index.d.ts +2 -0
- package/dist/enrichment/providers/index.js +10 -1
- package/dist/enrichment/providers/ldd.d.ts +1 -10
- package/dist/enrichment/providers/ldd.js +20 -97
- package/dist/enrichment/providers/smartprospect.js +28 -48
- package/dist/enrichment/providers/snovio.d.ts +1 -1
- package/dist/enrichment/providers/snovio.js +29 -31
- package/dist/enrichment/providers/trykitt.d.ts +63 -0
- package/dist/enrichment/providers/trykitt.js +210 -0
- package/dist/enrichment/types.d.ts +210 -7
- package/dist/enrichment/types.js +16 -8
- package/dist/enrichment/utils/candidate-parser.d.ts +107 -0
- package/dist/enrichment/utils/candidate-parser.js +173 -0
- package/dist/enrichment/utils/noop-provider.d.ts +39 -0
- package/dist/enrichment/utils/noop-provider.js +37 -0
- package/dist/enrichment/utils/rate-limiter.d.ts +103 -0
- package/dist/enrichment/utils/rate-limiter.js +204 -0
- package/dist/enrichment/utils/validation.d.ts +75 -3
- package/dist/enrichment/utils/validation.js +164 -11
- package/dist/linkedin-api.d.ts +40 -1
- package/dist/linkedin-api.js +160 -27
- package/dist/types.d.ts +50 -1
- package/dist/utils/lru-cache.d.ts +105 -0
- package/dist/utils/lru-cache.js +175 -0
- package/package.json +25 -26
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple LRU (Least Recently Used) Cache
|
|
3
|
+
*
|
|
4
|
+
* A memory-bounded cache that evicts the least recently used entries
|
|
5
|
+
* when the maximum size is exceeded. Prevents unbounded memory growth.
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - O(1) get and set operations
|
|
9
|
+
* - Automatic eviction of stale entries
|
|
10
|
+
* - Optional TTL support
|
|
11
|
+
* - Size limit enforcement
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Cache entry with data and timestamp
|
|
15
|
+
*/
|
|
16
|
+
export interface CacheEntry<T> {
|
|
17
|
+
data: T;
|
|
18
|
+
ts: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* LRU Cache implementation using Map's insertion order
|
|
22
|
+
*
|
|
23
|
+
* JavaScript Map maintains insertion order, so we can implement LRU
|
|
24
|
+
* by deleting and re-inserting on access (moving to end).
|
|
25
|
+
*/
|
|
26
|
+
export declare class LRUCache<T> {
|
|
27
|
+
private cache;
|
|
28
|
+
private readonly maxSize;
|
|
29
|
+
private readonly ttlMs;
|
|
30
|
+
/**
|
|
31
|
+
* Create a new LRU cache
|
|
32
|
+
*
|
|
33
|
+
* @param maxSize - Maximum number of entries to store (default: 1000)
|
|
34
|
+
* @param ttlMs - Optional TTL in milliseconds (default: null = no expiry)
|
|
35
|
+
*/
|
|
36
|
+
constructor(maxSize?: number, ttlMs?: number | null);
|
|
37
|
+
/**
|
|
38
|
+
* Get a value from the cache
|
|
39
|
+
*
|
|
40
|
+
* @param key - Cache key
|
|
41
|
+
* @param ttlOverride - Optional TTL override in milliseconds (for dynamic TTL from config)
|
|
42
|
+
* @returns The cached value or null if not found/expired
|
|
43
|
+
*/
|
|
44
|
+
get(key: string, ttlOverride?: number): T | null;
|
|
45
|
+
/**
|
|
46
|
+
* Set a value in the cache
|
|
47
|
+
*
|
|
48
|
+
* @param key - Cache key
|
|
49
|
+
* @param data - Value to cache
|
|
50
|
+
*/
|
|
51
|
+
set(key: string, data: T): void;
|
|
52
|
+
/**
|
|
53
|
+
* Delete a key from the cache
|
|
54
|
+
*
|
|
55
|
+
* @param key - Cache key to delete
|
|
56
|
+
* @returns true if the key existed
|
|
57
|
+
*/
|
|
58
|
+
delete(key: string): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Check if a key exists in the cache (without updating access time)
|
|
61
|
+
*
|
|
62
|
+
* @param key - Cache key
|
|
63
|
+
* @returns true if key exists and is not expired
|
|
64
|
+
*/
|
|
65
|
+
has(key: string): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Clear all entries from the cache
|
|
68
|
+
*/
|
|
69
|
+
clear(): void;
|
|
70
|
+
/**
|
|
71
|
+
* Get the current number of entries in the cache
|
|
72
|
+
*/
|
|
73
|
+
get size(): number;
|
|
74
|
+
/**
|
|
75
|
+
* Get all keys in the cache (for debugging/testing)
|
|
76
|
+
*/
|
|
77
|
+
keys(): IterableIterator<string>;
|
|
78
|
+
/**
|
|
79
|
+
* Prune expired entries (useful for periodic cleanup)
|
|
80
|
+
*
|
|
81
|
+
* @returns Number of entries removed
|
|
82
|
+
*/
|
|
83
|
+
prune(): number;
|
|
84
|
+
/**
|
|
85
|
+
* Get cache statistics
|
|
86
|
+
*/
|
|
87
|
+
stats(): {
|
|
88
|
+
size: number;
|
|
89
|
+
maxSize: number;
|
|
90
|
+
ttlMs: number | null;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Create a new LRU cache with the specified options
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* // Cache up to 500 profiles for 15 minutes
|
|
99
|
+
* const profileCache = createLRUCache<LinkedInProfile>(500, 15 * 60 * 1000);
|
|
100
|
+
*
|
|
101
|
+
* profileCache.set('johndoe', profile);
|
|
102
|
+
* const cached = profileCache.get('johndoe');
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
export declare function createLRUCache<T>(maxSize?: number, ttlMs?: number | null): LRUCache<T>;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Simple LRU (Least Recently Used) Cache
|
|
4
|
+
*
|
|
5
|
+
* A memory-bounded cache that evicts the least recently used entries
|
|
6
|
+
* when the maximum size is exceeded. Prevents unbounded memory growth.
|
|
7
|
+
*
|
|
8
|
+
* Features:
|
|
9
|
+
* - O(1) get and set operations
|
|
10
|
+
* - Automatic eviction of stale entries
|
|
11
|
+
* - Optional TTL support
|
|
12
|
+
* - Size limit enforcement
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.LRUCache = void 0;
|
|
16
|
+
exports.createLRUCache = createLRUCache;
|
|
17
|
+
/**
|
|
18
|
+
* LRU Cache implementation using Map's insertion order
|
|
19
|
+
*
|
|
20
|
+
* JavaScript Map maintains insertion order, so we can implement LRU
|
|
21
|
+
* by deleting and re-inserting on access (moving to end).
|
|
22
|
+
*/
|
|
23
|
+
class LRUCache {
|
|
24
|
+
cache;
|
|
25
|
+
maxSize;
|
|
26
|
+
ttlMs;
|
|
27
|
+
/**
|
|
28
|
+
* Create a new LRU cache
|
|
29
|
+
*
|
|
30
|
+
* @param maxSize - Maximum number of entries to store (default: 1000)
|
|
31
|
+
* @param ttlMs - Optional TTL in milliseconds (default: null = no expiry)
|
|
32
|
+
*/
|
|
33
|
+
constructor(maxSize = 1000, ttlMs = null) {
|
|
34
|
+
this.cache = new Map();
|
|
35
|
+
this.maxSize = maxSize;
|
|
36
|
+
this.ttlMs = ttlMs;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get a value from the cache
|
|
40
|
+
*
|
|
41
|
+
* @param key - Cache key
|
|
42
|
+
* @param ttlOverride - Optional TTL override in milliseconds (for dynamic TTL from config)
|
|
43
|
+
* @returns The cached value or null if not found/expired
|
|
44
|
+
*/
|
|
45
|
+
get(key, ttlOverride) {
|
|
46
|
+
const entry = this.cache.get(key);
|
|
47
|
+
if (!entry) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
// Check TTL expiration (use override if provided, otherwise instance TTL)
|
|
51
|
+
const effectiveTtl = ttlOverride ?? this.ttlMs;
|
|
52
|
+
if (effectiveTtl !== null && Date.now() - entry.ts > effectiveTtl) {
|
|
53
|
+
this.cache.delete(key);
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
// Move to end (most recently used) by delete + set
|
|
57
|
+
this.cache.delete(key);
|
|
58
|
+
this.cache.set(key, entry);
|
|
59
|
+
return entry.data;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Set a value in the cache
|
|
63
|
+
*
|
|
64
|
+
* @param key - Cache key
|
|
65
|
+
* @param data - Value to cache
|
|
66
|
+
*/
|
|
67
|
+
set(key, data) {
|
|
68
|
+
// If key exists, delete it first (will be re-added at end)
|
|
69
|
+
if (this.cache.has(key)) {
|
|
70
|
+
this.cache.delete(key);
|
|
71
|
+
}
|
|
72
|
+
// Evict oldest entries if at capacity
|
|
73
|
+
while (this.cache.size >= this.maxSize) {
|
|
74
|
+
const oldestKey = this.cache.keys().next().value;
|
|
75
|
+
if (oldestKey !== undefined) {
|
|
76
|
+
this.cache.delete(oldestKey);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Add new entry
|
|
83
|
+
this.cache.set(key, { data, ts: Date.now() });
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Delete a key from the cache
|
|
87
|
+
*
|
|
88
|
+
* @param key - Cache key to delete
|
|
89
|
+
* @returns true if the key existed
|
|
90
|
+
*/
|
|
91
|
+
delete(key) {
|
|
92
|
+
return this.cache.delete(key);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Check if a key exists in the cache (without updating access time)
|
|
96
|
+
*
|
|
97
|
+
* @param key - Cache key
|
|
98
|
+
* @returns true if key exists and is not expired
|
|
99
|
+
*/
|
|
100
|
+
has(key) {
|
|
101
|
+
const entry = this.cache.get(key);
|
|
102
|
+
if (!entry) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
// Check TTL expiration
|
|
106
|
+
if (this.ttlMs !== null && Date.now() - entry.ts > this.ttlMs) {
|
|
107
|
+
this.cache.delete(key);
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Clear all entries from the cache
|
|
114
|
+
*/
|
|
115
|
+
clear() {
|
|
116
|
+
this.cache.clear();
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Get the current number of entries in the cache
|
|
120
|
+
*/
|
|
121
|
+
get size() {
|
|
122
|
+
return this.cache.size;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Get all keys in the cache (for debugging/testing)
|
|
126
|
+
*/
|
|
127
|
+
keys() {
|
|
128
|
+
return this.cache.keys();
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Prune expired entries (useful for periodic cleanup)
|
|
132
|
+
*
|
|
133
|
+
* @returns Number of entries removed
|
|
134
|
+
*/
|
|
135
|
+
prune() {
|
|
136
|
+
if (this.ttlMs === null) {
|
|
137
|
+
return 0;
|
|
138
|
+
}
|
|
139
|
+
const now = Date.now();
|
|
140
|
+
let removed = 0;
|
|
141
|
+
for (const [key, entry] of this.cache) {
|
|
142
|
+
if (now - entry.ts > this.ttlMs) {
|
|
143
|
+
this.cache.delete(key);
|
|
144
|
+
removed++;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return removed;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Get cache statistics
|
|
151
|
+
*/
|
|
152
|
+
stats() {
|
|
153
|
+
return {
|
|
154
|
+
size: this.cache.size,
|
|
155
|
+
maxSize: this.maxSize,
|
|
156
|
+
ttlMs: this.ttlMs,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
exports.LRUCache = LRUCache;
|
|
161
|
+
/**
|
|
162
|
+
* Create a new LRU cache with the specified options
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```typescript
|
|
166
|
+
* // Cache up to 500 profiles for 15 minutes
|
|
167
|
+
* const profileCache = createLRUCache<LinkedInProfile>(500, 15 * 60 * 1000);
|
|
168
|
+
*
|
|
169
|
+
* profileCache.set('johndoe', profile);
|
|
170
|
+
* const cached = profileCache.get('johndoe');
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
function createLRUCache(maxSize = 1000, ttlMs = null) {
|
|
174
|
+
return new LRUCache(maxSize, ttlMs);
|
|
175
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "linkedin-secret-sauce",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.2",
|
|
4
4
|
"description": "Private LinkedIn Sales Navigator client with automatic cookie management",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -10,30 +10,6 @@
|
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"registry": "https://registry.npmjs.org/"
|
|
12
12
|
},
|
|
13
|
-
"scripts": {
|
|
14
|
-
"dev:playground": "pnpm -C apps/playground dev",
|
|
15
|
-
"search": "node scripts/rg-fast.mjs",
|
|
16
|
-
"rg:fast": "node scripts/rg-fast.mjs",
|
|
17
|
-
"build": "tsc -p tsconfig.json",
|
|
18
|
-
"typecheck": "tsc --noEmit",
|
|
19
|
-
"typecheck:playground": "pnpm -C apps/playground typecheck",
|
|
20
|
-
"typecheck:all": "pnpm typecheck && pnpm typecheck:playground",
|
|
21
|
-
"lint": "eslint \"src/**/*.ts\" --max-warnings=0",
|
|
22
|
-
"lint:playground": "eslint \"apps/playground/src/**/*.{ts,tsx}\" \"apps/playground/server/**/*.ts\" --max-warnings=0",
|
|
23
|
-
"lint:all": "eslint \"src/**/*.ts\" \"apps/playground/src/**/*.{ts,tsx}\" \"apps/playground/server/**/*.ts\" --max-warnings=0",
|
|
24
|
-
"lint:fix": "eslint \"src/**/*.ts\" \"apps/playground/src/**/*.{ts,tsx}\" \"apps/playground/server/**/*.ts\" --fix",
|
|
25
|
-
"check": "pnpm typecheck:all && pnpm lint:all",
|
|
26
|
-
"dev": "pnpm dev:playground",
|
|
27
|
-
"dev:watch": "tsc -w -p tsconfig.json",
|
|
28
|
-
"test": "vitest run",
|
|
29
|
-
"docs": "typedoc",
|
|
30
|
-
"docs:netlify": "rm -rf docs/api && typedoc && echo 'Build complete'",
|
|
31
|
-
"docs:watch": "typedoc --watch",
|
|
32
|
-
"prepublishOnly": "npm run build",
|
|
33
|
-
"release:patch": "npm version patch && git push --follow-tags",
|
|
34
|
-
"release:minor": "npm version minor && git push --follow-tags",
|
|
35
|
-
"release:major": "npm version major && git push --follow-tags"
|
|
36
|
-
},
|
|
37
13
|
"keywords": [
|
|
38
14
|
"linkedin",
|
|
39
15
|
"sales-navigator",
|
|
@@ -66,5 +42,28 @@
|
|
|
66
42
|
"typedoc-plugin-markdown": "^4.9.0",
|
|
67
43
|
"typescript": "^5.9.3",
|
|
68
44
|
"vitest": "^1.6.0"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"dev:playground": "pnpm -C apps/playground dev",
|
|
48
|
+
"search": "node scripts/rg-fast.mjs",
|
|
49
|
+
"rg:fast": "node scripts/rg-fast.mjs",
|
|
50
|
+
"build": "tsc -p tsconfig.json",
|
|
51
|
+
"typecheck": "tsc --noEmit",
|
|
52
|
+
"typecheck:playground": "pnpm -C apps/playground typecheck",
|
|
53
|
+
"typecheck:all": "pnpm typecheck && pnpm typecheck:playground",
|
|
54
|
+
"lint": "eslint \"src/**/*.ts\" --max-warnings=0",
|
|
55
|
+
"lint:playground": "eslint \"apps/playground/src/**/*.{ts,tsx}\" \"apps/playground/server/**/*.ts\" --max-warnings=0",
|
|
56
|
+
"lint:all": "eslint \"src/**/*.ts\" \"apps/playground/src/**/*.{ts,tsx}\" \"apps/playground/server/**/*.ts\" --max-warnings=0",
|
|
57
|
+
"lint:fix": "eslint \"src/**/*.ts\" \"apps/playground/src/**/*.{ts,tsx}\" \"apps/playground/server/**/*.ts\" --fix",
|
|
58
|
+
"check": "pnpm typecheck:all && pnpm lint:all",
|
|
59
|
+
"dev": "pnpm dev:playground",
|
|
60
|
+
"dev:watch": "tsc -w -p tsconfig.json",
|
|
61
|
+
"test": "vitest run",
|
|
62
|
+
"docs": "typedoc",
|
|
63
|
+
"docs:netlify": "rm -rf docs/api && typedoc && echo 'Build complete'",
|
|
64
|
+
"docs:watch": "typedoc --watch",
|
|
65
|
+
"release:patch": "npm version patch && git push --follow-tags",
|
|
66
|
+
"release:minor": "npm version minor && git push --follow-tags",
|
|
67
|
+
"release:major": "npm version major && git push --follow-tags"
|
|
69
68
|
}
|
|
70
|
-
}
|
|
69
|
+
}
|