@healthier-business/hub-sdk 0.1.0 → 0.2.0

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 (43) hide show
  1. package/README.md +110 -3
  2. package/dist/cjs/access.d.ts +60 -0
  3. package/dist/cjs/access.js +21 -0
  4. package/dist/cjs/browser/index.d.ts +3 -3
  5. package/dist/cjs/browser/index.js +3 -1
  6. package/dist/cjs/browser/mount.d.ts +2 -0
  7. package/dist/cjs/browser/mount.js +16 -4
  8. package/dist/cjs/core/errors.d.ts +13 -0
  9. package/dist/cjs/core/errors.js +35 -3
  10. package/dist/cjs/embed/handler.js +3 -1
  11. package/dist/cjs/embed/protocol.d.ts +33 -3
  12. package/dist/cjs/embed/protocol.js +29 -1
  13. package/dist/cjs/generated/events.d.ts +8 -1
  14. package/dist/cjs/generated/events.js +7 -0
  15. package/dist/cjs/generated/operations.js +18 -0
  16. package/dist/cjs/generated/resources.d.ts +101 -0
  17. package/dist/cjs/generated/types.d.ts +256 -0
  18. package/dist/cjs/index.d.ts +3 -2
  19. package/dist/cjs/index.js +7 -1
  20. package/dist/cjs/version.d.ts +1 -1
  21. package/dist/cjs/version.js +1 -1
  22. package/dist/esm/access.d.ts +60 -0
  23. package/dist/esm/access.js +18 -0
  24. package/dist/esm/browser/index.d.ts +3 -3
  25. package/dist/esm/browser/index.js +1 -1
  26. package/dist/esm/browser/mount.d.ts +2 -0
  27. package/dist/esm/browser/mount.js +17 -5
  28. package/dist/esm/core/errors.d.ts +13 -0
  29. package/dist/esm/core/errors.js +32 -2
  30. package/dist/esm/embed/handler.js +4 -2
  31. package/dist/esm/embed/protocol.d.ts +33 -3
  32. package/dist/esm/embed/protocol.js +27 -0
  33. package/dist/esm/generated/events.d.ts +8 -1
  34. package/dist/esm/generated/events.js +7 -0
  35. package/dist/esm/generated/operations.js +18 -0
  36. package/dist/esm/generated/resources.d.ts +101 -0
  37. package/dist/esm/generated/types.d.ts +256 -0
  38. package/dist/esm/index.d.ts +3 -2
  39. package/dist/esm/index.js +3 -2
  40. package/dist/esm/version.d.ts +1 -1
  41. package/dist/esm/version.js +1 -1
  42. package/dist/iife/hb-embed.min.js +1 -1
  43. package/package.json +3 -7
package/README.md CHANGED
@@ -12,6 +12,8 @@ Give it your API key and it does the rest: it gets and renews tokens, retries sa
12
12
  npm install @healthier-business/hub-sdk
13
13
  ```
14
14
 
15
+ Full documentation, with every method, the embed flow and the sandbox: <https://dev.hbcompliance.co.uk/sdk-overview>
16
+
15
17
  ## Quickstart
16
18
 
17
19
  ```ts
