vigor-roblox 1.0.1 → 1.0.3

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.d.ts CHANGED
@@ -117,6 +117,11 @@ interface RobloxThumbnailTarget {
117
117
  format?: string;
118
118
  isCircular?: boolean;
119
119
  }
120
+ interface RobloxThumbnailRaw extends RobloxThumbnailTarget {
121
+ imageUrl: string | null;
122
+ state: string;
123
+ version: string;
124
+ }
120
125
  interface RobloxThumbnail extends RobloxThumbnailTarget {
121
126
  url: string | null;
122
127
  state: string;
@@ -178,6 +183,15 @@ interface RobloxServerLocation {
178
183
  isp: string;
179
184
  timezone: string;
180
185
  }
186
+ interface RobloxFriendEntry {
187
+ id: RobloxUserId;
188
+ name: RobloxUserName;
189
+ displayName: RobloxDisplayName;
190
+ hasVerifiedBadge?: boolean;
191
+ isOnline?: boolean;
192
+ isDeleted?: boolean;
193
+ friendFrom?: string | null;
194
+ }
181
195
  interface CreateRobloxApiOptions {
182
196
  cache: RobloxApiCache;
183
197
  cookies: RobloxCookie[];
@@ -227,13 +241,18 @@ interface RobloxApi {
227
241
  placeId: RobloxPlaceId;
228
242
  jobIds: RobloxJobId[];
229
243
  }) => Promise<RobloxServerLocation[]>;
244
+ friends: (userId: RobloxUserId) => Promise<RobloxFriendEntry[]>;
245
+ sendFriendRequest: (targetUserId: RobloxUserId) => Promise<void>;
246
+ unfriend: (targetUserId: RobloxUserId) => Promise<void>;
230
247
  _internal: {
231
248
  gamejoinApi: VigorFetchInstance;
232
249
  gamesApi: VigorFetchInstance;
233
250
  apisRoblox: VigorFetchInstance;
251
+ friendsApi: VigorFetchInstance;
252
+ presenceApi: VigorFetchInstance;
234
253
  };
235
254
  }
236
255
  declare function createRobloxApi({ cache, cookies: cookiesList, ipgeolocationKey, }: CreateRobloxApiOptions): RobloxApi;
237
256
 
238
257
  export { RobloxAuthError, RobloxRateLimitError, RobloxRequestError, createRobloxApi };
239
- export type { CreateRobloxApiOptions, RobloxApi, RobloxApiCache, RobloxAssetId, RobloxAuthenticatedUser, RobloxCookie, RobloxDisplayName, RobloxJobId, RobloxPlaceId, RobloxPlaceInfo, RobloxPresenceEntry, RobloxServerEntry, RobloxServerEntryWithLocation, RobloxServerLocation, RobloxServersResult, RobloxThumbnail, RobloxThumbnailTarget, RobloxUniverseId, RobloxUser, RobloxUserAgeBracket, RobloxUserBirthdate, RobloxUserCountryCode, RobloxUserDescription, RobloxUserGender, RobloxUserId, RobloxUserName, RobloxUserRoles, RobloxUserSimple, VigorFetchInstance };
258
+ export type { CreateRobloxApiOptions, RobloxApi, RobloxApiCache, RobloxAssetId, RobloxAuthenticatedUser, RobloxCookie, RobloxDisplayName, RobloxFriendEntry, RobloxJobId, RobloxPlaceId, RobloxPlaceInfo, RobloxPresenceEntry, RobloxServerEntry, RobloxServerEntryWithLocation, RobloxServerLocation, RobloxServersResult, RobloxThumbnail, RobloxThumbnailRaw, RobloxThumbnailTarget, RobloxUniverseId, RobloxUser, RobloxUserAgeBracket, RobloxUserBirthdate, RobloxUserCountryCode, RobloxUserDescription, RobloxUserGender, RobloxUserId, RobloxUserName, RobloxUserRoles, RobloxUserSimple, VigorFetchInstance };
package/dist/index.js CHANGED
@@ -1904,6 +1904,14 @@ function createRobloxApi({ cache, cookies: cookiesList, ipgeolocationKey, }) {
1904
1904
  .retryConfig(c => c
1905
1905
  .settings(s => s.attempt(4))
1906
1906
  .algorithms(a => a.backoff().initial(500).multiplier(2)));
1907
+ // friends.roblox.com — used for friend list lookups, sending friend
1908
+ // requests, and unfriending. Same cookie + WinInet headers as usersApi.
1909
+ const friendsApi = vigor.fetch('https://friends.roblox.com/v1')
1910
+ .interceptors(cookieInterceptor)
1911
+ .interceptors(winInetInterceptor)
1912
+ .retryConfig(c => c
1913
+ .settings(s => s.attempt(5))
1914
+ .algorithms(a => a.backoff().initial(500).multiplier(2)));
1907
1915
  async function withCache(opts) {
1908
1916
  const { type, keys, ttlMs, getKey, fetchMissing, fallback } = opts;
1909
1917
  const cached = await cache.select(type, keys);
@@ -2062,7 +2070,7 @@ function createRobloxApi({ cache, cookies: cookiesList, ipgeolocationKey, }) {
2062
2070
  api.setResult(ctx.result.flat());
2063
2071
  }))
