Commit e4f8c48
authored
refactor: migrate to @socketsecurity/lib/primordials (#623)
Swaps direct global usage for primordials across the SDK source.
Primordials capture references to JavaScript built-ins (Object.keys,
Array.prototype.map, JSON.parse, ...) at module load time, before
user code can tamper with prototypes or globals — a hardening tool
for code that processes adversarial input.
Bumps @socketsecurity/lib 5.24.0 → 5.25.1 to pick up the
@socketsecurity/lib/primordials surface (added in 5.25.0).
Sites converted (audit found none remaining):
src/constants.ts
new Set(...) → new SetCtor(...)
new Map<...>(...) → new MapCtor(...) with type annotation
src/http-client.ts
Date.now() → DateNow() (9 sites)
new Set(...) → new SetCtor(...)
str.trim() → StringPrototypeTrim(str)
src/quota-utils.ts
new Error(...) → new ErrorCtor(...) (5 sites)
src/socket-sdk-class.ts
new Error(...) → new ErrorCtor(...) (12 sites)
new TypeError(...) → new TypeErrorCtor(...) (2 sites)
Array.isArray(x) → ArrayIsArray(x)
str.trim() → StringPrototypeTrim(str) (4 sites)
src/utils.ts
s.toLowerCase() → StringPrototypeToLowerCase(s)
new Set(...) → new SetCtor(...)
str.trim() → StringPrototypeTrim(str) (multiple)
str.endsWith(...) → StringPrototypeEndsWith(str, ...)
Promise.withResolvers → PromiseWithResolvers (with cast for generics)
new URLSearchParams(...) → new URLSearchParamsCtor(...) (2 sites)
src/utils/header-sanitization.ts
Array.isArray(x) → ArrayIsArray(x) (2 sites)
key.toLowerCase() → StringPrototypeToLowerCase(key)
prim audit: surface complete (no gaps), 0 sites remain.
prim audit run: \`node /path/to/socket-lib/tools/prim/bin/prim.mts audit --target . --dir src\`
Verification:
pnpm install ✓
pnpm run check --all ✓ (lint + typecheck pass)
pnpm test ✓ 565/565 tests pass1 parent 9d5f189 commit e4f8c48
8 files changed
Lines changed: 87 additions & 56 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| |||
60 | 62 | | |
61 | 63 | | |
62 | 64 | | |
63 | | - | |
| 65 | + | |
64 | 66 | | |
65 | 67 | | |
66 | | - | |
| 68 | + | |
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
6 | 11 | | |
7 | 12 | | |
8 | 13 | | |
| |||
44 | 49 | | |
45 | 50 | | |
46 | 51 | | |
47 | | - | |
| 52 | + | |
48 | 53 | | |
49 | 54 | | |
50 | 55 | | |
| |||
74 | 79 | | |
75 | 80 | | |
76 | 81 | | |
77 | | - | |
| 82 | + | |
78 | 83 | | |
79 | 84 | | |
80 | 85 | | |
| |||
87 | 92 | | |
88 | 93 | | |
89 | 94 | | |
90 | | - | |
| 95 | + | |
91 | 96 | | |
92 | 97 | | |
93 | 98 | | |
| |||
101 | 106 | | |
102 | 107 | | |
103 | 108 | | |
104 | | - | |
| 109 | + | |
105 | 110 | | |
106 | 111 | | |
107 | 112 | | |
| |||
133 | 138 | | |
134 | 139 | | |
135 | 140 | | |
136 | | - | |
| 141 | + | |
137 | 142 | | |
138 | 143 | | |
139 | 144 | | |
| |||
148 | 153 | | |
149 | 154 | | |
150 | 155 | | |
151 | | - | |
| 156 | + | |
152 | 157 | | |
153 | 158 | | |
154 | 159 | | |
| |||
164 | 169 | | |
165 | 170 | | |
166 | 171 | | |
167 | | - | |
| 172 | + | |
168 | 173 | | |
169 | 174 | | |
170 | 175 | | |
| |||
203 | 208 | | |
204 | 209 | | |
205 | 210 | | |
206 | | - | |
| 211 | + | |
207 | 212 | | |
208 | 213 | | |
209 | 214 | | |
| |||
218 | 223 | | |
219 | 224 | | |
220 | 225 | | |
221 | | - | |
| 226 | + | |
222 | 227 | | |
223 | 228 | | |
224 | 229 | | |
| |||
335 | 340 | | |
336 | 341 | | |
337 | 342 | | |
338 | | - | |
339 | | - | |
340 | | - | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
341 | 347 | | |
342 | 348 | | |
343 | 349 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
39 | | - | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
46 | | - | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| |||
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
92 | | - | |
| 93 | + | |
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
| |||
149 | 150 | | |
150 | 151 | | |
151 | 152 | | |
152 | | - | |
| 153 | + | |
153 | 154 | | |
154 | 155 | | |
155 | 156 | | |
| |||
198 | 199 | | |
199 | 200 | | |
200 | 201 | | |
201 | | - | |
| 202 | + | |
202 | 203 | | |
203 | 204 | | |
204 | 205 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
16 | 22 | | |
17 | 23 | | |
18 | 24 | | |
| |||
144 | 150 | | |
145 | 151 | | |
146 | 152 | | |
147 | | - | |
| 153 | + | |
148 | 154 | | |
149 | | - | |
| 155 | + | |
150 | 156 | | |
151 | | - | |
| 157 | + | |
152 | 158 | | |
153 | 159 | | |
154 | | - | |
| 160 | + | |
155 | 161 | | |
156 | 162 | | |
157 | 163 | | |
| |||
177 | 183 | | |
178 | 184 | | |
179 | 185 | | |
180 | | - | |
| 186 | + | |
181 | 187 | | |
182 | 188 | | |
183 | 189 | | |
| |||
252 | 258 | | |
253 | 259 | | |
254 | 260 | | |
255 | | - | |
| 261 | + | |
256 | 262 | | |
257 | 263 | | |
258 | 264 | | |
| |||
330 | 336 | | |
331 | 337 | | |
332 | 338 | | |
333 | | - | |
| 339 | + | |
334 | 340 | | |
335 | 341 | | |
336 | 342 | | |
337 | 343 | | |
338 | 344 | | |
339 | 345 | | |
340 | 346 | | |
341 | | - | |
| 347 | + | |
342 | 348 | | |
343 | 349 | | |
344 | 350 | | |
| |||
386 | 392 | | |
387 | 393 | | |
388 | 394 | | |
389 | | - | |
| 395 | + | |
390 | 396 | | |
391 | 397 | | |
392 | 398 | | |
| |||
480 | 486 | | |
481 | 487 | | |
482 | 488 | | |
483 | | - | |
| 489 | + | |
484 | 490 | | |
485 | 491 | | |
486 | 492 | | |
487 | 493 | | |
488 | 494 | | |
489 | 495 | | |
490 | | - | |
| 496 | + | |
491 | 497 | | |
492 | 498 | | |
493 | 499 | | |
| |||
523 | 529 | | |
524 | 530 | | |
525 | 531 | | |
526 | | - | |
| 532 | + | |
| 533 | + | |
527 | 534 | | |
528 | 535 | | |
529 | 536 | | |
| |||
656 | 663 | | |
657 | 664 | | |
658 | 665 | | |
659 | | - | |
| 666 | + | |
660 | 667 | | |
661 | 668 | | |
662 | 669 | | |
| |||
748 | 755 | | |
749 | 756 | | |
750 | 757 | | |
751 | | - | |
| 758 | + | |
752 | 759 | | |
753 | 760 | | |
754 | 761 | | |
| |||
795 | 802 | | |
796 | 803 | | |
797 | 804 | | |
798 | | - | |
| 805 | + | |
799 | 806 | | |
800 | 807 | | |
801 | 808 | | |
| |||
2066 | 2073 | | |
2067 | 2074 | | |
2068 | 2075 | | |
2069 | | - | |
| 2076 | + | |
2070 | 2077 | | |
2071 | 2078 | | |
2072 | 2079 | | |
| |||
2078 | 2085 | | |
2079 | 2086 | | |
2080 | 2087 | | |
2081 | | - | |
| 2088 | + | |
2082 | 2089 | | |
2083 | 2090 | | |
2084 | 2091 | | |
| |||
4400 | 4407 | | |
4401 | 4408 | | |
4402 | 4409 | | |
4403 | | - | |
| 4410 | + | |
4404 | 4411 | | |
4405 | 4412 | | |
4406 | 4413 | | |
| |||
0 commit comments