@@ -39,6 +41,7 @@ That is all the setup there is. No token calls, no refresh logic, no storage.
39
41
  - [Files](#files)
40
42
  - [Webhooks](#webhooks)
41
43
  - [Embedding courses, tests and OH forms](#embedding-courses-tests-and-oh-forms)
44
+ - [Access, payment and renewal](#access-payment-and-renewal)
42
45
  - [Sandbox](#sandbox)
43
46
  - [Serverless and token storage](#serverless-and-token-storage)
44
47
  - [Updating the SDK when the API changes](#updating-the-sdk-when-the-api-changes)
@@ -110,6 +113,7 @@ Everything the Hub refuses is an `ApiError` with `status`, `code` (the stable `s
110
113
  | `PermissionError` (403) | `insufficient_scope`, `portal_unavailable`, `key_inactive`, `ip_not_allowed`. |
111
114
  | `AuthenticationError` (401) | The key is wrong, or was regenerated. |
112
115
  | `NotFoundError` (404), `ConflictError` (409) | |
116
+ | `EmbedAccessError` (409, a `ConflictError`) | An embed session was refused because the candidate's access is not in place. `error.access` is `{ state, payer, next }`. See [Access, payment and renewal](#access-payment-and-renewal). |
113
117
  | `InsufficientCreditsError` (402) | Nothing was charged. |
114
118
  | `RateLimitError` (429) | After the SDK ran out of retries. `retryAfterSeconds` is set. |
115
119
  | `GoneError` (410) | For example `session_expired`. |
@@ -230,7 +234,7 @@ const frame = HealthierBusiness.mount(document.getElementById('course')!, {
230
234
 
231
235
  ### Events
232
236
 
233
- Every event below is sent by the Hub frame. The callbacks (`onProgress`, `onCompleted`, `onPassed`, `onFailed`, `onSubmitted`, `onError`, `onReady`), `onEvent` and `controller.on(name, handler)` all receive the data typed exactly as the frame sends it:
237
+ Every event below is sent by the Hub frame. The callbacks (`onProgress`, `onCompleted`, `onPassed`, `onFailed`, `onSubmitted`, `onTermsAccepted`, `onError`, `onReady`), `onEvent` and `controller.on(name, handler)` all receive the data typed exactly as the frame sends it:
234
238
 
235
239
  | Event | Sent when | Data |
236
240
  | --- | --- | --- |
@@ -239,7 +243,8 @@ Every event below is sent by the Hub frame. The callbacks (`onProgress`, `onComp
239
243
  | `completed` | The learner finished the course. Final. | `{ courseId }`: the Online Training course id of the session. |
240
244
  | `passed` / `failed` | The learner submitted the test. Final. | `{ score, passMark }`: both percentages, `score` with one decimal. The frame does not say how many attempts are left. |
241
245
  | `submitted` | The OH form was submitted. Final. | `{ requestId }`: the numeric OH request id. |
242
- | `error` | The frame could not show the session, or a call was refused after it started. | `{ code }`, plus a plain-words `message` added by the SDK. See [Troubleshooting](#troubleshooting). |
246
+ | `terms-accepted` | The candidate accepted the Hub terms on the first screen of the frame. Not final: the content follows. | `{ version, acceptedAt }`: the terms version and an ISO 8601 time. |
247
+ | `error` | The frame could not show the session, or a call was refused after it started. | `{ code }`, plus a plain-words `message` added by the SDK, and `details` (`{ state, payer, next }`) for the four access codes. See [Troubleshooting](#troubleshooting). |
243
248
  | `token-expiring` | About 2 minutes before the frame's access ends. The SDK renews it for you; you only see the event. | `{ expires_at }`: ISO 8601. |
244
249
 
245
250
  The last event of a session (`completed`, `passed`, `failed` or `submitted`) finishes it, and the Hub sends it exactly once. The events come from what the Hub recorded, never from what the browser says, so they are safe to act on in the page, but your server should still read the result from the API (or a webhook) before it grants anything.
@@ -305,7 +310,10 @@ Errors from creating or refreshing a session (these are `ApiError`s; `error.hint
305
310
  | `404 not_found` | The candidate, request or session does not exist (for your account). | Check the id; sandbox ids mean nothing for a real account, and the other way round. |
306
311
  | `409 course_not_embeddable` | The course is not a Course Studio course linked to an Online Training course. | Use a Course Studio course. |
307
312
  | `409 course_not_pending` | The candidate already completed this course. | Only courses still to do can be opened. |
308
- | `409 course_access_required` | The candidate does not have the course. | Assign it first with `hb.onlineTraining.candidates.courses()`. |
313
+ | `409 course_access_required` | The candidate's access has not been started (or the course is not assigned). `details.next` is `start_access`. | Start it with `hb.onlineTraining.candidates.accessStart()`, then create the session again. If the course is not assigned, assign it first with `hb.onlineTraining.candidates.courses()`. |
314
+ | `409 payment_pending` | The candidate has a payment link that is not paid yet. `details.next` is `pay`. | Ask them to pay, or start access again for a new link (it replaces the old one). Create the session after `online-training.access.started`. |
315
+ | `409 renewal_approval_required` | A manual renewal needs your approval. The request is recorded and your agency emailed once. `details.next` is `await_approval`. | Approve it with `renewalApprove()` (or in Hub), then create the session again. |
316
+ | `409 access_expired` | The candidate's access has ended. `details.next` is `renew`. | Renew with `accessStart()`, or `renewalRequest()` when renewals need approval, then create the session again. |
309
317
  | `409 form_not_pending` | That questionnaire was already sent, or the request has an outcome. | Pick a form that is still to answer. |
310
318
  | `409 session_finished` | The session is complete. | Create a new session. |
311
319
  | `410 session_expired` | 60 minutes passed without a refresh, or 12 hours in all. (`GoneError`) | Create a new session. |
@@ -321,12 +329,111 @@ The `error` event of `mount` (what the frame or the SDK reports; `embedErrorHint
321
329
  | `frame_invalid` | The frame was not opened by the SDK (your own iframe, or a copied URL). |
322
330
  | `origin_not_allowed` | This page is not the origin the session was created for, or the origin is not registered. |
323
331
  | `not_allowed` | The content can only be opened through the SDK from the right website. |
332
+ | `terms_required` | The candidate has not accepted the terms. The frame shows them first and nothing else opens until they do (see `terms-accepted`). |
333
+ | `access_expired` | The candidate's access ended while they were working. Renew it, then create a new session. |
334
+ | `course_access_required`, `payment_pending`, `renewal_approval_required`, `course_not_pending` | Your embed route refused to create the session. With `hb.embed.handler()` the page gets the code and `details` here; see the table above. |
324
335
  | `session_expired`, `session_finished`, `not_found` | See the table above. |
325
336
  | `network` | The frame could not reach the Hub. |
326
337
  | `frame_timeout` | The frame never started. A session that expired, finished or was made for another origin shows an error page inside the frame but sends the page nothing, so this is how you find out. |
327
338
  | `origin_mismatch` | The session's `allowedOrigin` is not this page's origin. Pass this page's origin when your server creates the session. |
328
339
  | `session_failed`, `session_changed`, `token_refresh_failed`, `init_failed` | Your route failed or returned the wrong thing. Check its response in the network tab. |
329
340
 
341
+ ## Access, payment and renewal
342
+
343
+ An embed opens nothing the Hub account would not open. Before a candidate can use a course in the frame, three things must be true: they have accepted the terms, their **training access is started**, and (for a course they have finished before) their access has not ended. Your server starts access through the API; the frame never takes payment and never starts access itself.
344
+
345
+ ### Start access
346
+
347
+ ```ts
348
+ import { accessStartResult } from '@healthier-business/hub-sdk';
349
+
350
+ const res = await hb.onlineTraining.candidates.accessStart(
351
+ { candidate_ref, body: { return_url: 'https://learn.example.com/training' } },
352
+ { idempotencyKey: `start-access-${order.id}` }, // your own id for this start
353
+ );
354
+ const result = accessStartResult(res.data); // typed: switch on result.outcome
355
+ ```
356
+
357
+ Hub decides who pays each course group (the group's setting, else the candidate's charge); the request cannot change it, and a candidate-paid group is never paid from your credits. The three outcomes:
358
+
359
+ | `outcome` | Meaning | What you do |
360
+ | --- | --- | --- |
361
+ | `enabled` | Your credits were taken (or the groups were free) and access is on. `credits_charged`, `balance_after` and the `groups` with their `expires_at` are in the answer. | Create the embed session. |
362
+ | `payment_required` | The candidate pays. `payment.url` is a **one-time payment link**, a Hub page; `payment.id`, `expires_at` (7 days), `amount_gross_pence` and the groups come with it. Nothing was started. | Give `payment.url` to the candidate (email, your page, a button). The link is shown **only in this answer** and cannot be read again. Wait for the webhook below. |
363
+ | `partial` | The same, and the groups your account pays were started (`started`). | As `payment_required`; those groups are already usable. |
364
+ | `none` | Nothing needed access, or another call just started it. Nothing was charged. | Create the embed session. |
365
+
366
+ A new link for the same candidate replaces the old one (it becomes `superseded`). Read one link's status (`pending`, `paid`, `expired`, `superseded`, `refunded`, `cancelled`) with `hb.onlineTraining.candidates.accessPayment({ candidate_ref, payment_id })`, and the candidate's current state per course group, the terms and the renewal with `hb.onlineTraining.candidates.access({ candidate_ref })`. The candidate agrees to the payment terms on the Hub page and pays through HB Pay; only HB Pay's confirmation switches access on, never the page the candidate returns to.
367
+
368
+ `accessStart` errors are the usual `ApiError`s: `InsufficientCreditsError` (402, nothing charged), `409 renewal_list_required`, `409 renewal_approval_required`, `503 payments_unavailable` (card payments are not set up: no link was made and nothing was started), `422` for a bad `group_ids`, `months` or `return_url` (it must be on one of your registered origins).
369
+
370
+ **Idempotency.** Send your own `Idempotency-Key` (`{ idempotencyKey }` as above), so that retrying after a lost answer starts and charges once. The SDK adds a random one when you do not, which protects only its own automatic retries. The same key and body within 24 hours returns the first answer without charging again (`Idempotent-Replayed: true`). A second call with a new key finds nothing left to start and answers `none`. Limits: 30 calls a minute per key, 5 a minute per candidate.
371
+
372
+ ### When the embed refuses
373
+
374
+ `hb.embed.createCourseSession`, `createTestSession` and the handler refuse a candidate whose access is not in place with a **409 `EmbedAccessError`** (a `ConflictError`). Nothing is charged and nothing is started by a refused session. `error.access` (also `error.details`) says what to do:
375
+
376
+ | `code` | `access.state` | `access.next` | Do this |
377
+ | --- | --- | --- | --- |
378
+ | `course_access_required` | `not_started` | `start_access` | `accessStart()`. |
379
+ | `payment_pending` | `payment_pending` | `pay` | The candidate pays the link you gave them. |
380
+ | `renewal_approval_required` | `awaiting_approval` | `await_approval` | Approve the renewal. |
381
+ | `access_expired` | `expired` | `renew` | Renew with `accessStart()` (or `renewalRequest()` when renewals need approval). |
382
+
383
+ `access.payer` is `client` (your credits) or `candidate`. Every field is optional: one the Hub did not send is left out.
384
+
385
+ ```ts
386
+ import { isEmbedAccessError } from '@healthier-business/hub-sdk';
387
+
388
+ try {
389
+ session = await hb.embed.createCourseSession({ candidateRef, courseId, origin });
390
+ } catch (e) {
391
+ if (!isEmbedAccessError(e)) throw e;
392
+ if (e.access.next === 'start_access') await startAccessFor(candidateRef);
393
+ else tellTheCandidate(e.code, e.hint);
394
+ }
395
+ ```
396
+
397
+ With `hb.embed.handler()` you write none of that: the route passes these four codes and `course_not_pending` to the page as `{ error, message, hint, requestId, details }` (and nothing else from the Hub), `mount()` does not create a frame, and `onError` and `ready` report them:
398
+
399
+ ```ts
400
+ HealthierBusiness.mount(el, {
401
+ endpoint: '/api/hb/embed', kind: 'course', courseId: 12,
402
+ onError: ({ code, details }) => {
403
+ if (code === 'payment_pending') showMessage('Please pay with the link we sent you.');
404
+ else if (code === 'course_access_required') askServerToStartAccess(details?.next);
405
+ },
406
+ });
407
+ ```
408
+
409
+ ### Terms in the frame
410
+
411
+ The first screen of every frame (course, test and OH form) is the Hub terms for a candidate who has not accepted the current version; nothing else opens until they do, and a new version asks again. Acceptance is recorded by the Hub with its evidence. **No API can accept the terms for a candidate**, you can only read the `terms` block of `access()`. Your page hears `terms-accepted` (`onTermsAccepted({ version, acceptedAt })`) and your server the webhook `online-training.terms.accepted`. A frame call made before acceptance is refused and the page gets the `terms_required` error event.
412
+
413
+ ### Renewals
414
+
415
+ When a course is due for renewal, `hb.onlineTraining.candidates.renewal`, `renewalRequest`, `renewalApprove` and `renewalDecline` (and `hb.onlineTraining.renewals.list`) read and decide it; the scopes are `online-training:renewals:read` and `:write`. Approving takes credits and grants access again. Embedding a candidate whose manual renewal is not approved answers `renewal_approval_required`, and records the request once.
416
+
417
+ ### Webhooks to listen for
418
+
419
+ | Event | When |
420
+ | --- | --- |
421
+ | `online-training.access.started` | Access was switched on, by credits, free groups, **candidate payment** (`source: "payment"`) or a renewal. Create the embed session when you see it for your candidate. |
422
+ | `online-training.access.payment_link.expired` | A payment link ran out unpaid: start access again for a new one. |
423
+ | `online-training.access.revoked` | A paid access was taken back (for example a refund). |
424
+ | `online-training.terms.accepted` | The candidate accepted the terms. |
425
+ | `online-training.renewal.requested`, `.approved`, `.declined` | The renewal request moved. |
426
+
427
+ They are verified and typed by `hb.webhooks.constructEvent` like every other event. Webhooks carry `candidate_ref`, never names or emails.
428
+
429
+ ### Do not trust browser events
430
+
431
+ Events such as `passed`, `completed` and `submitted` reach your page from a frame, and **a person at the browser can forge them**. Use them to update the screen. Before you issue your own certificate, record a result or grant anything, confirm it with the API (`hb.onlineTraining.candidates.results`) or a webhook on your server.
432
+
433
+ ### Sandbox
434
+
435
+ The sandbox demo candidates for each access state (enabled, payment link, renewal approval) are described in the documentation: <https://dev.hbcompliance.co.uk/sdk-overview>.
436
+
330
437
  ## Sandbox
331
438
 
332
439
  The sandbox is a safe copy of the Hub API with demo data, so you can build and test the embed without a real candidate, course or form. It is run by the Healthier Business developer platform, not by the Hub: a sandbox key never reaches the real Hub and nothing is sent or charged.
@@ -0,0 +1,60 @@
1
+ /**
2
+ * The answer of `hb.onlineTraining.candidates.accessStart()`, typed. The OpenAPI document describes it as a list of unknowns, so
3
+ * these types are written by hand from the Hub's documented body (`outcome` and the fields each outcome adds). This file does not
4
+ * depend on the generated files, so syncing the spec never touches it.
5
+ */
6
+ export interface AccessStartGroup {
7
+ group_id: number;
8
+ title: string;
9
+ /** ISO 8601 UTC: when the access ends. */
10
+ expires_at: string;
11
+ }
12
+ /** The one-time link for the groups the candidate pays for. `url` is shown only in the start answer: store it or hand it over at once. */
13
+ export interface AccessStartPayment {
14
+ /** Use it to read the link's status and to match the `access.started`, `access.payment_link.expired` and `access.revoked` webhooks. */
15
+ id: string;
16
+ /** A Hub page to give to the candidate. Works until paid or expired; a newer link for the same candidate replaces it. */
17
+ url: string;
18
+ /** ISO 8601 UTC. */
19
+ expires_at: string;
20
+ /** What the candidate would pay now, in pence including VAT. */
21
+ amount_gross_pence: number;
22
+ currency: 'GBP';
23
+ /** 12, or 24 when the account allows it and it was asked for. */
24
+ months: number;
25
+ groups: {
26
+ group_id: number;
27
+ title: string;
28
+ gross_pence: number;
29
+ }[];
30
+ }
31
+ interface Started {
32
+ credits_charged: number;
33
+ balance_after: number;
34
+ groups: AccessStartGroup[];
35
+ }
36
+ /**
37
+ * - `enabled`: switched on by this call (credits taken or free groups opened).
38
+ * - `none`: nothing needed access, or another call had just started it. Nothing was charged.
39
+ * - `payment_required`: the candidate pays: give them `payment.url`. Nothing was started.
40
+ * - `partial`: the same, and the groups your account pays were started (`started`).
41
+ */
42
+ export type AccessStartResult = ({
43
+ outcome: 'enabled';
44
+ } & Started) | {
45
+ outcome: 'none';
46
+ } | {
47
+ outcome: 'payment_required';
48
+ payment: AccessStartPayment;
49
+ started: Started;
50
+ } | {
51
+ outcome: 'partial';
52
+ payment: AccessStartPayment;
53
+ started: Started;
54
+ };
55
+ /**
56
+ * Types the `data` of an `accessStart` answer: `accessStartResult((await hb.onlineTraining.candidates.accessStart(...)).data)`.
57
+ * Throws a TypeError if the Hub answered with an outcome this version does not know, so a new outcome is never mistaken for success.
58
+ */
59
+ export declare function accessStartResult(data: unknown): AccessStartResult;
60
+ export {};
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ /**
3
+ * The answer of `hb.onlineTraining.candidates.accessStart()`, typed. The OpenAPI document describes it as a list of unknowns, so
4
+ * these types are written by hand from the Hub's documented body (`outcome` and the fields each outcome adds). This file does not
5
+ * depend on the generated files, so syncing the spec never touches it.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.accessStartResult = accessStartResult;
9
+ /**
10
+ * Types the `data` of an `accessStart` answer: `accessStartResult((await hb.onlineTraining.candidates.accessStart(...)).data)`.
11
+ * Throws a TypeError if the Hub answered with an outcome this version does not know, so a new outcome is never mistaken for success.
12
+ */
13
+ function accessStartResult(data) {
14
+ const d = data;
15
+ const outcome = d && typeof d === 'object' ? d.outcome : undefined;
16
+ if (outcome === 'enabled' || outcome === 'none')
17
+ return data;
18
+ if ((outcome === 'payment_required' || outcome === 'partial') && typeof d?.payment?.url === 'string')
19
+ return data;
20
+ throw new TypeError(`The Hub answered access/start with an outcome this SDK version does not know (${JSON.stringify(outcome)}). Update the SDK.`);
21
+ }
@@ -1,9 +1,9 @@
1
1
  import { mount } from './mount.js';
2
2
  export { mount, sessionFetcher, SANDBOX, ALLOW, type EmbedController, type MountOptions, type SessionRequest } from './mount.js';
3
- export { embedErrorHint, isEmbedSession, PROTOCOL_VERSION, type EmbedErrorCode, type EmbedEventMap, type EmbedEventName, type EmbedKind, type EmbedSession, type FrameMessage, type ParentMessage } from '../embed/protocol.js';
3
+ export { cleanAccessDetails, EMBED_ACCESS_CODES, embedErrorHint, isEmbedSession, PROTOCOL_VERSION, type EmbedAccessCode, type EmbedAccessDetails, type EmbedAccessNext, type EmbedAccessState, type EmbedErrorCode, type EmbedEventMap, type EmbedEventName, type EmbedKind, type EmbedSession, type FrameMessage, type ParentMessage } from '../embed/protocol.js';
4
4
  /** `HealthierBusiness.mount(element, options)` for the browser. It holds no API key and cannot make API calls. */
5
5
  export declare const HealthierBusiness: {
6
6
  readonly mount: typeof mount;
7
- readonly version: "0.1.0";
7
+ readonly version: "0.2.0";
8
8
  };
9
- export declare const version = "0.1.0";
9
+ export declare const version = "0.2.0";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.version = exports.HealthierBusiness = exports.PROTOCOL_VERSION = exports.isEmbedSession = exports.embedErrorHint = exports.ALLOW = exports.SANDBOX = exports.sessionFetcher = exports.mount = void 0;
3
+ exports.version = exports.HealthierBusiness = exports.PROTOCOL_VERSION = exports.isEmbedSession = exports.embedErrorHint = exports.EMBED_ACCESS_CODES = exports.cleanAccessDetails = exports.ALLOW = exports.SANDBOX = exports.sessionFetcher = exports.mount = void 0;
4
4
  const mount_js_1 = require("./mount.js");
5
5
  const version_js_1 = require("../version.js");
6
6
  var mount_js_2 = require("./mount.js");
@@ -9,6 +9,8 @@ Object.defineProperty(exports, "sessionFetcher", { enumerable: true, get: functi
9
9
  Object.defineProperty(exports, "SANDBOX", { enumerable: true, get: function () { return mount_js_2.SANDBOX; } });
10
10
  Object.defineProperty(exports, "ALLOW", { enumerable: true, get: function () { return mount_js_2.ALLOW; } });
11
11
  var protocol_js_1 = require("../embed/protocol.js");
12
+ Object.defineProperty(exports, "cleanAccessDetails", { enumerable: true, get: function () { return protocol_js_1.cleanAccessDetails; } });
13
+ Object.defineProperty(exports, "EMBED_ACCESS_CODES", { enumerable: true, get: function () { return protocol_js_1.EMBED_ACCESS_CODES; } });
12
14
  Object.defineProperty(exports, "embedErrorHint", { enumerable: true, get: function () { return protocol_js_1.embedErrorHint; } });
13
15
  Object.defineProperty(exports, "isEmbedSession", { enumerable: true, get: function () { return protocol_js_1.isEmbedSession; } });
14
16
  Object.defineProperty(exports, "PROTOCOL_VERSION", { enumerable: true, get: function () { return protocol_js_1.PROTOCOL_VERSION; } });
@@ -36,6 +36,8 @@ export interface MountOptions {
36
36
  onPassed?: (data: EmbedEventMap['passed']) => void;
37
37
  onFailed?: (data: EmbedEventMap['failed']) => void;
38
38
  onSubmitted?: (data: EmbedEventMap['submitted']) => void;
39
+ /** The candidate accepted the Hub terms in the frame. */
40
+ onTermsAccepted?: (data: EmbedEventMap['terms-accepted']) => void;
39
41
  onError?: (error: EmbedEventMap['error']) => void;
40
42
  /**
41
43
  * The frame asks for the top of its content to be in view when the learner moves to another lesson or page. By default the SDK
@@ -53,8 +53,12 @@ function sessionFetcher(options) {
53
53
  body: JSON.stringify(reason === 'refresh' ? { action: 'refresh', sessionId } : { action: 'create', kind, courseId, formShortcode }),
54
54
  });
55
55
  const body = (await res.json().catch(() => ({})));
56
- if (!res.ok)
57
- throw new Error(typeof body.message === 'string' ? body.message : `Your server answered HTTP ${res.status}.`);
56
+ if (!res.ok) {
57
+ const message = typeof body.message === 'string' ? body.message : `Your server answered HTTP ${res.status}.`;
58
+ // A refusal from the Hub that the page can act on (the access errors, course_not_pending) keeps its code and details.
59
+ const code = typeof body.error === 'string' && protocol_js_1.EMBED_SESSION_ERROR_CODES.includes(body.error) ? body.error : undefined;
60
+ throw Object.assign(new Error(message), code ? { code, details: (0, protocol_js_1.cleanAccessDetails)(body.details) } : {});
61
+ }
58
62
  return body;
59
63
  };
60
64
  }
@@ -107,16 +111,19 @@ function mount(element, options) {
107
111
  case 'submitted':
108
112
  options.onSubmitted?.(d);
109
113
  break;
114
+ case 'terms-accepted':
115
+ options.onTermsAccepted?.(d);
116
+ break;
110
117
  case 'error':
111
118
  options.onError?.(d);
112
119
  break;
113
120
  }
114
121
  handlers.get(name)?.forEach((h) => h(d));
115
122
  };
116
- const fail = (code, message) => {
123
+ const fail = (code, message, details) => {
117
124
  win.clearTimeout(readyTimer);
118
125
  rejectReady(new Error(message));
119
- emit('error', { code, message: message || (0, protocol_js_1.embedErrorHint)(code) });
126
+ emit('error', { code, message: message || (0, protocol_js_1.embedErrorHint)(code), ...(details ? { details } : {}) });
120
127
  };
121
128
  const waitForFrame = () => {
122
129
  win.clearTimeout(readyTimer);
@@ -260,6 +267,11 @@ function mount(element, options) {
260
267
  element.appendChild(iframe);
261
268
  }
262
269
  catch (e) {
270
+ const known = e?.code;
271
+ if (typeof known === 'string' && protocol_js_1.EMBED_SESSION_ERROR_CODES.includes(known)) {
272
+ fail(known, e.message || (0, protocol_js_1.embedErrorHint)(known) || known, (0, protocol_js_1.cleanAccessDetails)(e.details));
273
+ return;
274
+ }
263
275
  fail('session_failed', e instanceof Error ? e.message : 'Could not get a session from your server.');
264
276
  }
265
277
  })();
@@ -1,3 +1,4 @@
1
+ import { type EmbedAccessDetails, type EmbedAccessNext } from '../embed/protocol.js';
1
2
  export interface RateLimitInfo {
2
3
  /** Calls the key may make per hour. */
3
4
  limit?: number;
@@ -42,6 +43,8 @@ export declare class ApiError extends HubError {
42
43
  }
43
44
  /** Next steps for error codes, shown by `ApiError.hint` and used in the README troubleshooting table. */
44
45
  export declare const CODE_HINTS: Record<string, string>;
46
+ /** What to do for each `details.next` of an access error. */
47
+ export declare const NEXT_HINTS: Record<EmbedAccessNext, string>;
45
48
  /** 401: the token was refused even after renewing it, or the API key is wrong. */
46
49
  export declare class AuthenticationError extends ApiError {
47
50
  }
@@ -54,6 +57,16 @@ export declare class NotFoundError extends ApiError {
54
57
  /** 409: a taken slot, or an idempotency key reused with a different body. */
55
58
  export declare class ConflictError extends ApiError {
56
59
  }
60
+ /**
61
+ * 409 when the Hub will not create an embed session because the candidate's access is not in place: `course_access_required`,
62
+ * `payment_pending`, `renewal_approval_required` or `access_expired`. `access` says what to do next. Nothing was charged or started.
63
+ */
64
+ export declare class EmbedAccessError extends ConflictError {
65
+ /** `{ state, payer, next }` from the Hub. Unknown fields and values are dropped. */
66
+ get access(): EmbedAccessDetails;
67
+ }
68
+ /** True for an `EmbedAccessError`. */
69
+ export declare function isEmbedAccessError(error: unknown): error is EmbedAccessError;
57
70
  /** 402: not enough credits or balance. Nothing was charged. */
58
71
  export declare class InsufficientCreditsError extends ApiError {
59
72
  }
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EmbedError = exports.WebhookSignatureError = exports.AuthThrottledError = exports.AbortedError = exports.NetworkError = exports.ServerError = exports.RateLimitError = exports.GoneError = exports.ValidationError = exports.InsufficientCreditsError = exports.ConflictError = exports.NotFoundError = exports.PermissionError = exports.AuthenticationError = exports.CODE_HINTS = exports.ApiError = exports.ConfigError = exports.HubError = void 0;
3
+ exports.EmbedError = exports.WebhookSignatureError = exports.AuthThrottledError = exports.AbortedError = exports.NetworkError = exports.ServerError = exports.RateLimitError = exports.GoneError = exports.ValidationError = exports.InsufficientCreditsError = exports.EmbedAccessError = exports.ConflictError = exports.NotFoundError = exports.PermissionError = exports.AuthenticationError = exports.NEXT_HINTS = exports.CODE_HINTS = exports.ApiError = exports.ConfigError = exports.HubError = void 0;
4
+ exports.isEmbedAccessError = isEmbedAccessError;
4
5
  exports.apiErrorFrom = apiErrorFrom;
6
+ const protocol_js_1 = require("../embed/protocol.js");
5
7
  /** Base class of everything the SDK throws on purpose. */
6
8
  class HubError extends Error {
7
9
  constructor(message, options) {
@@ -45,6 +47,11 @@ class ApiError extends HubError {
45
47
  if (this.code === 'validation_failed' && this.details && typeof this.details === 'object' && 'origin' in this.details) {
46
48
  return exports.CODE_HINTS.origin_not_registered;
47
49
  }
50
+ if (protocol_js_1.EMBED_ACCESS_CODES.includes(this.code)) {
51
+ const next = (0, protocol_js_1.cleanAccessDetails)(this.details).next;
52
+ if (next)
53
+ return exports.NEXT_HINTS[next];
54
+ }
48
55
  return exports.CODE_HINTS[this.code];
49
56
  }
50
57
  toJSON() {
@@ -64,11 +71,21 @@ exports.CODE_HINTS = {
64
71
  origin_not_registered: 'Origin not registered: add this website (scheme, host and port, for example https://learn.example.com) under Developer > Embed in Hub, then create the session again.',
65
72
  course_not_embeddable: 'This course cannot be shown in a frame: it must be delivered by Course Studio and linked to an Online Training course.',
66
73
  course_not_pending: 'The candidate has already completed this course. Only courses still to do can be opened.',
67
- course_access_required: 'The candidate does not have this course yet. Assign it first with hb.onlineTraining.candidates.courses().',
74
+ course_access_required: 'The candidate\'s access has not been started. Start it with hb.onlineTraining.candidates.accessStart(), then create the session again. (If the course is not assigned to them yet, assign it first with hb.onlineTraining.candidates.courses().)',
75
+ payment_pending: 'The candidate has a payment link that is not paid yet. Ask them to pay it (or start access again for a new link, which replaces the old one), wait for the online-training.access.started webhook, then create the session again.',
76
+ renewal_approval_required: 'A manual renewal waits for approval; the request is recorded and the agency emailed once. Approve it with hb.onlineTraining.candidates.renewalApprove() (or in Hub), then create the session again.',
77
+ access_expired: 'The candidate\'s access has ended. Renew it with hb.onlineTraining.candidates.accessStart(), or ask for approval with renewalRequest() when renewals need approval, then create the session again.',
68
78
  form_not_pending: 'This questionnaire was already sent, or the request already has an outcome. Only forms still to answer can be opened.',
69
79
  session_finished: 'This session is complete. Create a new session if the person needs it again.',
70
80
  session_expired: 'This session timed out (60 minutes without a refresh, 12 hours at the most). Create a new session.',
71
81
  };
82
+ /** What to do for each `details.next` of an access error. */
83
+ exports.NEXT_HINTS = {
84
+ start_access: 'Start the candidate\'s access with hb.onlineTraining.candidates.accessStart() on your server, then create the session again.',
85
+ pay: 'The candidate pays for this training: give them the payment link from accessStart() (a new call makes a new link and replaces the old one), wait for the online-training.access.started webhook, then create the session again.',
86
+ await_approval: 'A manual renewal waits for approval. Approve it with hb.onlineTraining.candidates.renewalApprove() (or in Hub), then create the session again.',
87
+ renew: 'The access has ended. Renew it with hb.onlineTraining.candidates.accessStart(), or ask for approval with renewalRequest() when renewals need approval, then create the session again.',
88
+ };
72
89
  /** 401: the token was refused even after renewing it, or the API key is wrong. */
73
90
  class AuthenticationError extends ApiError {
74
91
  }
@@ -85,6 +102,21 @@ exports.NotFoundError = NotFoundError;
85
102
  class ConflictError extends ApiError {
86
103
  }
87
104
  exports.ConflictError = ConflictError;
105
+ /**
106
+ * 409 when the Hub will not create an embed session because the candidate's access is not in place: `course_access_required`,
107
+ * `payment_pending`, `renewal_approval_required` or `access_expired`. `access` says what to do next. Nothing was charged or started.
108
+ */
109
+ class EmbedAccessError extends ConflictError {
110
+ /** `{ state, payer, next }` from the Hub. Unknown fields and values are dropped. */
111
+ get access() {
112
+ return (0, protocol_js_1.cleanAccessDetails)(this.details);
113
+ }
114
+ }
115
+ exports.EmbedAccessError = EmbedAccessError;
116
+ /** True for an `EmbedAccessError`. */
117
+ function isEmbedAccessError(error) {
118
+ return error instanceof EmbedAccessError;
119
+ }
88
120
  /** 402: not enough credits or balance. Nothing was charged. */
89
121
  class InsufficientCreditsError extends ApiError {
90
122
  }
@@ -164,7 +196,7 @@ function apiErrorFrom(status, code, message, details, requestId, retryAfter, rat
164
196
  if (status === 404)
165
197
  return new NotFoundError(...args);
166
198
  if (status === 409)
167
- return new ConflictError(...args);
199
+ return protocol_js_1.EMBED_ACCESS_CODES.includes(code) ? new EmbedAccessError(...args) : new ConflictError(...args);
168
200
  if (status === 410)
169
201
  return new GoneError(...args);
170
202
  if (status === 422)
@@ -136,7 +136,9 @@ function createEmbedHandler(embed, options) {
136
136
  }
137
137
  catch (e) {
138
138
  if (e instanceof errors_js_1.ApiError && e.status >= 400 && e.status < 500 && e.status !== 401 && e.status !== 403) {
139
- return reply(e.status, { error: e.code, message: e.message, hint: e.hint, requestId: e.requestId });
139
+ // Only the code, the message, the hint and (for the access errors) the three known `details` fields go to the browser.
140
+ const details = e instanceof errors_js_1.EmbedAccessError ? { details: e.access } : {};
141
+ return reply(e.status, { error: e.code, message: e.message, hint: e.hint, requestId: e.requestId, ...details });
140
142
  }
141
143
  if (e instanceof errors_js_1.EmbedError)
142
144
  return problem(e.status ?? 400, e.code, e.message);
@@ -19,13 +19,34 @@ export interface EmbedSession {
19
19
  /** The one website origin allowed to show this frame. */
20
20
  allowedOrigin: string;
21
21
  }
22
- export type EmbedEventName = 'ready' | 'progress' | 'completed' | 'passed' | 'failed' | 'submitted' | 'error' | 'token-expiring';
22
+ export type EmbedEventName = 'ready' | 'progress' | 'completed' | 'passed' | 'failed' | 'submitted' | 'terms-accepted' | 'error' | 'token-expiring';
23
+ /**
24
+ * The codes the Hub answers with (HTTP 409) when it will not create a session because the candidate's training access is not in
25
+ * place. Each carries `details` (see `EmbedAccessDetails`).
26
+ */
27
+ export declare const EMBED_ACCESS_CODES: readonly ["course_access_required", "payment_pending", "renewal_approval_required", "access_expired"];
28
+ export type EmbedAccessCode = (typeof EMBED_ACCESS_CODES)[number];
29
+ /** Session errors your embed route passes to the browser, so the page can say what is wrong. The four access codes and `course_not_pending`. */
30
+ export declare const EMBED_SESSION_ERROR_CODES: readonly string[];
31
+ /** What the candidate's access looks like: `not_started`, `payment_pending` (unpaid link), `awaiting_approval` (manual renewal) or `expired`. */
32
+ export type EmbedAccessState = 'not_started' | 'payment_pending' | 'awaiting_approval' | 'expired';
33
+ /** What to do next: `start_access` (call accessStart), `pay` (the candidate pays the link), `await_approval` (approve the renewal) or `renew`. */
34
+ export type EmbedAccessNext = 'start_access' | 'pay' | 'await_approval' | 'renew';
35
+ /** The `details` of the four access errors. Every field is optional: a field the Hub did not send, or sent with an unknown value, is left out. */
36
+ export interface EmbedAccessDetails {
37
+ state?: EmbedAccessState;
38
+ /** Who pays for the candidate's training: your account's credits (`client`) or the candidate. */
39
+ payer?: 'client' | 'candidate';
40
+ next?: EmbedAccessNext;
41
+ }
42
+ /** Keeps only the three known fields with known values, so nothing else the Hub (or anyone) put there reaches the browser. */
43
+ export declare function cleanAccessDetails(value: unknown): EmbedAccessDetails;
23
44
  /**
24
45
  * Codes of the `error` event. The first group is what the Hub frame sends (a refused launch token or origin, a session that
25
46
  * ended or is unknown, a refused call after the handshake, a lost connection); the second is raised by the SDK itself.
26
47
  * `embedErrorHint()` explains each. Unknown codes are possible: the type stays open.
27
48
  */
28
- export type EmbedErrorCode = 'token_used' | 'token_invalid' | 'token_expired' | 'frame_invalid' | 'origin_not_allowed' | 'not_allowed' | 'session_expired' | 'session_finished' | 'not_found' | 'network' | 'frame_timeout' | 'origin_mismatch' | 'session_failed' | 'session_changed' | 'token_refresh_failed' | 'init_failed' | (string & {});
49
+ export type EmbedErrorCode = 'token_used' | 'token_invalid' | 'token_expired' | 'frame_invalid' | 'origin_not_allowed' | 'not_allowed' | 'session_expired' | 'session_finished' | 'not_found' | 'network' | 'terms_required' | 'access_expired' | 'course_access_required' | 'payment_pending' | 'renewal_approval_required' | 'course_not_pending' | 'frame_timeout' | 'origin_mismatch' | 'session_failed' | 'session_changed' | 'token_refresh_failed' | 'init_failed' | (string & {});
29
50
  /** Plain words for an `error` event code, or undefined for an unknown one. */
30
51
  export declare function embedErrorHint(code: string): string | undefined;
31
52
  /**
@@ -60,10 +81,19 @@ export interface EmbedEventMap {
60
81
  submitted: {
61
82
  requestId: number;
62
83
  };
63
- /** `code` says why (see `EmbedErrorCode`); `message` is added by the SDK in plain words. */
84
+ /** The candidate accepted the Hub terms in the frame (always the first screen for someone who has not). `version` is the terms version, `acceptedAt` ISO 8601. The webhook `online-training.terms.accepted` says the same to your server. */
85
+ 'terms-accepted': {
86
+ version: string;
87
+ acceptedAt: string;
88
+ };
89
+ /**
90
+ * `code` says why (see `EmbedErrorCode`); `message` is added by the SDK in plain words. For the four access codes `details` says
91
+ * what to do next. Browser events can be forged by the person at the browser: use them to update the screen, not to decide anything.
92
+ */
64
93
  error: {
65
94
  code: EmbedErrorCode;
66
95
  message?: string;
96
+ details?: EmbedAccessDetails;
67
97
  };
68
98
  /** The frame's access ends in about 2 minutes (`expires_at`, ISO 8601). The SDK renews it for you; you only see this event, you do not act on it. */
69
99
  'token-expiring': {
@@ -4,11 +4,33 @@
4
4
  * Every message carries `hb: 1`.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.PROTOCOL_VERSION = void 0;
7
+ exports.EMBED_SESSION_ERROR_CODES = exports.EMBED_ACCESS_CODES = exports.PROTOCOL_VERSION = void 0;
8
+ exports.cleanAccessDetails = cleanAccessDetails;
8
9
  exports.embedErrorHint = embedErrorHint;
9
10
  exports.isFrameMessage = isFrameMessage;
10
11
  exports.isEmbedSession = isEmbedSession;
11
12
  exports.PROTOCOL_VERSION = 1;
13
+ /**
14
+ * The codes the Hub answers with (HTTP 409) when it will not create a session because the candidate's training access is not in
15
+ * place. Each carries `details` (see `EmbedAccessDetails`).
16
+ */
17
+ exports.EMBED_ACCESS_CODES = ['course_access_required', 'payment_pending', 'renewal_approval_required', 'access_expired'];
18
+ /** Session errors your embed route passes to the browser, so the page can say what is wrong. The four access codes and `course_not_pending`. */
19
+ exports.EMBED_SESSION_ERROR_CODES = [...exports.EMBED_ACCESS_CODES, 'course_not_pending'];
20
+ const ACCESS_STATES = ['not_started', 'payment_pending', 'awaiting_approval', 'expired'];
21
+ const ACCESS_NEXT = ['start_access', 'pay', 'await_approval', 'renew'];
22
+ /** Keeps only the three known fields with known values, so nothing else the Hub (or anyone) put there reaches the browser. */
23
+ function cleanAccessDetails(value) {
24
+ const v = (typeof value === 'object' && value !== null ? value : {});
25
+ const out = {};
26
+ if (typeof v.state === 'string' && ACCESS_STATES.includes(v.state))
27
+ out.state = v.state;
28
+ if (v.payer === 'client' || v.payer === 'candidate')
29
+ out.payer = v.payer;
30
+ if (typeof v.next === 'string' && ACCESS_NEXT.includes(v.next))
31
+ out.next = v.next;
32
+ return out;
33
+ }
12
34
  const ERROR_HINTS = {
13
35
  token_used: 'The launch token was already used. A token works once: create or refresh the session and mount again.',
14
36
  token_invalid: 'The launch token is not valid for this session. Make sure getSession returns the session your server just created or refreshed.',
@@ -26,6 +48,12 @@ const ERROR_HINTS = {
26
48
  session_changed: 'Refreshing returned a different session. Your route must call hb.embed.refresh(sessionId) for a refresh.',
27
49
  token_refresh_failed: 'Renewing the launch token failed twice. Check that your refresh route works and that the person is still signed in.',
28
50
  init_failed: 'The frame could not be started with the token.',
51
+ terms_required: 'The candidate has not accepted the terms. The frame shows them first; nothing else can be used until they accept (watch for the terms-accepted event).',
52
+ access_expired: 'The candidate\'s access has ended. Renew it (accessStart, or the renewal calls when renewals need approval), then create a new session.',
53
+ course_access_required: 'The candidate\'s access has not been started. Start it with hb.onlineTraining.candidates.accessStart() on your server, then create the session again.',
54
+ payment_pending: 'The candidate has a payment link that is not paid yet. Ask them to pay it, then create the session again.',
55
+ renewal_approval_required: 'A renewal waits for approval. Approve it (renewalApprove or in Hub), then create the session again.',
56
+ course_not_pending: 'The candidate has already completed this course. Only courses still to do can be opened.',
29
57
  };
30
58
  /** Plain words for an `error` event code, or undefined for an unknown one. */
31
59
  function embedErrorHint(code) {
@@ -22,9 +22,16 @@ export interface WebhookEvents {
22
22
  "occupational-health.request.rejected": Types.WebhookOccupationalHealthRequestRejectedData;
23
23
  "occupational-health.request.submitted": Types.WebhookOccupationalHealthRequestSubmittedData;
24
24
  "occupational-health.request.temporary_clearance": Types.WebhookOccupationalHealthRequestTemporaryClearanceData;
25
+ "online-training.access.payment_link.expired": Types.WebhookOnlineTrainingAccessPaymentLinkExpiredData;
26
+ "online-training.access.revoked": Types.WebhookOnlineTrainingAccessRevokedData;
27
+ "online-training.access.started": Types.WebhookOnlineTrainingAccessStartedData;
25
28
  "online-training.certificate.issued": Types.WebhookOnlineTrainingCertificateIssuedData;
26
29
  "online-training.course.assigned": Types.WebhookOnlineTrainingCourseAssignedData;
27
30
  "online-training.course.completed": Types.WebhookOnlineTrainingCourseCompletedData;
31
+ "online-training.renewal.approved": Types.WebhookOnlineTrainingRenewalApprovedData;
32
+ "online-training.renewal.declined": Types.WebhookOnlineTrainingRenewalDeclinedData;
33
+ "online-training.renewal.requested": Types.WebhookOnlineTrainingRenewalRequestedData;
34
+ "online-training.terms.accepted": Types.WebhookOnlineTrainingTermsAcceptedData;
28
35
  "online-training.training.completed": Types.WebhookOnlineTrainingTrainingCompletedData;
29
36
  "online-training.training.expired": Types.WebhookOnlineTrainingTrainingExpiredData;
30
37
  "online-training.training.expiring": Types.WebhookOnlineTrainingTrainingExpiringData;
@@ -79,4 +86,4 @@ export type HubWebhookEvent = {
79
86
  data: WebhookEvents[K];
80
87
  };
81
88
  }[WebhookEventType];
82
- export declare const WEBHOOK_EVENT_TYPES: readonly ["clinical-appraisals.booking.confirmed", "clinical-appraisals.booking.created", "clinical-interviews.booking.attendance_marked", "clinical-interviews.booking.cancelled", "clinical-interviews.booking.confirmed", "clinical-interviews.booking.created", "clinical-interviews.booking.interview_completed", "clinical-interviews.booking.interview_report_available", "clinical-interviews.booking.rescheduled", "dbs-rtw.alert.raised", "dbs-rtw.dbs.status_changed", "dbs-rtw.rtw.status_changed", "occupational-health.document.available", "occupational-health.renewal.due", "occupational-health.request.awaiting_candidate", "occupational-health.request.fail", "occupational-health.request.full_clearance", "occupational-health.request.questionnaire_completed", "occupational-health.request.rejected", "occupational-health.request.submitted", "occupational-health.request.temporary_clearance", "online-training.certificate.issued", "online-training.course.assigned", "online-training.course.completed", "online-training.training.completed", "online-training.training.expired", "online-training.training.expiring", "practical-training.balance.depleted", "practical-training.balance.low", "practical-training.booking.attendance_marked", "practical-training.booking.cancelled", "practical-training.booking.certificate_available", "practical-training.booking.confirmed", "practical-training.booking.created", "practical-training.booking.no_show", "practical-training.booking.rescheduled", "practical-training.booking_invite.opened", "practical-training.booking_invite.sent", "practical-training.booking_invite.used", "practical-training.credits.depleted", "practical-training.credits.low", "practical-training.slot_hold.expired", "practical-training.training_event.seats_low", "references.candidate.referees.submitted", "references.reference.all_completed", "references.reference.declined", "references.reference.expired", "references.reference.reminder.sent", "references.reference.request.created", "references.reference.submitted", "registration-monitoring.worker.initial_verification", "registration-monitoring.worker.status_changed", "training-verification.failed", "training-verification.not_found", "training-verification.processing", "training-verification.refunded", "training-verification.rejected", "training-verification.submitted", "training-verification.verified", "virtual-bls-training.booking.attendance_marked", "virtual-bls-training.booking.cancelled", "virtual-bls-training.booking.certificate_available", "virtual-bls-training.booking.confirmed", "virtual-bls-training.booking.created", "virtual-bls-training.booking.equipment_late", "virtual-bls-training.booking.rescheduled"];
89
+ export declare const WEBHOOK_EVENT_TYPES: readonly ["clinical-appraisals.booking.confirmed", "clinical-appraisals.booking.created", "clinical-interviews.booking.attendance_marked", "clinical-interviews.booking.cancelled", "clinical-interviews.booking.confirmed", "clinical-interviews.booking.created", "clinical-interviews.booking.interview_completed", "clinical-interviews.booking.interview_report_available", "clinical-interviews.booking.rescheduled", "dbs-rtw.alert.raised", "dbs-rtw.dbs.status_changed", "dbs-rtw.rtw.status_changed", "occupational-health.document.available", "occupational-health.renewal.due", "occupational-health.request.awaiting_candidate", "occupational-health.request.fail", "occupational-health.request.full_clearance", "occupational-health.request.questionnaire_completed", "occupational-health.request.rejected", "occupational-health.request.submitted", "occupational-health.request.temporary_clearance", "online-training.access.payment_link.expired", "online-training.access.revoked", "online-training.access.started", "online-training.certificate.issued", "online-training.course.assigned", "online-training.course.completed", "online-training.renewal.approved", "online-training.renewal.declined", "online-training.renewal.requested", "online-training.terms.accepted", "online-training.training.completed", "online-training.training.expired", "online-training.training.expiring", "practical-training.balance.depleted", "practical-training.balance.low", "practical-training.booking.attendance_marked", "practical-training.booking.cancelled", "practical-training.booking.certificate_available", "practical-training.booking.confirmed", "practical-training.booking.created", "practical-training.booking.no_show", "practical-training.booking.rescheduled", "practical-training.booking_invite.opened", "practical-training.booking_invite.sent", "practical-training.booking_invite.used", "practical-training.credits.depleted", "practical-training.credits.low", "practical-training.slot_hold.expired", "practical-training.training_event.seats_low", "references.candidate.referees.submitted", "references.reference.all_completed", "references.reference.declined", "references.reference.expired", "references.reference.reminder.sent", "references.reference.request.created", "references.reference.submitted", "registration-monitoring.worker.initial_verification", "registration-monitoring.worker.status_changed", "training-verification.failed", "training-verification.not_found", "training-verification.processing", "training-verification.refunded", "training-verification.rejected", "training-verification.submitted", "training-verification.verified", "virtual-bls-training.booking.attendance_marked", "virtual-bls-training.booking.cancelled", "virtual-bls-training.booking.certificate_available", "virtual-bls-training.booking.confirmed", "virtual-bls-training.booking.created", "virtual-bls-training.booking.equipment_late", "virtual-bls-training.booking.rescheduled"];