@inneropen/marvin-sdk 2.0.1 → 3.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.
package/dist/platform.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import {
2
2
  HttpClient,
3
+ MarvinValidationError,
3
4
  SessionAuth,
4
5
  init_core
5
- } from "./chunk-25F3IF6S.js";
6
+ } from "./chunk-WJC4X7TB.js";
6
7
 
7
8
  // src/platform/client.ts
8
9
  init_core();
@@ -23,7 +24,8 @@ var EntriesModule = class {
23
24
  * Get a single entry by ID
24
25
  */
25
26
  async get(id) {
26
- return this.http.get(`/api/platform/entries/${id}`);
27
+ const validId = this.http.validatePathParam(id, "entry ID");
28
+ return this.http.get(`/api/platform/entries/${validId}`);
27
29
  }
28
30
  /**
29
31
  * Create a new entry
@@ -35,26 +37,31 @@ var EntriesModule = class {
35
37
  * Update an entry
36
38
  */
37
39
  async update(id, data) {
38
- return this.http.patch(`/api/platform/entries/${id}`, data);
40
+ const validId = this.http.validatePathParam(id, "entry ID");
41
+ return this.http.patch(`/api/platform/entries/${validId}`, data);
39
42
  }
40
43
  /**
41
44
  * Delete an entry
42
45
  */
43
46
  async delete(id) {
44
- return this.http.delete(`/api/platform/entries/${id}`);
47
+ const validId = this.http.validatePathParam(id, "entry ID");
48
+ return this.http.delete(`/api/platform/entries/${validId}`);
45
49
  }
46
50
  /**
47
51
  * Get collections that this entry belongs to
48
52
  */
49
53
  async listCollections(entryId) {
50
- return this.http.get(`/api/platform/entries/${entryId}/collections`);
54
+ const validId = this.http.validatePathParam(entryId, "entry ID");
55
+ return this.http.get(`/api/platform/entries/${validId}/collections`);
51
56
  }
52
57
  /**
53
58
  * Add entry to a collection
54
59
  */
55
60
  async addToCollection(entryId, collectionId) {
61
+ const validEntryId = this.http.validatePathParam(entryId, "entry ID");
62
+ const validCollectionId = this.http.validatePathParam(collectionId, "collection ID");
56
63
  return this.http.post(
57
- `/api/platform/entries/${entryId}/collections/${collectionId}`,
64
+ `/api/platform/entries/${validEntryId}/collections/${validCollectionId}`,
58
65
  {}
59
66
  );
60
67
  }
@@ -62,7 +69,9 @@ var EntriesModule = class {
62
69
  * Remove entry from a collection
63
70
  */
64
71
  async removeFromCollection(entryId, collectionId) {
65
- return this.http.delete(`/api/platform/entries/${entryId}/collections/${collectionId}`);
72
+ const validEntryId = this.http.validatePathParam(entryId, "entry ID");
73
+ const validCollectionId = this.http.validatePathParam(collectionId, "collection ID");
74
+ return this.http.delete(`/api/platform/entries/${validEntryId}/collections/${validCollectionId}`);
66
75
  }
67
76
  };
68
77
 
@@ -82,7 +91,8 @@ var CollectionsModule = class {
82
91
  * Get a single collection by ID
83
92
  */
84
93
  async get(id) {
85
- return this.http.get(`/api/platform/collections/${id}`);
94
+ const validId = this.http.validatePathParam(id, "id");
95
+ return this.http.get(`/api/platform/collections/${validId}`);
86
96
  }
87
97
  /**
88
98
  * Create a new collection
@@ -94,25 +104,29 @@ var CollectionsModule = class {
94
104
  * Update a collection
95
105
  */
96
106
  async update(id, data) {
97
- return this.http.patch(`/api/platform/collections/${id}`, data);
107
+ const validId = this.http.validatePathParam(id, "id");
108
+ return this.http.patch(`/api/platform/collections/${validId}`, data);
98
109
  }
99
110
  /**
100
111
  * Delete a collection
101
112
  */
102
113
  async delete(id) {
103
- return this.http.delete(`/api/platform/collections/${id}`);
114
+ const validId = this.http.validatePathParam(id, "collection ID");
115
+ return this.http.delete(`/api/platform/collections/${validId}`);
104
116
  }
105
117
  /**
106
118
  * Get entries in a collection
107
119
  */
108
120
  async getEntries(id) {
109
- return this.http.get(`/api/platform/collections/${id}/entries`);
121
+ const validId = this.http.validatePathParam(id, "collection ID");
122
+ return this.http.get(`/api/platform/collections/${validId}/entries`);
110
123
  }
111
124
  /**
112
125
  * Reorder entries in a collection
113
126
  */
114
127
  async reorderEntries(id, entries) {
115
- return this.http.patch(`/api/platform/collections/${id}/entries/order`, { entries });
128
+ const validId = this.http.validatePathParam(id, "collection ID");
129
+ return this.http.patch(`/api/platform/collections/${validId}/entries/order`, { entries });
116
130
  }
117
131
  };
118
132
 
@@ -132,7 +146,8 @@ var ResourcesModule = class {
132
146
  * Get a single resource by ID
133
147
  */
134
148
  async get(id) {
135
- return this.http.get(`/api/platform/resources/${id}`);
149
+ const validId = this.http.validatePathParam(id, "id");
150
+ return this.http.get(`/api/platform/resources/${validId}`);
136
151
  }
137
152
  /**
138
153
  * Create a new resource
@@ -144,7 +159,8 @@ var ResourcesModule = class {
144
159
  * Update a resource
145
160
  */
146
161
  async update(id, data) {
147
- return this.http.patch(`/api/platform/resources/${id}`, data);
162
+ const validId = this.http.validatePathParam(id, "id");
163
+ return this.http.patch(`/api/platform/resources/${validId}`, data);
148
164
  }
149
165
  /**
150
166
  * Delete a resource
@@ -161,11 +177,53 @@ var ResourcesModule = class {
161
177
  };
162
178
 
163
179
  // src/platform/assets.ts
180
+ init_core();
164
181
  var AssetsModule = class {
165
182
  constructor(http) {
166
183
  this.http = http;
167
184
  }
168
185
  http;
186
+ /**
187
+ * Validate file before upload
188
+ */
189
+ validateFile(file, options) {
190
+ const maxSize = options?.maxFileSize || 100 * 1024 * 1024;
191
+ const allowedTypes = options?.allowedMimeTypes;
192
+ if (file.size === 0) {
193
+ throw new MarvinValidationError("File is empty");
194
+ }
195
+ if (file.size > maxSize) {
196
+ const maxMB = Math.round(maxSize / (1024 * 1024));
197
+ const fileMB = Math.round(file.size / (1024 * 1024));
198
+ throw new MarvinValidationError(
199
+ `File size (${fileMB}MB) exceeds maximum allowed size of ${maxMB}MB`
200
+ );
201
+ }
202
+ if (allowedTypes && allowedTypes.length > 0) {
203
+ if (file instanceof File && file.type) {
204
+ const isAllowed = allowedTypes.some((allowed) => {
205
+ if (allowed.endsWith("/*")) {
206
+ const prefix = allowed.slice(0, -2);
207
+ return file.type.startsWith(prefix);
208
+ }
209
+ return file.type === allowed;
210
+ });
211
+ if (!isAllowed) {
212
+ throw new MarvinValidationError(
213
+ `File type "${file.type}" is not allowed. Allowed types: ${allowedTypes.join(", ")}`
214
+ );
215
+ }
216
+ }
217
+ }
218
+ if (file instanceof File) {
219
+ if (!file.name || file.name.trim().length === 0) {
220
+ throw new MarvinValidationError("File must have a valid name");
221
+ }
222
+ if (file.name.includes("..") || file.name.includes("/") || file.name.includes("\\")) {
223
+ throw new MarvinValidationError("Invalid filename: cannot contain path separators");
224
+ }
225
+ }
226
+ }
169
227
  /**
170
228
  * List all assets
171
229
  */
@@ -176,16 +234,31 @@ var AssetsModule = class {
176
234
  * Get a single asset by ID
177
235
  */
178
236
  async get(id) {
179
- return this.http.get(`/api/platform/assets/${id}`);
237
+ const validId = this.http.validatePathParam(id, "id");
238
+ return this.http.get(`/api/platform/assets/${validId}`);
180
239
  }
181
240
  /**
182
241
  * Upload a new asset file
183
242
  *
184
243
  * @param file - The file to upload (File or Blob)
185
244
  * @param metadata - Asset metadata (slug, name, altText, description, metadata)
245
+ * @param options - Upload options (file size limits, allowed types)
186
246
  * @returns The created asset with extracted metadata
247
+ *
248
+ * @example
249
+ * ```typescript
250
+ * // Upload with default limits (100MB, all types)
251
+ * const asset = await assets.upload(file, { slug: 'my-image', name: 'My Image' });
252
+ *
253
+ * // Upload with restrictions
254
+ * const asset = await assets.upload(file,
255
+ * { slug: 'avatar', name: 'Avatar' },
256
+ * { maxFileSize: 5 * 1024 * 1024, allowedMimeTypes: ['image/*'] }
257
+ * );
258
+ * ```
187
259
  */
188
- async upload(file, metadata) {
260
+ async upload(file, metadata, options) {
261
+ this.validateFile(file, options);
189
262
  const formData = new FormData();
190
263
  formData.append("file", file);
191
264
  formData.append("slug", metadata.slug);
@@ -205,13 +278,24 @@ var AssetsModule = class {
205
278
  * Update an asset (editable fields only: slug, name, altText, description, metadata)
206
279
  */
207
280
  async update(id, data) {
208
- return this.http.patch(`/api/platform/assets/${id}`, data);
281
+ const validId = this.http.validatePathParam(id, "id");
282
+ return this.http.patch(`/api/platform/assets/${validId}`, data);
209
283
  }
210
284
  /**
211
285
  * Delete an asset (removes file from storage and database)
212
286
  */
213
287
  async delete(id) {
214
- return this.http.delete(`/api/platform/assets/${id}`);
288
+ const validId = this.http.validatePathParam(id, "asset ID");
289
+ return this.http.delete(`/api/platform/assets/${validId}`);
290
+ }
291
+ /**
292
+ * Get download URL for an asset file
293
+ * Use this to create download links or fetch the file directly
294
+ */
295
+ getDownloadUrl(id, baseUrl) {
296
+ const validId = this.http.validatePathParam(id, "asset ID");
297
+ const base = baseUrl || (typeof window !== "undefined" && window.location ? window.location.origin : "");
298
+ return `${base}/api/platform/assets/${validId}/file`;
215
299
  }
216
300
  };
217
301
 
@@ -231,7 +315,8 @@ var APIClientsModule = class {
231
315
  * Get a single API client by ID
232
316
  */
233
317
  async get(id) {
234
- return this.http.get(`/api/platform/api-clients/${id}`);
318
+ const validId = this.http.validatePathParam(id, "id");
319
+ return this.http.get(`/api/platform/api-clients/${validId}`);
235
320
  }
236
321
  /**
237
322
  * Create a new API client (returns client with token)
@@ -243,7 +328,8 @@ var APIClientsModule = class {
243
328
  * Update an API client
244
329
  */
245
330
  async update(id, data) {
246
- return this.http.patch(`/api/platform/api-clients/${id}`, data);
331
+ const validId = this.http.validatePathParam(id, "id");
332
+ return this.http.patch(`/api/platform/api-clients/${validId}`, data);
247
333
  }
248
334
  /**
249
335
  * Delete an API client
@@ -407,6 +493,15 @@ var WorkspacesModule = class {
407
493
  const url = `/api/admin/groups/${id}${force ? "?force=true" : ""}`;
408
494
  await this.http.delete(url);
409
495
  }
496
+ /**
497
+ * Export workspace data as JSON (collections, entry types, entries, site config)
498
+ */
499
+ async export(options) {
500
+ const pretty = options?.pretty ?? true;
501
+ const endpoint = pretty ? "/api/platform/workspace/export/pretty" : "/api/platform/workspace/export";
502
+ const params = options?.includeSystemTypes ? { include_system_types: true } : void 0;
503
+ return this.http.get(endpoint, params);
504
+ }
410
505
  /**
411
506
  * Get workspace preferences
412
507
  */
@@ -422,6 +517,12 @@ var WorkspacesModule = class {
422
517
  };
423
518
 
424
519
  // src/platform/invites.ts
520
+ function getEnv(key) {
521
+ if (typeof process !== "undefined" && process.env) {
522
+ return process.env[key];
523
+ }
524
+ return void 0;
525
+ }
425
526
  var InvitesModule = class {
426
527
  constructor(http) {
427
528
  this.http = http;
@@ -454,27 +555,47 @@ var InvitesModule = class {
454
555
  }
455
556
  /**
456
557
  * Generate invitation URL from a token
457
- * Uses MARVIN_FRONTEND_URL for the base URL, falls back to MARVIN_API_URL with common port mappings
558
+ *
559
+ * @param token - Invitation token
560
+ * @param baseUrl - Base URL for the frontend (required in browser environments)
561
+ * @returns Full invitation URL
562
+ *
563
+ * @example
564
+ * ```typescript
565
+ * // Node.js (can use env vars)
566
+ * const url = invites.getInvitationUrl(token);
567
+ *
568
+ * // Browser (must provide baseUrl)
569
+ * const url = invites.getInvitationUrl(token, 'https://app.example.com');
570
+ * ```
458
571
  */
459
572
  getInvitationUrl(token, baseUrl) {
460
573
  let base = baseUrl;
461
574
  if (!base) {
462
- base = process.env.MARVIN_FRONTEND_URL;
463
- if (!base && process.env.MARVIN_API_URL) {
464
- const apiUrl = process.env.MARVIN_API_URL;
465
- if (apiUrl.includes(":8080")) {
466
- base = apiUrl.replace(":8080", ":4321");
467
- } else if (apiUrl.includes(":3000")) {
468
- base = apiUrl.replace(":3000", ":4321");
469
- } else {
470
- base = apiUrl;
575
+ base = getEnv("MARVIN_FRONTEND_URL");
576
+ if (!base) {
577
+ const apiUrl = getEnv("MARVIN_API_URL");
578
+ if (apiUrl) {
579
+ if (apiUrl.includes(":8080")) {
580
+ base = apiUrl.replace(":8080", ":4321");
581
+ } else if (apiUrl.includes(":3000")) {
582
+ base = apiUrl.replace(":3000", ":4321");
583
+ } else {
584
+ base = apiUrl;
585
+ }
471
586
  }
472
587
  }
473
- if (!base) {
474
- base = "http://localhost:4321";
588
+ }
589
+ if (!base) {
590
+ if (typeof window !== "undefined" && window.location) {
591
+ base = window.location.origin;
592
+ } else {
593
+ throw new Error(
594
+ 'baseUrl is required when not in Node.js environment. Pass the frontend URL as second argument: getInvitationUrl(token, "https://app.example.com")'
595
+ );
475
596
  }
476
597
  }
477
- return `${base}/register?token=${token}`;
598
+ return `${base}/register?token=${encodeURIComponent(token)}`;
478
599
  }
479
600
  };
480
601
 
@@ -523,11 +644,63 @@ var NotificationsModule = class {
523
644
  };
524
645
 
525
646
  // src/platform/webhooks.ts
647
+ init_core();
526
648
  var WebhooksModule = class {
527
649
  constructor(http) {
528
650
  this.http = http;
529
651
  }
530
652
  http;
653
+ /**
654
+ * Validate webhook URL to prevent SSRF attacks
655
+ */
656
+ validateWebhookUrl(url) {
657
+ if (!url || typeof url !== "string") {
658
+ throw new MarvinValidationError("Webhook URL is required and must be a string");
659
+ }
660
+ let parsed;
661
+ try {
662
+ parsed = new URL(url);
663
+ } catch {
664
+ throw new MarvinValidationError("Invalid webhook URL format. Expected: https://example.com/webhook");
665
+ }
666
+ if (!["http:", "https:"].includes(parsed.protocol)) {
667
+ throw new MarvinValidationError(
668
+ `Webhook URL must use HTTP or HTTPS protocol. Got: ${parsed.protocol}`
669
+ );
670
+ }
671
+ const hostname = parsed.hostname.toLowerCase();
672
+ const blockedHosts = [
673
+ "localhost",
674
+ "127.0.0.1",
675
+ "0.0.0.0",
676
+ "::1",
677
+ "169.254.169.254",
678
+ // AWS metadata service
679
+ "[::]"
680
+ ];
681
+ if (blockedHosts.some((blocked) => hostname === blocked || hostname.includes(blocked))) {
682
+ throw new MarvinValidationError(
683
+ "Webhook URL cannot target localhost or internal network addresses"
684
+ );
685
+ }
686
+ const ipv4Regex = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
687
+ const match = hostname.match(ipv4Regex);
688
+ if (match) {
689
+ const octets = match.slice(1).map(Number);
690
+ if (octets[0] === 10) {
691
+ throw new MarvinValidationError("Webhook URL cannot target private IP range (10.x.x.x)");
692
+ }
693
+ if (octets[0] === 172 && octets[1] >= 16 && octets[1] <= 31) {
694
+ throw new MarvinValidationError("Webhook URL cannot target private IP range (172.16-31.x.x)");
695
+ }
696
+ if (octets[0] === 192 && octets[1] === 168) {
697
+ throw new MarvinValidationError("Webhook URL cannot target private IP range (192.168.x.x)");
698
+ }
699
+ }
700
+ if (url.length > 2048) {
701
+ throw new MarvinValidationError("Webhook URL exceeds maximum length of 2048 characters");
702
+ }
703
+ }
531
704
  /**
532
705
  * List all webhooks for the current workspace
533
706
  */
@@ -539,31 +712,43 @@ var WebhooksModule = class {
539
712
  * Get a webhook by ID
540
713
  */
541
714
  async get(id) {
542
- return this.http.get(`/api/groups/webhooks/${id}`);
715
+ const validId = this.http.validatePathParam(id, "webhook ID");
716
+ return this.http.get(`/api/groups/webhooks/${validId}`);
543
717
  }
544
718
  /**
545
719
  * Create a new webhook
720
+ * Validates URL to prevent SSRF attacks
546
721
  */
547
722
  async create(data) {
723
+ if (data.url) {
724
+ this.validateWebhookUrl(data.url);
725
+ }
548
726
  return this.http.post("/api/groups/webhooks", data);
549
727
  }
550
728
  /**
551
729
  * Update a webhook
730
+ * Validates URL if provided to prevent SSRF attacks
552
731
  */
553
732
  async update(id, data) {
554
- return this.http.put(`/api/groups/webhooks/${id}`, data);
733
+ const validId = this.http.validatePathParam(id, "webhook ID");
734
+ if (data.url) {
735
+ this.validateWebhookUrl(data.url);
736
+ }
737
+ return this.http.put(`/api/groups/webhooks/${validId}`, data);
555
738
  }
556
739
  /**
557
740
  * Delete a webhook
558
741
  */
559
742
  async delete(id) {
560
- await this.http.delete(`/api/groups/webhooks/${id}`);
743
+ const validId = this.http.validatePathParam(id, "webhook ID");
744
+ await this.http.delete(`/api/groups/webhooks/${validId}`);
561
745
  }
562
746
  /**
563
747
  * Test a webhook
564
748
  */
565
749
  async test(id) {
566
- return this.http.post(`/api/groups/webhooks/${id}/test`, {});
750
+ const validId = this.http.validatePathParam(id, "webhook ID");
751
+ return this.http.post(`/api/groups/webhooks/${validId}/test`, {});
567
752
  }
568
753
  /**
569
754
  * Rerun failed webhooks
@@ -655,6 +840,7 @@ var AdminSystemModule = class {
655
840
  }
656
841
  /**
657
842
  * Update email settings
843
+ * Note: Password field is write-only and will not be returned in response
658
844
  */
659
845
  async updateEmailSettings(data) {
660
846
  return this.http.put("/api/admin/email", data);
@@ -938,53 +1124,40 @@ var EmailTemplatesClient = class {
938
1124
  http;
939
1125
  /**
940
1126
  * List all email templates for the workspace
941
- * @param groupId - Workspace ID
942
1127
  */
943
1128
  async list(groupId) {
944
1129
  return this.http.get(`/api/platform/workspaces/${groupId}/email-templates`);
945
1130
  }
946
1131
  /**
947
1132
  * Get a specific email template
948
- * @param groupId - Workspace ID
949
- * @param templateId - Template ID
950
1133
  */
951
1134
  async get(groupId, templateId) {
952
1135
  return this.http.get(`/api/platform/workspaces/${groupId}/email-templates/${templateId}`);
953
1136
  }
954
1137
  /**
955
1138
  * Create a new email template
956
- * @param groupId - Workspace ID
957
- * @param data - Template data
958
1139
  */
959
1140
  async create(groupId, data) {
960
1141
  return this.http.post(`/api/platform/workspaces/${groupId}/email-templates`, data);
961
1142
  }
962
1143
  /**
963
1144
  * Update an email template
964
- * @param groupId - Workspace ID
965
- * @param templateId - Template ID
966
- * @param data - Updated template data
967
1145
  */
968
1146
  async update(groupId, templateId, data) {
969
1147
  return this.http.patch(`/api/platform/workspaces/${groupId}/email-templates/${templateId}`, data);
970
1148
  }
971
1149
  /**
972
1150
  * Delete an email template
973
- * @param groupId - Workspace ID
974
- * @param templateId - Template ID
975
1151
  */
976
1152
  async delete(groupId, templateId) {
977
1153
  await this.http.delete(`/api/platform/workspaces/${groupId}/email-templates/${templateId}`);
978
1154
  }
979
1155
  /**
980
1156
  * Send a test email using a template
981
- * @param groupId - Workspace ID
982
- * @param templateId - Template ID
983
- * @param recipientEmail - Test recipient email address
984
1157
  */
985
1158
  async sendTest(groupId, templateId, recipientEmail) {
986
1159
  return this.http.post(`/api/platform/workspaces/${groupId}/email-templates/${templateId}/test`, {
987
- recipient_email: recipientEmail
1160
+ email: recipientEmail
988
1161
  });
989
1162
  }
990
1163
  };
@@ -1005,7 +1178,8 @@ var ScheduledTasksModule = class {
1005
1178
  * Get a scheduled task by ID or slug
1006
1179
  */
1007
1180
  async get(idOrSlug) {
1008
- return this.http.get(`/api/platform/scheduled-tasks/${idOrSlug}`);
1181
+ const validIdOrSlug = this.http.validatePathParam(idOrSlug, "idOrSlug");
1182
+ return this.http.get(`/api/platform/scheduled-tasks/${validIdOrSlug}`);
1009
1183
  }
1010
1184
  /**
1011
1185
  * Create a new scheduled task
@@ -1017,7 +1191,8 @@ var ScheduledTasksModule = class {
1017
1191
  * Update a scheduled task
1018
1192
  */
1019
1193
  async update(idOrSlug, data) {
1020
- return this.http.patch(`/api/platform/scheduled-tasks/${idOrSlug}`, data);
1194
+ const validIdOrSlug = this.http.validatePathParam(idOrSlug, "idOrSlug");
1195
+ return this.http.patch(`/api/platform/scheduled-tasks/${validIdOrSlug}`, data);
1021
1196
  }
1022
1197
  /**
1023
1198
  * Delete a scheduled task
@@ -1058,11 +1233,40 @@ var ScheduledTasksModule = class {
1058
1233
  };
1059
1234
 
1060
1235
  // src/platform/forms.ts
1236
+ init_core();
1061
1237
  var FormsModule = class {
1062
1238
  constructor(http) {
1063
1239
  this.http = http;
1064
1240
  }
1065
1241
  http;
1242
+ /**
1243
+ * Validate form submission data
1244
+ * - Prevents XSS by checking for script tags
1245
+ * - Validates data is a proper object
1246
+ * - Checks for reasonable size limits
1247
+ */
1248
+ validateFormData(data) {
1249
+ if (!data || typeof data !== "object") {
1250
+ throw new MarvinValidationError("Form data must be a valid object");
1251
+ }
1252
+ const jsonString = JSON.stringify(data);
1253
+ const sizeInBytes = new Blob([jsonString]).size;
1254
+ if (sizeInBytes > 1024 * 1024) {
1255
+ throw new MarvinValidationError("Form data exceeds maximum size of 1MB");
1256
+ }
1257
+ const checkForScripts = (value) => {
1258
+ if (typeof value === "string") {
1259
+ if (/<script[\s\S]*?>[\s\S]*?<\/script>/gi.test(value)) {
1260
+ throw new MarvinValidationError("Form data contains potentially malicious content");
1261
+ }
1262
+ } else if (Array.isArray(value)) {
1263
+ value.forEach(checkForScripts);
1264
+ } else if (value && typeof value === "object") {
1265
+ Object.values(value).forEach(checkForScripts);
1266
+ }
1267
+ };
1268
+ Object.values(data).forEach(checkForScripts);
1269
+ }
1066
1270
  /**
1067
1271
  * List all forms
1068
1272
  */
@@ -1073,7 +1277,8 @@ var FormsModule = class {
1073
1277
  * Get a single form by ID
1074
1278
  */
1075
1279
  async get(id) {
1076
- return this.http.get(`/api/platform/forms/${id}`);
1280
+ const validId = this.http.validatePathParam(id, "id");
1281
+ return this.http.get(`/api/platform/forms/${validId}`);
1077
1282
  }
1078
1283
  /**
1079
1284
  * Create a new form
@@ -1085,7 +1290,8 @@ var FormsModule = class {
1085
1290
  * Update a form
1086
1291
  */
1087
1292
  async update(id, data) {
1088
- return this.http.patch(`/api/platform/forms/${id}`, data);
1293
+ const validId = this.http.validatePathParam(id, "id");
1294
+ return this.http.patch(`/api/platform/forms/${validId}`, data);
1089
1295
  }
1090
1296
  /**
1091
1297
  * Delete a form
@@ -1107,15 +1313,31 @@ var FormsModule = class {
1107
1313
  }
1108
1314
  /**
1109
1315
  * Submit data to a published form (Publishing API - public access)
1316
+ * Validates data before submission to prevent XSS and malicious content
1110
1317
  */
1111
1318
  async submitForm(slug, data) {
1112
- return this.http.post(`/api/publish/forms/${slug}/submit`, {
1319
+ const validSlug = this.http.validatePathParam(slug, "form slug");
1320
+ this.validateFormData(data);
1321
+ return this.http.post(`/api/publish/forms/${validSlug}/submit`, {
1113
1322
  dataJson: data
1114
1323
  });
1115
1324
  }
1116
1325
  };
1117
1326
 
1118
1327
  // src/platform/client.ts
1328
+ function getEnv2(key) {
1329
+ if (typeof process !== "undefined" && process.env) {
1330
+ return process.env[key];
1331
+ }
1332
+ return void 0;
1333
+ }
1334
+ function createPlatformConfigFromEnv(overrides) {
1335
+ return {
1336
+ apiUrl: overrides?.apiUrl || getEnv2("MARVIN_API_URL") || "http://localhost:8080",
1337
+ userToken: overrides?.userToken || getEnv2("MARVIN_USER_TOKEN"),
1338
+ credentials: overrides?.credentials || "include"
1339
+ };
1340
+ }
1119
1341
  var PlatformClient = class extends HttpClient {
1120
1342
  entries;
1121
1343
  collections;
@@ -1142,7 +1364,7 @@ var PlatformClient = class extends HttpClient {
1142
1364
  adminMaintenance;
1143
1365
  constructor(config) {
1144
1366
  const httpConfig = {
1145
- baseUrl: config.apiUrl,
1367
+ baseUrl: config.apiUrl || "http://localhost:8080",
1146
1368
  auth: new SessionAuth(config.userToken),
1147
1369
  credentials: config.credentials || "include"
1148
1370
  };
@@ -1172,7 +1394,8 @@ var PlatformClient = class extends HttpClient {
1172
1394
  }
1173
1395
  };
1174
1396
  function createPlatformClient(config) {
1175
- return new PlatformClient(config);
1397
+ const finalConfig = createPlatformConfigFromEnv(config);
1398
+ return new PlatformClient(finalConfig);
1176
1399
  }
1177
1400
  export {
1178
1401
  APIClientsModule,
@@ -1198,5 +1421,6 @@ export {
1198
1421
  WebhooksModule,
1199
1422
  WorkspaceMembersModule,
1200
1423
  WorkspacesModule,
1201
- createPlatformClient
1424
+ createPlatformClient,
1425
+ createPlatformConfigFromEnv
1202
1426
  };