@unboundcx/sdk 4.13.87 → 4.13.89

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.87",
3
+ "version": "4.13.89",
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",
@@ -12,7 +12,13 @@ import { internalRequest } from '../../base.js';
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
14
  // underscore -- the same convention formSubmit.js/formSubmitPublicKey.js
15
- // already split on for the legacy `_token` field.
15
+ // already split on for the legacy `_token` field. `context` is NOT a
16
+ // control field: app1-api's captureContext.js builds the submission's
17
+ // context column by scanning the body's TOP-LEVEL keys against an
18
+ // allowlist (utm_*, gclid, fbclid, referrer, landingUrl, pageUrl,
19
+ // userAgent) and explicitly skips any `_`-prefixed key as a control
20
+ // field -- so `context` values are spread onto the top level alongside
21
+ // `fields`, never nested, or the server drops them silently.
16
22
  export class FormsPublicService {
17
23
  constructor(sdk) {
18
24
  this.sdk = sdk;
@@ -28,7 +34,9 @@ export class FormsPublicService {
28
34
  * @param {Object} [options]
29
35
  * @param {Object} [options.context] - Client-observed context (utm/referrer/
30
36
  * landingUrl/etc, D12) to merge with what the server infers from the
31
- * request itself -- sent as the `_context` control field.
37
+ * request itself -- spread onto the top-level body (never nested);
38
+ * the server's captureContext.js allowlist only reads top-level keys.
39
+ * A key here that collides with a `fields` key loses to `fields`.
32
40
  * @param {string} [options.captchaToken] - Turnstile/etc response token
33
41
  * (D10); sent as `_captchaToken`. Ignored server-side until a captcha
34
42
  * provider is configured for the form/account.
@@ -41,10 +49,9 @@ export class FormsPublicService {
41
49
  { publicKey },
42
50
  { publicKey: { type: 'string', required: true } },
43
51
  );
44
- const body = { ...(fields || {}) };
52
+ const body = { ...(context || {}), ...(fields || {}) };
45
53
  if (idempotencyKey) body._idempotencyKey = idempotencyKey;
46
54
  if (captchaToken) body._captchaToken = captchaToken;
47
- if (context) body._context = context;
48
55
 
49
56
  return internalRequest(
50
57
  this.sdk,
@@ -43,4 +43,31 @@ export class FormsSettingsService {
43
43
  body: { ...(patch || {}) },
44
44
  });
45
45
  }
46
+
47
+ /**
48
+ * Review fix -- per-form Turnstile override (Settings tab's "Secret key
49
+ * (override)" field). Mirrors `set()`: the raw secret goes under
50
+ * `turnstileSecret`, never the stored `turnstileSecretRef` column name.
51
+ * Server route: `PUT /forms/:id/settings`
52
+ * (app1-api/src/services/forms/controllers/putFormSettings.js).
53
+ * @param {string} formId
54
+ * @param {Object} patch
55
+ * @param {string|null} [patch.captchaProvider]
56
+ * @param {string|null} [patch.turnstileSiteKey]
57
+ * @param {string} [patch.turnstileSecret] - Plaintext; omit (or send '')
58
+ * to leave the currently stored secret untouched.
59
+ * @returns {Promise<Object>}
60
+ */
61
+ async setForm(formId, patch) {
62
+ this.sdk.validateParams(
63
+ { formId },
64
+ { formId: { type: 'string', required: true } },
65
+ );
66
+ return internalRequest(
67
+ this.sdk,
68
+ `/forms/${encodeURIComponent(formId)}/settings`,
69
+ 'PUT',
70
+ { body: { ...(patch || {}) } },
71
+ );
72
+ }
46
73
  }