rozod 5.0.0 → 6.0.1

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.
Files changed (87) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +160 -17
  3. package/lib/endpoints/accountinformationv1.d.ts +2 -8
  4. package/lib/endpoints/accountinformationv1.js +2 -8
  5. package/lib/endpoints/accountsettingsv1.d.ts +1 -317
  6. package/lib/endpoints/accountsettingsv1.js +2 -318
  7. package/lib/endpoints/adconfigurationv2.d.ts +1 -1
  8. package/lib/endpoints/adconfigurationv2.js +1 -1
  9. package/lib/endpoints/assetdeliveryv1.d.ts +15 -10
  10. package/lib/endpoints/assetdeliveryv1.js +16 -11
  11. package/lib/endpoints/assetdeliveryv2.d.ts +13 -8
  12. package/lib/endpoints/assetdeliveryv2.js +14 -9
  13. package/lib/endpoints/authv1.d.ts +229 -143
  14. package/lib/endpoints/authv1.js +229 -143
  15. package/lib/endpoints/authv2.d.ts +134 -111
  16. package/lib/endpoints/authv2.js +135 -112
  17. package/lib/endpoints/authv3.d.ts +44 -0
  18. package/lib/endpoints/authv3.js +45 -1
  19. package/lib/endpoints/avatarv1.d.ts +1 -1
  20. package/lib/endpoints/avatarv1.js +1 -1
  21. package/lib/endpoints/avatarv2.d.ts +17 -16
  22. package/lib/endpoints/avatarv2.js +17 -16
  23. package/lib/endpoints/avatarv3.d.ts +12 -18
  24. package/lib/endpoints/avatarv3.js +12 -18
  25. package/lib/endpoints/badgesv1.d.ts +54 -1
  26. package/lib/endpoints/badgesv1.js +55 -2
  27. package/lib/endpoints/catalogv1.d.ts +256 -44
  28. package/lib/endpoints/catalogv1.js +249 -39
  29. package/lib/endpoints/catalogv2.d.ts +14 -7
  30. package/lib/endpoints/catalogv2.js +14 -7
  31. package/lib/endpoints/clientsettingsv2.d.ts +53 -1
  32. package/lib/endpoints/clientsettingsv2.js +54 -2
  33. package/lib/endpoints/developv2.d.ts +5 -1
  34. package/lib/endpoints/developv2.js +5 -1
  35. package/lib/endpoints/economycreatorstatsv1.d.ts +1 -1
  36. package/lib/endpoints/economycreatorstatsv1.js +1 -1
  37. package/lib/endpoints/engagementpayoutsv1.d.ts +1 -1
  38. package/lib/endpoints/engagementpayoutsv1.js +1 -1
  39. package/lib/endpoints/followingsv2.d.ts +1 -1
  40. package/lib/endpoints/followingsv2.js +1 -1
  41. package/lib/endpoints/friendsv1.d.ts +250 -1
  42. package/lib/endpoints/friendsv1.js +251 -2
  43. package/lib/endpoints/gameinternationalizationv1.d.ts +30 -43
  44. package/lib/endpoints/gameinternationalizationv1.js +32 -45
  45. package/lib/endpoints/gamejoinv1.d.ts +11 -1
  46. package/lib/endpoints/gamejoinv1.js +11 -1
  47. package/lib/endpoints/gamesv1.d.ts +16 -4
  48. package/lib/endpoints/gamesv1.js +16 -4
  49. package/lib/endpoints/gamesv2.d.ts +23 -3
  50. package/lib/endpoints/gamesv2.js +23 -3
  51. package/lib/endpoints/groupsv1.d.ts +42 -7
  52. package/lib/endpoints/groupsv1.js +42 -7
  53. package/lib/endpoints/groupsv2.d.ts +8 -1
  54. package/lib/endpoints/groupsv2.js +8 -1
  55. package/lib/endpoints/inventoryv1.d.ts +18 -155
  56. package/lib/endpoints/inventoryv1.js +19 -156
  57. package/lib/endpoints/inventoryv2.d.ts +4 -0
  58. package/lib/endpoints/inventoryv2.js +4 -0
  59. package/lib/endpoints/localizationtablesv1.d.ts +1 -0
  60. package/lib/endpoints/localizationtablesv1.js +1 -0
  61. package/lib/endpoints/notificationsv2.d.ts +2 -506
  62. package/lib/endpoints/notificationsv2.js +3 -505
  63. package/lib/endpoints/presencev1.d.ts +1 -1
  64. package/lib/endpoints/presencev1.js +1 -1
  65. package/lib/endpoints/thumbnailsv1.d.ts +11 -0
  66. package/lib/endpoints/thumbnailsv1.js +11 -0
  67. package/lib/endpoints/tradesv1.d.ts +29 -150
  68. package/lib/endpoints/tradesv1.js +30 -151
  69. package/lib/endpoints/tradesv2.d.ts +200 -0
  70. package/lib/endpoints/tradesv2.js +199 -0
  71. package/lib/endpoints/twostepverificationv1.d.ts +47 -13
  72. package/lib/endpoints/twostepverificationv1.js +48 -14
  73. package/lib/index.d.ts +38 -11
  74. package/lib/index.js +100 -38
  75. package/lib/opencloud/index.js +17 -7
  76. package/lib/opencloud/v1/assets.d.ts +89 -89
  77. package/lib/opencloud/v1/assets.js +80 -80
  78. package/lib/opencloud/v1/datastores-ordered.d.ts +23 -23
  79. package/lib/opencloud/v1/datastores-ordered.js +15 -15
  80. package/lib/opencloud/v1/datastores.d.ts +26 -22
  81. package/lib/opencloud/v1/datastores.js +19 -15
  82. package/lib/opencloud/v1/universes.d.ts +1 -1
  83. package/lib/opencloud/v2/cloud.d.ts +1099 -1086
  84. package/lib/opencloud/v2/cloud.js +819 -753
  85. package/package.json +64 -61
  86. package/lib/endpoints/translationsv1.d.ts +0 -182
  87. package/lib/endpoints/translationsv1.js +0 -183
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  ISC License
2
2
 
