@unboundcx/sdk 4.13.90 → 4.13.92

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unboundcx/sdk",
3
- "version": "4.13.90",
3
+ "version": "4.13.92",
4
4
  "description": "Official JavaScript SDK for the Unbound API - A comprehensive toolkit for integrating with Unbound's communication, AI, and data management services",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -11,8 +11,8 @@ import { internalRequest } from '../../base.js';
11
11
  // forms-v2-precheck.md §4.1): plain form fields go at the top level of the
12
12
  // body (fieldKey -> value, arrays allowed), and everything the server
13
13
  // treats as a *control* field (not a form value) is sent with a leading
14
- // underscore -- the same convention formSubmit.js/formSubmitPublicKey.js
15
- // already split on for the legacy `_token` field. `context` is NOT a
14
+ // underscore, e.g. `_idempotencyKey`/`_captchaToken` below --
15
+ // formSubmitPublicKey.js splits on that same convention. `context` is NOT a
16
16
  // control field: app1-api's captureContext.js builds the submission's
17
17
  // context column by scanning the body's TOP-LEVEL keys against an
18
18
  // allowlist (utm_*, gclid, fbclid, referrer, landingUrl, pageUrl,
@@ -26,9 +26,8 @@ export class FormsPublicService {
26
26
 
27
27
  /**
28
28
  * Submit a public form by its publicKey (D1 -- every form has its own
29
- * publicKey; no tracking-code/_token needed for this path). Legacy
30
- * hosted-fields forms keep using the `/webhooks/form/:formId` +
31
- * `_token` path (unchanged, not exposed here).
29
+ * publicKey; no tracking-code/_token needed -- publicKey + origin/
30
+ * domainAllowlist is the only auth for a public form submit).
32
31
  * @param {string} publicKey
33
32
  * @param {Object} fields - fieldKey -> value (arrays kept as arrays).
34
33
  * @param {Object} [options]
package/services/forms.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { internalRequest } from '../base.js';
1
2
  import { FormsPublicService } from './forms/PublicService.js';
2
3
  import { FormsSubmissionsService } from './forms/SubmissionsService.js';
3
4
  import { FormsSettingsService } from './forms/SettingsService.js';
@@ -14,4 +15,50 @@ export class FormsService {
14
15
  this.settings = new FormsSettingsService(sdk);
15
16
  this.health = new FormsHealthService(sdk);
16
17
  }
18
+
19
+ /**
20
+ * Gap closure (task item 2, D1/D20). Mints a brand new `forms.publicKey`
21
+ * and overwrites the old one -- every embed snippet/HTML still carrying
22
+ * the old key stops resolving immediately (see the server route's doc
23
+ * comment). A destructive action; callers should confirm with the user
24
+ * before invoking (FormIdentitySettingsCard.svelte's "Regenerate" flow).
25
+ * Server route: `POST /forms/:id/regenerate-key`
26
+ * (app1-api/src/services/forms/controllers/regenerateFormPublicKey.js).
27
+ * @param {string} formId
28
+ * @returns {Promise<{publicKey:string}>}
29
+ */
30
+ async regeneratePublicKey(formId) {
31
+ this.sdk.validateParams(
32
+ { formId },
33
+ { formId: { type: 'string', required: true } },
34
+ );
35
+ return internalRequest(
36
+ this.sdk,
37
+ `/forms/${encodeURIComponent(formId)}/regenerate-key`,
38
+ 'POST',
39
+ );
40
+ }
41
+
42
+ /**
43
+ * Gap closure (task item 3, D19). Mints a signed, 15-min-TTL token
44
+ * scoped to this exact formId so a `draft`/non-`active` form's real
45
+ * embed script can be requested via
46
+ * `GET /f/:publicKey.js?preview=<token>` without making the form
47
+ * publicly live. Server route: `POST /forms/:id/preview-token`
48
+ * (app1-api/src/services/forms/controllers/mintFormPreviewToken.js);
49
+ * verify side has been live since P2 (formEmbedPublicKey.js).
50
+ * @param {string} formId
51
+ * @returns {Promise<{token:string, expiresIn:number}>}
52
+ */
53
+ async previewToken(formId) {
54
+ this.sdk.validateParams(
55
+ { formId },
56
+ { formId: { type: 'string', required: true } },
57
+ );
58
+ return internalRequest(
59
+ this.sdk,
60
+ `/forms/${encodeURIComponent(formId)}/preview-token`,
61
+ 'POST',
62
+ );
63
+ }
17
64
  }