2064
2072
  .request();
2065
- return results.map(t => ({ ...t, url: t.state === 'Completed' ? t.url : null }));
2073
+ return results.map(t => ({ ...t, url: t.state === 'Completed' ? t.imageUrl : null }));
2066
2074
  }
2067
2075
  catch (cause) {
2068
2076
  throw wrapVigorError(cause);
@@ -2092,7 +2100,7 @@ function createRobloxApi({ cache, cookies: cookiesList, ipgeolocationKey, }) {
2092
2100
  return results.map(item => {
2093
2101
  const original = batchMap.get(item.requestId) ?? {};
2094
2102
  const { requestId: _rid, ...rest } = item;
2095
- return { ...original, ...rest, url: rest.state === 'Completed' ? rest.url : null };
2103
+ return { ...original, ...rest, url: rest.state === 'Completed' ? rest.imageUrl : null };
2096
2104
  });
2097
2105
  }
2098
2106
  catch (cause) {
@@ -2398,6 +2406,42 @@ function createRobloxApi({ cache, cookies: cookiesList, ipgeolocationKey, }) {
2398
2406
  ]);
2399
2407
  return jobIds.flatMap(id => { const loc = resultMap.get(id); return loc ? [loc] : []; });
2400
2408
  }
2409
+ // ----------------------------------------------------------------
2410
+ // Friends
2411
+ // ----------------------------------------------------------------
2412
+ async function friends(userId) {
2413
+ try {
2414
+ return await friendsApi
2415
+ .path('users', userId, 'friends')
2416
+ .interceptors(dataInterceptor)
2417
+ .request();
2418
+ }
2419
+ catch (cause) {
2420
+ throw wrapVigorError(cause);
2421
+ }
2422
+ }
2423
+ async function sendFriendRequest(targetUserId) {
2424
+ try {
2425
+ await friendsApi
2426
+ .path('users', targetUserId, 'request-friendship')
2427
+ .body({})
2428
+ .request();
2429
+ }
2430
+ catch (cause) {
2431
+ throw wrapVigorError(cause);
2432
+ }
2433
+ }
2434
+ async function unfriend(targetUserId) {
2435
+ try {
2436
+ await friendsApi
2437
+ .path('users', targetUserId, 'unfriend')
2438
+ .body({})
2439
+ .request();
2440
+ }
2441
+ catch (cause) {
2442
+ throw wrapVigorError(cause);
2443
+ }
2444
+ }
2401
2445
  return {
2402
2446
  authenticated,
2403
2447
  usersSimple,
@@ -2413,7 +2457,10 @@ function createRobloxApi({ cache, cookies: cookiesList, ipgeolocationKey, }) {
2413
2457
  usersWithImg,
2414
2458
  track,
2415
2459
  serversRegion,
2416
- _internal: { gamejoinApi, gamesApi, apisRoblox },
2460
+ friends,
2461
+ sendFriendRequest,
2462
+ unfriend,
2463
+ _internal: { gamejoinApi, gamesApi, apisRoblox, friendsApi, presenceApi },
2417
2464
  };
2418
2465
  }
2419
2466
 