3
- Copyright (c) 2023 Alex Op
3
+ Copyright (c) 2025 Alrovi ApS
4
4
 
5
5
  Permission to use, copy, modify, and/or distribute this software for any
6
6
  purpose with or without fee is hereby granted, provided that the above
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
  <h4 align="center">Type-safe Roblox API and OpenCloud client for TypeScript</h4>
7
7
 
8
8
  <p align="center">
9
- <a href="https://www.npmjs.com/package/rozod"><img alt="npm bundle size" src="https://img.shields.io/bundlephobia/minzip/rozod?style=for-the-badge"></a>
9
+ <a href="https://www.npmjs.com/package/rozod"><img alt="npm bundle size" src="https://img.shields.io/bundlephobia/min/rozod?style=for-the-badge"></a>
10
10
  <a href="https://www.npmjs.com/package/rozod"><img alt="npm" src="https://img.shields.io/npm/v/rozod?style=for-the-badge"></a>
11
11
  <a href="https://www.npmjs.com/package/rozod"><img alt="npm" src="https://img.shields.io/npm/dt/rozod?style=for-the-badge"></a>
12
12
  </p>
@@ -24,16 +24,22 @@
24
24
  ---
25
25
 
26
26
  ## About
27
- `RoZod` makes working with Roblox APIs simple and type-safe in TypeScript. With just a few lines of code, you can fetch data from both traditional Roblox web APIs and the newer OpenCloud APIs with full type safety.
27
+
28
+ `RoZod` makes working with Roblox APIs simple and type-safe in TypeScript. With **650+ classic Roblox web API endpoints** and **95+ OpenCloud endpoints** (all code-generated from official Roblox documentation), you get comprehensive coverage of virtually every available Roblox API with full type safety.
29
+
30
+ Perfect for everything from small one-time NodeJS/Bun/Deno scripts to large-scale production applications. RoZod powers [RoGold](https://rogold.live), a browser extension with **800,000+ active users**, handling millions of API requests daily across both frontend extensions and backend workflows.
28
31
 
29
32
  ## Features
30
33
 
31
34
  - ✨ **Simple Interface** - Easy to understand API with minimal boilerplate
32
35
  - 🔒 **Type Safety** - Complete TypeScript type safety for requests and responses
33
- - 📚 **Comprehensive API Coverage** - Access to both traditional Roblox web APIs and OpenCloud APIs
36
+ - 📚 **750+ Total Endpoints** - 650+ classic web APIs + 95+ OpenCloud APIs, all code-generated from official docs
37
+ - 🚀 **Production Ready** - Battle-tested in applications serving 800,000+ users
34
38
  - 🔄 **Pagination Helpers** - Easy tools for handling paginated responses
35
39
  - 🔁 **Batch Processing** - Split large requests automatically to avoid API limits
40
+ - 🌐 **Universal Runtime Support** - Works seamlessly in NodeJS, Bun, Deno, and browsers
36
41
  - 🔍 **Custom Endpoints** - Define your own endpoints with full type safety
42
+ - 🧩 **Smart Error Handling** - Choose between safe unions or throw-on-error
37
43
 
38
44
  ## Installation
39
45
 
@@ -53,6 +59,9 @@ import { getUsersUserdetails } from 'rozod/lib/endpoints/usersv1';
53
59
 
54
60
  // Fetch user details with full type safety
55
61
  const userInfo = await fetchApi(getUsersUserdetails, { userIds: [1, 123456] });
62
+ if (isAnyErrorResponse(userInfo)) {
63
+ return;
64
+ }
56
65
  console.log(userInfo.data[0].displayName); // Properly typed!
57
66
  ```
58
67
 
@@ -88,8 +97,8 @@ import { getGroupsGroupidWallPosts } from 'rozod/lib/endpoints/groupsv2';
88
97
  // Process pages as they arrive
89
98
  const pages = fetchApiPagesGenerator(getGroupsGroupidWallPosts, { groupId: 11479637 });
90
99
  for await (const page of pages) {
91
- console.log(`Processing page with ${page.data.length} posts`);
92
- // Do something with this page
100
+ console.log(`Processing page with ${page.data.length} posts`);
101
+ // Do something with this page
93
102
  }
94
103
  ```
95
104
 
@@ -101,13 +110,47 @@ import { getGamesIcons } from 'rozod/lib/endpoints/gamesv1';
101
110
 
102
111
  // Will automatically split into smaller batches of 100 universeIds per request
103
112
  const data = await fetchApiSplit(
104
- getGamesIcons,
105
- { universeIds: [1, 2, 3, 4, 5, /* many more IDs */] },
106
- { universeIds: 100 }
113
+ getGamesIcons,
114
+ { universeIds: [1, 2, 3, 4, 5 /* many more IDs */] },
115
+ { universeIds: 100 },
107
116
  );
108
117
  console.log(data);
109
118
  ```
110
119
 
120
+ ### Handling Errors
121
+
122
+ By default, requests return either the success type or a simple `AnyError`. Use the tiny helper to check:
123
+
124
+ ```ts
125
+ import { fetchApi, isAnyErrorResponse } from 'rozod';
126
+ import { getGamesIcons } from 'rozod/lib/endpoints/gamesv1';
127
+
128
+ const res = await fetchApi(getGamesIcons, { universeIds: [1534453623] });
129
+ if (isAnyErrorResponse(res)) {
130
+ console.error(res.message);
131
+ } else {
132
+ console.log(res.data);
133
+ }
134
+ ```
135
+
136
+ Prefer a straight try/catch? Enable throwing:
137
+
138
+ ```ts
139
+ try {
140
+ const res = await fetchApi(getGamesIcons, { universeIds: [1534453623] }, { throwOnError: true });
141
+ console.log(res.data);
142
+ } catch (err) {
143
+ console.error((err as Error).message);
144
+ }
145
+ ```
146
+
147
+ Need the raw Response? Use `returnRaw: true`:
148
+
149
+ ```ts
150
+ const resp = await fetchApi(getGamesIcons, { universeIds: [1534453623] }, { returnRaw: true });
151
+ const json = await resp.json();
152
+ ```
153
+
111
154
  ## OpenCloud
112
155
 
113
156
  RoZod supports Roblox's newer OpenCloud APIs with the same easy interface:
@@ -117,8 +160,8 @@ import { fetchApi } from 'rozod';
117
160
  import { v2 } from 'rozod/lib/opencloud';
118
161
 
119
162
  // Get universe details through OpenCloud
120
- const universeInfo = await fetchApi(v2.getCloudV2UniversesUniverseId, {
121
- universe_id: '123456789'
163
+ const universeInfo = await fetchApi(v2.getCloudV2UniversesUniverseId, {
164
+ universe_id: '123456789',
122
165
  });
123
166
 
124
167
  // Access typed properties
@@ -133,12 +176,110 @@ import { fetchApi } from 'rozod';
133
176
  import { getCloudV2UniversesUniverseIdDataStoresDataStoreIdEntries } from 'rozod/lib/opencloud/v2/cloud';
134
177
 
135
178
  // Get DataStore entries with type safety
136
- const dataStoreEntries = await fetchApi(
137
- getCloudV2UniversesUniverseIdDataStoresDataStoreIdEntries,
138
- {
139
- universe_id: '123456789',
140
- data_store_id: 'MyStore'
179
+ const dataStoreEntries = await fetchApi(getCloudV2UniversesUniverseIdDataStoresDataStoreIdEntries, {
180
+ universe_id: '123456789',
181
+ data_store_id: 'MyStore',
182
+ });
183
+ ```
184
+
185
+ ## Authentication
186
+
187
+ RoZod handles Roblox authentication automatically with comprehensive security features:
188
+
189
+ ### Browser Environments
190
+
191
+ In browsers, authentication works automatically when users are logged into Roblox:
192
+
193
+ ```ts
194
+ import { fetchApi } from 'rozod';
195
+ import { getUsersUserdetails } from 'rozod/lib/endpoints/usersv1';
196
+
197
+ // Cookies are sent automatically - no setup required!
198
+ const userInfo = await fetchApi(getUsersUserdetails, { userIds: [123456] });
199
+ ```
200
+
201
+ ### Server Environments (Node.js/Bun/Deno)
202
+
203
+ For server environments, you need to provide the `.ROBLOSECURITY` cookie manually:
204
+
205
+ ```ts
206
+ import { fetchApi } from 'rozod';
207
+ import { getUsersUserdetails } from 'rozod/lib/endpoints/usersv1';
208
+
209
+ const userInfo = await fetchApi(
210
+ getUsersUserdetails,
211
+ { userIds: [123456] },
212
+ {
213
+ headers: {
214
+ 'Cookie': '.ROBLOSECURITY=your_cookie_here'
215
+ }
216
+ }
217
+ );
218
+ ```
219
+
220
+ ### Security Features
221
+
222
+ RoZod automatically handles advanced Roblox security requirements:
223
+
224
+ - **✅ XCSRF Token Management** - Automatic CSRF token retrieval and caching
225
+ - **✅ Hardware-Backed Authentication** - Full HBA signature support
226
+ - **✅ Challenge Handling** - Captchas, 2FA, and other authentication challenges
227
+ - **✅ Cookie Security** - Secure cookie parsing and validation
228
+
229
+ ### Challenge Handling
230
+
231
+ For advanced authentication challenges (captchas, 2FA), set up a global challenge handler:
232
+
233
+ ```ts
234
+ import { setHandleGenericChallenge } from 'rozod';
235
+
236
+ setHandleGenericChallenge(async (challenge) => {
237
+ // Handle captcha, 2FA, or other challenges
238
+ // Return the challenge response or undefined to skip
239
+ if (challenge.challengeType === 'captcha') {
240
+ const solution = await solveCaptcha(challenge.challengeId);
241
+ return {
242
+ challengeType: challenge.challengeType,
243
+ challengeId: challenge.challengeId,
244
+ challengeBase64Metadata: solution
245
+ };
246
+ }
247
+ });
248
+ ```
249
+
250
+ ### Hardware-Backed Authentication (Advanced)
251
+
252
+ For Node.js environments requiring custom HBA keys:
253
+
254
+ ```ts
255
+ import { changeHBAKeys } from 'rozod';
256
+
257
+ // Provide your own crypto key pair for HBA signatures
258
+ const keyPair = await crypto.subtle.generateKey(
259
+ { name: 'ECDSA', namedCurve: 'P-256' },
260
+ true,
261
+ ['sign', 'verify']
262
+ );
263
+
264
+ changeHBAKeys(keyPair);
265
+ ```
266
+
267
+ ### OpenCloud Authentication
268
+
269
+ OpenCloud APIs require API keys in headers:
270
+
271
+ ```ts
272
+ import { fetchApi } from 'rozod';
273
+ import { v2 } from 'rozod/lib/opencloud';
274
+
275
+ const universeInfo = await fetchApi(
276
+ v2.getCloudV2UniversesUniverseId,
277
+ { universe_id: '123456789' },
278
+ {
279
+ headers: {
280
+ 'x-api-key': 'your_opencloud_api_key_here'
141
281
  }
282
+ }
142
283
  );
143
284
  ```
144
285
 
@@ -156,11 +297,11 @@ const myCustomEndpoint = endpoint({
156
297
  baseUrl: 'https://my-api.example.com',
157
298
  parameters: {
158
299
  customId: z.string(),
159
- optional: z.string().optional()
300
+ optional: z.string().optional(),
160
301
  },
161
302
  response: z.object({
162
303
  success: z.boolean(),
163
- data: z.array(z.string())
304
+ data: z.array(z.string()),
164
305
  }),
165
306
  });
166
307
 
@@ -168,7 +309,9 @@ const response = await fetchApi(myCustomEndpoint, { customId: '123' });
168
309
  ```
169
310
 
170
311
  ## Credits
312
+
171
313
  This repository is maintained by Alrovi ApS, the company behind RoGold.
172
314
 
173
315
  ## Disclaimer
316
+
174
317
  RoZod is not affiliated with, maintained, authorized, endorsed, or sponsored by Roblox Corporation or any of its affiliates.
@@ -155,7 +155,6 @@ export const postBirthdate = endpoint({
155
155
  {
156
156
  status: 403,
157
157
  description: `0: Token Validation Failed
158
- 2: PIN is locked.
159
158
  5: Invalid birthdate change.`,
160
159
  },
161
160
  {
@@ -213,8 +212,7 @@ export const postDescription = endpoint({
213
212
  },
214
213
  {
215
214
  status: 403,
216
- description: `0: Token Validation Failed
217
- 2: PIN is locked.`,
215
+ description: `0: Token Validation Failed`,
218
216
  },
219
217
  {
220
218
  status: 500,
@@ -298,8 +296,7 @@ export const postGender = endpoint({
298
296
  },
299
297
  {
300
298
  status: 403,
301
- description: `0: Token Validation Failed
302
- 2: PIN is locked.`,
299
+ description: `0: Token Validation Failed`,
303
300
  },
304
301
  {
305
302
  status: 500,
@@ -370,7 +367,6 @@ export const postPhone = endpoint({
370
367
  {
371
368
  status: 403,
372
369
  description: `0: Token Validation Failed
373
- 4: Account Pin Locked
374
370
  5: Incorrect Password
375
371
  10: `,
376
372
  },
@@ -412,7 +408,6 @@ export const postPhoneDelete = endpoint({
412
408
  {
413
409
  status: 403,
414
410
  description: `0: Token Validation Failed
415
- 4: Account Pin Locked
416
411
  5: Incorrect Password`,
417
412
  },
418
413
  {
@@ -589,7 +584,6 @@ export const postPromotionChannels = endpoint({
589
584
  {
590
585
  status: 403,
591
586
  description: `0: Token Validation Failed
592
- 3: PIN is locked.
593
587
  4: Only users who are over twelve years of age may edit social network channels.`,
594
588
  },
595
589
  ],
@@ -156,7 +156,6 @@ exports.postBirthdate = (0, __1.endpoint)({
156
156
  {
157
157
  status: 403,
158
158
  description: `0: Token Validation Failed
159
- 2: PIN is locked.
160
159
  5: Invalid birthdate change.`,
161
160
  },
162
161
  {
@@ -214,8 +213,7 @@ exports.postDescription = (0, __1.endpoint)({
214
213
  },
215
214
  {
216
215
  status: 403,
217
- description: `0: Token Validation Failed
218
- 2: PIN is locked.`,
216
+ description: `0: Token Validation Failed`,
219
217
  },
220
218
  {
221
219
  status: 500,
@@ -299,8 +297,7 @@ exports.postGender = (0, __1.endpoint)({
299
297
  },
300
298
  {
301
299
  status: 403,
302
- description: `0: Token Validation Failed
303
- 2: PIN is locked.`,
300
+ description: `0: Token Validation Failed`,
304
301
  },
305
302
  {
306
303
  status: 500,
@@ -371,7 +368,6 @@ exports.postPhone = (0, __1.endpoint)({
371
368
  {
372
369
  status: 403,
373
370
  description: `0: Token Validation Failed
374
- 4: Account Pin Locked
375
371
  5: Incorrect Password
376
372
  10: `,
377
373
  },
@@ -413,7 +409,6 @@ exports.postPhoneDelete = (0, __1.endpoint)({
413
409
  {
414
410
  status: 403,
415
411
  description: `0: Token Validation Failed
416
- 4: Account Pin Locked
417
412
  5: Incorrect Password`,
418
413
  },
419
414
  {
@@ -590,7 +585,6 @@ exports.postPromotionChannels = (0, __1.endpoint)({
590
585
  {
591
586
  status: 403,
592
587
  description: `0: Token Validation Failed
593
- 3: PIN is locked.
594
588
  4: Only users who are over twelve years of age may edit social network channels.`,
595
589
  },
596
590
  ],