@unboundcx/sdk 4.13.90 → 4.13.91
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 +1 -1
- package/services/forms.js +47 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unboundcx/sdk",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.91",
|
|
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",
|
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
|
}
|