package/dist/index.mjs CHANGED
@@ -1902,6 +1902,14 @@ function createRobloxApi({ cache, cookies: cookiesList, ipgeolocationKey, }) {
1902
1902
  .retryConfig(c => c
1903
1903
  .settings(s => s.attempt(4))
1904
1904
  .algorithms(a => a.backoff().initial(500).multiplier(2)));
1905
+ // friends.roblox.com — used for friend list lookups, sending friend
1906
+ // requests, and unfriending. Same cookie + WinInet headers as usersApi.
1907
+ const friendsApi = vigor.fetch('https://friends.roblox.com/v1')
1908
+ .interceptors(cookieInterceptor)
1909
+ .interceptors(winInetInterceptor)
1910
+ .retryConfig(c => c
1911
+ .settings(s => s.attempt(5))
1912
+ .algorithms(a => a.backoff().initial(500).multiplier(2)));
1905
1913
  async function withCache(opts) {
1906
1914
  const { type, keys, ttlMs, getKey, fetchMissing, fallback } = opts;
1907
1915
  const cached = await cache.select(type, keys);
@@ -2060,7 +2068,7 @@ function createRobloxApi({ cache, cookies: cookiesList, ipgeolocationKey, }) {
2060
2068
  api.setResult(ctx.result.flat());
2061
2069
  }))
2062
2070
  .request();
2063
- return results.map(t => ({ ...t, url: t.state === 'Completed' ? t.url : null }));
2071
+ return results.map(t => ({ ...t, url: t.state === 'Completed' ? t.imageUrl : null }));
2064
2072
  }
2065
2073
  catch (cause) {
2066
2074
  throw wrapVigorError(cause);
@@ -2090,7 +2098,7 @@ function createRobloxApi({ cache, cookies: cookiesList, ipgeolocationKey, }) {
2090
2098
  return results.map(item => {
2091
2099
  const original = batchMap.get(item.requestId) ?? {};
2092
2100
  const { requestId: _rid, ...rest } = item;
2093
- return { ...original, ...rest, url: rest.state === 'Completed' ? rest.url : null };
2101
+ return { ...original, ...rest, url: rest.state === 'Completed' ? rest.imageUrl : null };
2094
2102
  });
2095
2103
  }
2096
2104
  catch (cause) {
@@ -2396,6 +2404,42 @@ function createRobloxApi({ cache, cookies: cookiesList, ipgeolocationKey, }) {
2396
2404
  ]);
2397
2405
  return jobIds.flatMap(id => { const loc = resultMap.get(id); return loc ? [loc] : []; });
2398
2406
  }
2407
+ // ----------------------------------------------------------------
2408
+ // Friends
2409
+ // ----------------------------------------------------------------
2410
+ async function friends(userId) {
2411
+ try {
2412
+ return await friendsApi
2413
+ .path('users', userId, 'friends')
2414
+ .interceptors(dataInterceptor)
2415
+ .request();
2416
+ }
2417
+ catch (cause) {
2418
+ throw wrapVigorError(cause);
2419
+ }
2420
+ }
2421
+ async function sendFriendRequest(targetUserId) {
2422
+ try {
2423
+ await friendsApi
2424
+ .path('users', targetUserId, 'request-friendship')
2425
+ .body({})
2426
+ .request();
2427
+ }
2428
+ catch (cause) {
2429
+ throw wrapVigorError(cause);
2430
+ }
2431
+ }
2432
+ async function unfriend(targetUserId) {
2433
+ try {
2434
+ await friendsApi
2435
+ .path('users', targetUserId, 'unfriend')
2436
+ .body({})
2437
+ .request();
2438
+ }
2439
+ catch (cause) {
2440
+ throw wrapVigorError(cause);
2441
+ }
2442
+ }
2399
2443
  return {
2400
2444
  authenticated,
2401
2445
  usersSimple,
@@ -2411,7 +2455,10 @@ function createRobloxApi({ cache, cookies: cookiesList, ipgeolocationKey, }) {
2411
2455
  usersWithImg,
2412
2456
  track,
2413
2457
  serversRegion,
2414
- _internal: { gamejoinApi, gamesApi, apisRoblox },
2458
+ friends,
2459
+ sendFriendRequest,
2460
+ unfriend,
2461
+ _internal: { gamejoinApi, gamesApi, apisRoblox, friendsApi, presenceApi },
2415
2462
  };
2416
2463
  }
2417
2464
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vigor-roblox",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",